mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Use the position of the previous xref stream if any when saving a pdf (bug 1823296)
This commit is contained in:
parent
3903391f3c
commit
2d0f30a67c
6 changed files with 62 additions and 1 deletions
2
test/pdfs/bug1823296.pdf.link
Normal file
2
test/pdfs/bug1823296.pdf.link
Normal file
|
@ -0,0 +1,2 @@
|
|||
https://bugzilla.mozilla.org/attachment.cgi?id=9324226
|
||||
|
|
@ -7496,5 +7496,12 @@
|
|||
"md5": "d95a83a868671a03cbf322f16b2e2b9d",
|
||||
"link": true,
|
||||
"type": "other"
|
||||
},
|
||||
{
|
||||
"id": "bug1823296",
|
||||
"file": "pdfs/bug1823296.pdf",
|
||||
"md5": "f71e89ebe3d6e75e0c83ce41cd72df1f",
|
||||
"link": true,
|
||||
"type": "other"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
AnnotationEditorType,
|
||||
AnnotationMode,
|
||||
AnnotationType,
|
||||
createPromiseCapability,
|
||||
|
@ -1980,6 +1981,35 @@ describe("api", function () {
|
|||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("write a a new annotation, save the pdf and check that the prev entry in xref stream is correct", async function () {
|
||||
if (isNodeJS) {
|
||||
pending("Linked test-cases are not supported in Node.js.");
|
||||
}
|
||||
|
||||
let loadingTask = getDocument(buildGetDocumentParams("bug1823296.pdf"));
|
||||
let pdfDoc = await loadingTask.promise;
|
||||
pdfDoc.annotationStorage.setValue("pdfjs_internal_editor_0", {
|
||||
annotationType: AnnotationEditorType.FREETEXT,
|
||||
rect: [12, 34, 56, 78],
|
||||
rotation: 0,
|
||||
fontSize: 10,
|
||||
color: [0, 0, 0],
|
||||
value: "Hello PDF.js World!",
|
||||
pageIndex: 0,
|
||||
});
|
||||
|
||||
const data = await pdfDoc.saveDocument();
|
||||
await loadingTask.destroy();
|
||||
|
||||
loadingTask = getDocument(data);
|
||||
pdfDoc = await loadingTask.promise;
|
||||
const xrefPrev = await pdfDoc.getXRefPrevValue();
|
||||
|
||||
expect(xrefPrev).toEqual(143954);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
describe("Cross-origin", function () {
|
||||
let loadingTask;
|
||||
function _checkCanLoad(expectSuccess, filename, options) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue