mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +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
|
@ -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