-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewer.html
More file actions
152 lines (102 loc) · 3.06 KB
/
viewer.html
File metadata and controls
152 lines (102 loc) · 3.06 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Embedding a PDF using PDFObject: Conditional JavaScript invoked upon successful embed</title>
<!-- This example created for PDFObject.com by Philip Hutchison (www.pipwerks.com) -->
<!-- CSS for basic page styling, not related to example -->
<style type="text/css">
<!--
#pdf {
}
#pdf.embedded {
width: 500px;
height: 300px;
margin: 2em auto;
border: 10px solid #6699FF;
}
#pdf p {
padding: 1em;
}
#pdf object {
display: block;
border: solid 1px #666;
}
#statement {
padding: 1em;
margin: 1em;
border: solid 4px #FFF;
font-size: medium;
font-weight: bold;
}
.success {
background: #00CC33;
color: #FFFFFF;
}
.fail {
background: #FF3366;
color: #FFFFFF;
}
-->
</style>
<script type="text/javascript" src="pdfobject.js"></script>
<script type="text/javascript">
/*
PDFObject returns a reference to the JavaScript object (pseudo 'class' instance).
PDFObject.embed() returns a reference to the embedded HTML <object>.
Knowing this, we store the references in two separate variables and perform
actions with them. For this example, We'll store the PDFObject obj in 'pObj'
and the HTML object in htmlObj.
http://www.pdf995.com/samples/pdf.pdf
*/
var pObj = new PDFObject({
url: "http://localhost:3000/exportpdf.pdf",
id: "myPDF",
pdfOpenParams: {
navpanes: 0,
toolbar: 0,
statusbar: 0,
view: "FitV"
}
});
//Note: the PDF has NOT been embedded yet because .embed() has not been invoked.
function embed(){
var s = document.getElementById("statement");
var msg;
document.getElementById("pdf").className = "embedded"; //Style the DIV
var htmlObj = pObj.embed("pdf"); //Returns a reference to the HTML <object> or null if unsuccessful
if(htmlObj){
msg = "The PDF was successfully embedded!";
s.className = "success";
} else {
msg = "It appears the embed didn't work.";
s.className = "fail";
}
s.innerHTML = msg;
}
window.onload = function (){
var s = document.getElementById("statement");
var msg;
if(pObj){
var plugintype = pObj.get("pluginTypeFound");
msg = "Type of PDF plugin found: " +plugintype;
if(plugintype){
msg += "<br/><a href='#' onclick='embed(); return false;'>Click here to embed the PDF!</a>";
} else {
msg += "<br/>Looks like we won't be able to embed your PDF! Doh!";
s.className = "fail";
}
}
s.innerHTML = msg;
};
</script>
</head>
<body>
<h1>Embedding a PDF using PDFObject:<br />
Conditional JavaScript invoked upon successful embed<br />
(Advanced example)</h1>
<p id="statement">This example uses a few lines of JavaScript wrapped in a <em>window.onload</em> statement, with a little CSS added to control the styling of the embedded element.</p>
<div id="pdf"></div>
<p><a href="/index.php">« Return to PDFObject home</a></p>
</body>
</html>