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.
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.