Skip to content

Commit 09b73f8

Browse files
committed
Merge pull request #418 from Flamenco/master
Color support, page context, c2d updates
2 parents 403bb61 + bf10cf5 commit 09b73f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+11213
-637
lines changed

doc/plugins/from_html.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!--
2+
/**
3+
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) [email protected]
4+
*
5+
* Licensed under the MIT License.
6+
* http://opensource.org/licenses/mit-license
7+
*/
8+
-->
9+
10+
# from_html Plugin CSS Support
11+
This document lists the CSS styles supported by the from_html jsPDF plugin.
12+
Each style indicates restrictions and issues.
13+
This file is intended for development purposes and may not be up to date.
14+
Refer to the source code for the lastest developments.
15+
16+
# Implemented
17+
18+
* margin
19+
* margin-top
20+
* margin-right
21+
* margin-left
22+
* margin-bottom
23+
* padding
24+
* padding-top
25+
* padding-right
26+
* padding-left
27+
* padding-bottom
28+
* font-family
29+
* font-style
30+
* text-align
31+
* font-size
32+
* line-height
33+
* display
34+
* float
35+
* clear
36+
* page-break-before
37+
> Only _always_ is implemented.
38+
39+
# Implemented But Not Merged
40+
* color
41+
42+
# Not Implemented
43+
* page-break-after
File renamed without changes.

test/test_annotation.html renamed to examples/annotation/test_annotation.html

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,15 @@
1313
<head>
1414
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
1515

16-
<title>Annotaion Test</title>
16+
<title>Annotation Test</title>
1717

18-
<script type="text/javascript" src="../jspdf.js"></script>
19-
<!-- required by the plugin to test -->
20-
<script type="text/javascript" src="../jspdf.plugin.standard_fonts_metrics.js"></script>
21-
<script type="text/javascript" src="../jspdf.plugin.split_text_to_size.js"></script>
22-
<!-- the plugin to test -->
23-
<script type="text/javascript" src="../jspdf.plugin.annotations.js"></script>
18+
<script src='../../libs/require/require.js'></script>
2419

2520
<script>
26-
window.onload = function() {
27-
28-
21+
require_baseUrl_override = '../../';
22+
require(['../../libs/require/config'], function(){
23+
require(['jspdf.plugin.annotations', 'examples/js/test_harness'], function(){
24+
2925
var pdf = new jsPDF('p', 'pt', 'letter');
3026

3127
// Create pages with a table of contents.
@@ -72,58 +68,24 @@
7268

7369
text = "Goto External URL";
7470
pdf.textWithLink(text, 20, y, {url:'http://www.twelvetone.tv'});
75-
y += pdf.getLineHeight();
76-
}
77-
78-
// generate either the pdf or source code
79-
if (getParameterByName('src') != 'true'){
80-
var frame = document.getElementById('pdfframe');
81-
frame.src = pdf.output('datauristring');
71+
y += pdf.getLineHeight();
8272
}
83-
else{
84-
var content = document.getElementById('sourcecode');
85-
var raw = pdf.output();
86-
raw = escapeHtml(raw);
87-
content.innerHTML = raw;
88-
}
89-
90-
}
91-
92-
var entityMap = {
93-
"&": "&amp;",
94-
"<": "&lt;",
95-
">": "&gt;",
96-
'"': '&quot;',
97-
"'": '&#39;',
98-
"/": '&#x2F;'
99-
};
100-
101-
function escapeHtml(string) {
102-
return String(string).replace(/[&<>"'\/]/g, function (s) {
103-
return entityMap[s];
104-
});
105-
}
106-
107-
function getParameterByName(name) {
108-
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
109-
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
110-
results = regex.exec(location.search);
111-
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
112-
}
73+
74+
var message = 'Chrome default PDF reader currently does not support magFactor links, \
75+
although links still work after manualy changing magFactor. <br /> \
76+
Firefox has a bug displaying annotations after the magFactor changes, but links do work. <br /> \
77+
To test magFactor links [...] without bugs, use Adobe Reader or compatible application.';
78+
79+
pdf_test_harness_init(pdf, message);
80+
81+
}); // require
82+
}); // require
11383

11484
</script>
11585

11686
</head>
11787

11888
<body style='background-color: silver; margin: 0;'>
119-
<p>
120-
Chrome default PDF reader currently does not support magFactor links, although links still work after manualy changing magFactor.
121-
<br />
122-
Firefox has a bug displaying annotations after the magFactor changes, but links do work.
123-
<br />
124-
To test magFactor links [...] without bugs, use Adobe Reader or compatible application.
125-
</p>
126-
<pre id='sourcecode'></pre>
127-
<iframe id='pdfframe' style='width: 100%; height: 100%; position: absolute'></iframe>
89+
12890
</body>
12991
</html>
File renamed without changes.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<!doctype html>
2+
<!--
3+
/**
4+
* jsPDF Annotations PlugIn
5+
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) [email protected]
6+
*
7+
* Licensed under the MIT License.
8+
* http://opensource.org/licenses/mit-license
9+
*/
10+
-->
11+
12+
<html>
13+
<head>
14+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
15+
16+
<title>Annotation Test - Text</title>
17+
<script src='../../libs/require/require.js'></script>
18+
19+
<script>
20+
require_baseUrl_override = '../../';
21+
require(['../../libs/require/config'], function(){
22+
require(['jspdf.plugin.annotations', 'examples/js/test_harness'], function(){
23+
24+
var pdf = new jsPDF('p', 'pt', 'letter');
25+
var y = 20;
26+
var w;
27+
var text = 'Text Annotations';
28+
pdf.text(text, 20, y);
29+
30+
pdf.setFontSize(12);
31+
32+
y += pdf.getLineHeight() * 2;
33+
pdf.text("Text Annotation With Popup (closed)", 20, y);
34+
pdf.createAnnotation({
35+
type : 'text',
36+
title: 'note',
37+
bounds : {
38+
x : 0,
39+
y : y,
40+
w : 200,
41+
h : 80
42+
},
43+
contents : 'This is text annotation (closed by default)',
44+
open : false
45+
});
46+
47+
y += pdf.getLineHeight() * 5;
48+
pdf.text("Text Annotation With Popup (opened)", 20, y);
49+
pdf.createAnnotation({
50+
type : 'text',
51+
title: 'another note',
52+
bounds : {
53+
x : 0,
54+
y : y,
55+
w : 200,
56+
h : 80
57+
},
58+
contents : 'This is a text annotation (opened)',
59+
open : true
60+
});
61+
62+
y += pdf.getLineHeight() * 5;
63+
pdf.text("Free Text Annotation", 20, y);
64+
pdf.createAnnotation({
65+
type : 'freetext',
66+
bounds : {
67+
x : 0,
68+
y : y + 10,
69+
w : 200,
70+
h : 20
71+
},
72+
contents : 'This is a freetext annotation',
73+
color : '#ff0000'
74+
});
75+
76+
var warning = 'Most web browsers do not display annotations. Download the PDF and open in Adobe Reader, etc).'
77+
pdf_test_harness_init(pdf, warning);
78+
79+
}); // require
80+
}); // require
81+
</script>
82+
83+
</head>
84+
85+
<body style='background-color: silver; margin: 0;'>
86+
87+
</body>
88+
</html>

0 commit comments

Comments
 (0)