mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Don't save anything in XFA entry if no XFA! (bug 1732344)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1732344 - rename some variables to have a more clear code; - and last but no least, add a unit test to test saving.
This commit is contained in:
parent
c914e9f0a6
commit
4b0538d07a
5 changed files with 60 additions and 32 deletions
|
@ -1283,6 +1283,28 @@ describe("api", function () {
|
|||
await Promise.all([loadingTask1.destroy(), loadingTask2.destroy()]);
|
||||
});
|
||||
|
||||
it("write a value in an annotation, save the pdf and load it", async function () {
|
||||
let loadingTask = getDocument(buildGetDocumentParams("evaljs.pdf"));
|
||||
let pdfDoc = await loadingTask.promise;
|
||||
const value = "Hello World";
|
||||
|
||||
pdfDoc.annotationStorage.setValue("55R", { value });
|
||||
|
||||
const data = await pdfDoc.saveDocument();
|
||||
await loadingTask.destroy();
|
||||
|
||||
loadingTask = getDocument(data);
|
||||
pdfDoc = await loadingTask.promise;
|
||||
const pdfPage = await pdfDoc.getPage(1);
|
||||
const annotations = await pdfPage.getAnnotations();
|
||||
|
||||
const field = annotations.find(annotation => annotation.id === "55R");
|
||||
expect(!!field).toEqual(true);
|
||||
expect(field.fieldValue).toEqual(value);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
describe("Cross-origin", function () {
|
||||
let loadingTask;
|
||||
function _checkCanLoad(expectSuccess, filename, options) {
|
||||
|
|
|
@ -162,7 +162,7 @@ describe("Writer", function () {
|
|||
Ref.get(456, 0),
|
||||
]);
|
||||
const acroFormRef = Ref.get(789, 0);
|
||||
const datasetsRef = Ref.get(101112, 0);
|
||||
const xfaDatasetsRef = Ref.get(101112, 0);
|
||||
const xfaData = "<hello>world</hello>";
|
||||
|
||||
const xrefInfo = {
|
||||
|
@ -180,8 +180,9 @@ describe("Writer", function () {
|
|||
originalData,
|
||||
xrefInfo,
|
||||
newRefs,
|
||||
datasetsRef,
|
||||
hasDatasets: false,
|
||||
hasXfa: true,
|
||||
xfaDatasetsRef,
|
||||
hasXfaDatasetsEntry: false,
|
||||
acroFormRef,
|
||||
acroForm,
|
||||
xfaData,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue