Pdftk fails to update_info the data that was produced by dump_data_annots

143 views Asked by At

I am looking to save all annotations in a pdf to a file then import them back to a pdf.

pdftk input.pdf dump_data_annots output annots.txt

Outputs all the annotations in the following format:

NumberOfPages: 3
---
AnnotSubtype: Widget
AnnotRect: 87.8555 702.461 282.5 711.825
AnnotPageNumber: 1
---
AnnotSubtype: Widget
AnnotRect: 62.9136 721.323 282.5 730.687
AnnotPageNumber: 1
---

When I try to import the annotations back to the PDF using

pdftk input.pdf update_info annots.txt output out.pdf

I get warnings and none of the annotations are imported

pdftk Warning: unexpected case 1 in LoadDataFile(); continuing
pdftk Warning: unexpected case 1 in LoadDataFile(); continuing

The annots.txt is not modified in any way.

I expected out.pdf to have the annotations, but it has no annotations.

2

There are 2 answers

0
notautogenerated On

There is a lot more information that would be needed to reconstruct the annotations besides what dump_data_annots prints, so this won't work. In principle an operation to copy annotations from one PDF to another could be implemented, and it should not bee too hard looking at e.g. How can I copy annotations/highlighting from one PDF to an updated version of that PDF?, but nobody has done it so far.

0
TomBen On

I’ve tried pdftk, but it failed to transfer the PDF annotations. Later I found Adobe Acrobat was able to make it. You can have a try by following this guide.