forked from coolwanglu/pdf2htmlEX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutline.cc
More file actions
72 lines (53 loc) · 1.4 KB
/
Copy pathoutline.cc
File metadata and controls
72 lines (53 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* outline.cc
*
* Handling Outline items
*
* by WangLu
* 2013.01.28
*/
#include <iostream>
#include <Outline.h>
#include <goo/GooList.h>
#include "HTMLRenderer.h"
#include "util/namespace.h"
#include "util/unicode.h"
namespace pdf2htmlEX {
using std::ostream;
void HTMLRenderer::process_outline_items(GooList * items)
{
if((!items) || (items->getLength() == 0))
return;
f_outline.fs << "<ul>";
for(int i = 0; i < items->getLength(); ++i)
{
OutlineItem * item = (OutlineItem*)(items->get(i));
string detail;
string dest = get_linkaction_str(item->getAction(), detail);
// we don't care dest is empty or not.
f_outline.fs << "<li>"
<< "<a href=\"" << dest << "\"";
if(!detail.empty())
f_outline.fs << " data-dest-detail='" << detail << "'";
f_outline.fs << ">";
outputUnicodes(f_outline.fs, item->getTitle(), item->getTitleLength());
f_outline.fs << "</a>";
// check kids
item->open();
if(item->hasKids())
{
process_outline_items(item->getKids());
}
item->close();
f_outline.fs << "</li>";
}
f_outline.fs << "</ul>";
}
void HTMLRenderer::process_outline()
{
Outline * outline = cur_doc->getOutline();
if(!outline)
return;
process_outline_items(outline->getItems());
}
}// namespace pdf2htmlEX