Skip to content

Commit aec8db1

Browse files
committed
Merge pull request #727 from renuo/master
Fix #725: Acroform elements always on last page
2 parents f895888 + 62d647a commit aec8db1

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

jspdf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ var jsPDF = (function (global) {
260260
out('endstream');
261261
},
262262
putPages = function () {
263-
var n, p, arr, i, deflater, adler32, adler32cs, wPt, hPt;
263+
var n, p, arr, i, deflater, adler32, adler32cs, wPt, hPt, pageObjectNumbers = [];
264264

265265
adler32cs = global.adler32cs || jsPDF.adler32cs;
266266
if (compress && typeof adler32cs === 'undefined') {
@@ -270,7 +270,7 @@ var jsPDF = (function (global) {
270270
// outToPages = false as set in endDocument(). out() writes to content.
271271

272272
for (n = 1; n <= page; n++) {
273-
newObject();
273+
pageObjectNumbers.push(newObject());
274274
wPt = (pageWidth = pagedim[n].width) * k;
275275
hPt = (pageHeight = pagedim[n].height) * k;
276276
out('<</Type /Page');
@@ -313,7 +313,7 @@ var jsPDF = (function (global) {
313313
out('<</Type /Pages');
314314
var kids = '/Kids [';
315315
for (i = 0; i < page; i++) {
316-
kids += (3 + 2 * i) + ' 0 R ';
316+
kids += pageObjectNumbers[i] + ' 0 R ';
317317
}
318318
out(kids + ']');
319319
out('/Count ' + page);

plugins/acroform.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
type: 'reference',
8181
object: object
8282
};
83-
jsPDF.API.annotationPlugin.annotations[this.internal.getCurrentPageInfo().pageNumber].push(options);
83+
jsPDF.API.annotationPlugin.annotations[this.internal.getPageInfo(object.page).pageNumber].push(options);
8484
};
8585

8686
var putForm = function (formObject) {
@@ -245,6 +245,7 @@
245245
// try to put..
246246
putForm.call(this, fieldObject);
247247
}
248+
fieldObject.page = this.acroformPlugin.internal.getCurrentPageInfo().pageNumber;
248249
return this;
249250
};
250251

@@ -1050,6 +1051,12 @@ AcroForm.Field = function () {
10501051
configurable: true,
10511052
writable: true
10521053
});
1054+
1055+
Object.defineProperty(this, 'page', {
1056+
enumerable: false,
1057+
configurable: true,
1058+
writable: true
1059+
});
10531060
};
10541061
AcroForm.Field.FieldNum = 0;
10551062

0 commit comments

Comments
 (0)