Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
pdf-customizer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
28355607
authored
2016-09-14 11:09:06 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
new pdf viewer
1 parent
642a5aa2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
22 deletions
public/files/js/interfaceGdrive.js
public/files/js/interfaceGdrive.js
View file @
2835560
...
...
@@ -588,7 +588,7 @@ function returnfileOptions(files, form, preview) {
});
$
.
ajax
({
url
:
''
+
pluginUrl
+
'/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files'
,
url
:
pluginUrl
+
'/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files'
,
type
:
'POST'
,
data
:
data
,
cache
:
false
,
...
...
@@ -705,7 +705,18 @@ function returnOptions(form, preview) {
function
finalPdf
(
data
,
json
)
{
jQuery
(
function
(
$
)
{
if
(
!
window
.
requestAnimationFrame
)
{
window
.
requestAnimationFrame
=
(
function
()
{
return
window
.
webkitRequestAnimationFrame
||
window
.
mozRequestAnimationFrame
||
window
.
oRequestAnimationFrame
||
window
.
msRequestAnimationFrame
||
function
(
callback
,
element
)
{
window
.
setTimeout
(
callback
,
1000
/
60
);
};
})();
}
...
...
@@ -724,30 +735,12 @@ function finalPdf(data, json) {
$
(
'#controls'
).
hide
();
$
(
'#pdfPreviewInner'
).
show
()
PDFJS
.
disableStream
=
true
;
PDFJS
.
getDocument
(
pdf_customizer
+
'/fileentry/getPDF/'
+
json
[
0
].
folder
+
'/new_'
+
json
[
0
].
file
).
then
(
function
(
pdfFile
)
{
var
pageNumber
=
setpage
;
pdfFile
.
getPage
(
pageNumber
).
then
(
function
(
page
)
{
var
scale
=
1
;
var
viewport
=
page
.
getViewport
(
scale
);
});
});
var
canvas
=
document
.
getElementById
(
'renderedPdf'
);
var
context
=
canvas
.
getContext
(
'2d'
);
var
renderContext
=
{
canvasContext
:
context
,
viewport
:
viewport
};
page
.
render
(
renderContext
);
var
strVar2
=
""
strVar2
+=
'<div id="seepdf" style=" width:'
+
imageWidth
+
'px; height: '
+
imageHeight
+
'px; overflow: hidden;" > <
canvas id="renderedPdf"></canvas
></div>'
;
strVar2
+=
'<div id="seepdf" style=" width:'
+
imageWidth
+
'px; height: '
+
imageHeight
+
'px; overflow: hidden;" > <
div id="page"><canvas id="the-canvas"></canvas></page
></div>'
;
document
.
getElementById
(
'pdfPreviewInner'
).
innerHTML
=
strVar2
;
...
...
@@ -755,6 +748,45 @@ function finalPdf(data, json) {
document
.
getElementById
(
'controls'
).
innerHTML
=
strVar3
;
var
pfd_url
=
pdf_customizer
+
'/fileentry/getPDF/'
+
json
[
0
].
folder
+
'/new_'
+
json
[
0
].
file
;
// Asynchronous download PDF
PDFJS
.
getDocument
(
pfd_url
)
.
then
(
function
(
pdf
)
{
return
pdf
.
getPage
(
parseInt
(
setpage
));
})
.
then
(
function
(
page
)
{
// Set scale (zoom) level
var
scale
=
1.35
;
// Get viewport (dimensions)
var
viewport
=
page
.
getViewport
(
scale
);
// Get canvas#the-canvas
var
canvas
=
document
.
getElementById
(
'the-canvas'
);
// Fetch canvas' 2d context
var
context
=
canvas
.
getContext
(
'2d'
);
// Set dimensions to Canvas
canvas
.
height
=
viewport
.
height
;
canvas
.
width
=
viewport
.
width
;
// Prepare object needed by render method
var
renderContext
=
{
canvasContext
:
context
,
viewport
:
viewport
};
// Render PDF page
page
.
render
(
renderContext
);
});
$
.
LoadingOverlaySetup
({
color
:
"rgba(0, 0, 0, 0.9)"
,
...
...
Please
register
or
sign in
to post a comment