Skip to content

Commit db9c9a7

Browse files
committed
Merge pull request #1 from adityab/master
Working implementation of PDF.js backend
2 parents 970772a + 59680ad commit db9c9a7

5 files changed

Lines changed: 879 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,45 @@ else ( IS_DIRECTORY $ENV{VIEWERJS_DOWNLOAD_DIR} )
5757
endif ( IS_DIRECTORY $ENV{VIEWERJS_DOWNLOAD_DIR} )
5858
MESSAGE ( STATUS "external downloads will be stored/expected in: ${EXTERNALS_DOWNLOAD_DIR}" )
5959

60+
SET ( VIEWER_BUILD_DIR ${CMAKE_BINARY_DIR}/viewer )
61+
FILE ( MAKE_DIRECTORY ${VIEWER_BUILD_DIR})
62+
SET ( VIEWERZIP ${CMAKE_BINARY_DIR}/Viewer.js-${VIEWERJS_VERSION}.zip)
63+
SET ( WEBODF_SOURCE_DIR ${CMAKE_BINARY_DIR}/WebODF-Prefix/src/WebODF )
64+
SET ( WEBODF_BUILD_DIR ${CMAKE_BINARY_DIR}/WebODF-Prefix/src/WebODF-build )
65+
SET ( PDFJS_SOURCE_DIR ${CMAKE_BINARY_DIR}/PDFjs-Prefix/src/PDFjs )
66+
6067
ExternalProject_Add(
6168
WebODF
6269
GIT_REPOSITORY git@gitorious.org:webodf/webodf.git
63-
UPDATE_COMMAND ""
64-
INSTALL_COMMAND ""
65-
ALWAYS 0
70+
UPDATE_COMMAND git pull origin master
71+
BUILD_COMMAND make viewerbuilddir-target
72+
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${WEBODF_BUILD_DIR}/viewer/ ${VIEWER_BUILD_DIR}
6673
)
6774

75+
ExternalProject_Add(
76+
PDFjs
77+
GIT_REPOSITORY git@github.com:mozilla/pdf.js.git
78+
UPDATE_COMMAND git pull
79+
CONFIGURE_COMMAND ""
80+
BUILD_COMMAND node ${PDFJS_SOURCE_DIR}/make.js generic
81+
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${PDFJS_SOURCE_DIR}/build/generic/build/pdf.js ${VIEWER_BUILD_DIR}/pdf.js
82+
)
83+
84+
add_custom_command(
85+
OUTPUT ${VIEWERZIP}
86+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/PluginLoader.js ${VIEWER_BUILD_DIR}/PluginLoader.js
87+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/PDFViewerPlugin.js ${VIEWER_BUILD_DIR}/PDFViewerPlugin.js
88+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/TextLayerBuilder.js ${VIEWER_BUILD_DIR}/TextLayerBuilder.js
89+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/PDFViewerPlugin.css ${VIEWER_BUILD_DIR}/PDFViewerPlugin.css
90+
COMMAND node ARGS ${WEBODF_SOURCE_DIR}/webodf/lib/runtime.js ${WEBODF_SOURCE_DIR}/webodf/tools/zipdir.js
91+
${VIEWER_BUILD_DIR}
92+
${VIEWERZIP}
93+
)
94+
95+
96+
add_custom_target(Viewer ALL
97+
DEPENDS
98+
${VIEWERZIP}
99+
WebODF
100+
PDFjs
101+
)

PDFViewerPlugin.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.page {
2+
margin: 7px auto 7px auto;
3+
position: relative;
4+
overflow: visible;
5+
background-clip: content-box;
6+
background-color: white;
7+
8+
box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75);
9+
-webkit-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75);
10+
-moz-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75);
11+
-ms-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75);
12+
-o-box-shadow: 0px 0px 7px rgba(0, 0, 0, 0.75);
13+
}
14+
15+
.textLayer {
16+
position: absolute;
17+
left: 0;
18+
top: 0;
19+
right: 0;
20+
bottom: 0;
21+
color: #000;
22+
font-family: sans-serif;
23+
overflow: hidden;
24+
}
25+
26+
.textLayer > div {
27+
color: transparent;
28+
position: absolute;
29+
line-height: 1;
30+
white-space: pre;
31+
cursor: text;
32+
overflow: hidden;
33+
}
34+
35+
::selection { background:rgba(0,0,255,0.3); }
36+
::-moz-selection { background:rgba(0,0,255,0.3); }
37+

0 commit comments

Comments
 (0)