Skip to content

Commit eafb2e4

Browse files
committed
Merge pull request #404 from Flamenco/c2d
HTML5 CanvasRenderingContext2D interface
2 parents a7fb4ae + 74aaebc commit eafb2e4

File tree

5 files changed

+1048
-7
lines changed

5 files changed

+1048
-7
lines changed

jspdf.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ var jsPDF = (function(global) {
199199
},
200200
API = {},
201201
events = new PubSub(API),
202+
lastTextWasStroke = false,
202203

203204
/////////////////////
204205
// Private functions
@@ -963,7 +964,17 @@ var jsPDF = (function(global) {
963964
'getNumberOfPages' : function() {
964965
return pages.length - 1;
965966
},
966-
'pages' : pages
967+
'pages' : pages,
968+
'out' : out,
969+
'f2' : f2,
970+
'getPageInfo' : function(pageNumberOneBased){
971+
var objId = (pageNumberOneBased - 1) * 2 + 3;
972+
return {objId:objId, pageNumber:pageNumberOneBased};
973+
},
974+
'getCurrentPageInfo' : function(){
975+
var objId = (currentPage - 1) * 2 + 3;
976+
return {objId:objId, pageNumber:currentPage};
977+
}
967978
};
968979

969980
/**
@@ -1055,7 +1066,23 @@ var jsPDF = (function(global) {
10551066
flags.noBOM = true;
10561067
if (!('autoencode' in flags))
10571068
flags.autoencode = true;
1058-
1069+
1070+
//TODO this might not work after object block changes
1071+
// It would be better to pass in a page context
1072+
var strokeOption = '';
1073+
if (true === flags.stroke){
1074+
if (this.lastTextWasStroke !== true){
1075+
strokeOption = '1 Tr\n';
1076+
this.lastTextWasStroke = true;
1077+
}
1078+
}
1079+
else{
1080+
if (this.lastTextWasStroke){
1081+
strokeOption = '0 Tr\n';
1082+
}
1083+
this.lastTextWasStroke = false;
1084+
}
1085+
10591086
if (typeof text === 'string') {
10601087
text = ESC(text);
10611088
} else if (text instanceof Array) {
@@ -1085,6 +1112,7 @@ var jsPDF = (function(global) {
10851112
'BT\n/' +
10861113
activeFontKey + ' ' + activeFontSize + ' Tf\n' + // font face, style, size
10871114
(activeFontSize * lineHeightProportion) + ' TL\n' + // line spacing
1115+
strokeOption +// stroke option
10881116
textColor +
10891117
'\n' + xtra + f2(x * k) + ' ' + f2((pageHeight - y) * k) + ' ' + mode + '\n(' +
10901118
text +

jspdf.plugin.annotations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
line = '<</Type /Annot /Subtype /Link ' + rect + '/Border [0 0 0] /A <</S /URI /URI (' + anno.options.url + ') >>';
110110
} else if (anno.options.pageNumber) {
111111
// first page is 0
112-
var pageObjId = anno.options.pageNumber * 2 + 1;
113-
line = '<</Type /Annot /Subtype /Link ' + rect + '/Border [0 0 0] /Dest [' + pageObjId + " 0 R";
112+
var info = this.internal.getPageInfo(anno.options.pageNumber);
113+
line = '<</Type /Annot /Subtype /Link ' + rect + '/Border [0 0 0] /Dest [' + info.objId + " 0 R";
114114
anno.options.magFactor = anno.options.magFactor || "XYZ";
115115
switch (anno.options.magFactor) {
116116
case 'Fit':
@@ -153,7 +153,7 @@
153153
*/
154154
jsPDFAPI.link = function(x,y,w,h,options) {
155155
'use strict';
156-
this.annotationPlugin.annotations[this.internal.getNumberOfPages()].push({
156+
this.annotationPlugin.annotations[this.internal.getCurrentPageInfo().pageNumber].push({
157157
x : x,
158158
y : y,
159159
w : w,

0 commit comments

Comments
 (0)