galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Extracting page from PDF does not copy original annotations #307

Closed ghost closed 5 years ago

ghost commented 5 years ago

I'm trying to extract one page from a PDF by doing:

const pdfWriter = hummus.createWriter(extractedPdfPath);
pdfWriter.appendPDFPagesFromPDF(sourcePdfPath, {
    type: hummus.eRangeTypeSpecific,
    specificRanges: [[pageIndex, pageIndex]],
});
pdfWriter.end();

It works pretty well except for the annotations which are not copied from the original to the new generated PDF.

Here is an example of PDF with annotations that does not work: A5.pdf

galkahana commented 5 years ago

copies only graphics natively. here's how to also copy annotations: https://github.com/galkahana/HummusJSSamples/tree/master/appending-pages-with-comments

ghost commented 5 years ago

That is awesome, thanks!