julianhille / MuhammaraJS

Muhammara a node module with c/cpp bindings to modify PDF with js for node or electron (based/replacement on/of galkhana/hummusjs)
Other
208 stars 44 forks source link

Unable to modify PDF file, make sure that output file target is available and that it is not protected #389

Open LudvikWiejowski opened 4 weeks ago

LudvikWiejowski commented 4 weeks ago

Hi,

I use pdfWriter = muhammara.createWriterToModify(localPdfPath,{modifiedFilePath:destPdfPath}); to create my pdfWriter so I can read and add an annotations. It worked perfectly until now, when I encountered protected pdf file with not allowed page extraction. PDF File is then locked and I need to restart my node.js api service. pdfWriter is not initialized so can't use .end(). (Maybe it's some small bug in createWriterToModify routine.)

Please, is there any way how to make it work, is there any quick way? Or is it possible to read all pages and recreated the pdf file without protection? Any hint or example is very much welcome.

I can send the pdf file as well, but I do not want to upload it publicly, as it is an invoice of my client's supplier.

Thanks Ludvik

image

EDIT: I tried pdf online validator tool pdf-online.com and got following output for problem PDF file.

File: 20240708114004_cma-cgm_com_1cb81728ba320cf8e0630a00ba4f89e0.pdf

Compliance: pdf1.4

Result: Document does not conform to PDF/A.

Details: Validating file "20240708114004_cma-cgm_com_1cb81728ba320cf8e0630a00ba4f89e0.pdf" for conformance level pdf1.4 The 'xref' keyword was not found or the xref table is malformed. The file trailer dictionary is missing or invalid. The "Length" key of the stream object is wrong. The "Length" key of the stream object is wrong. The document does not conform to the requested standard. The file format (header, trailer, objects, xref, streams) is corrupted. The document does not conform to the PDF 1.4 standard.Done.

It looks like this will be the cause of the issues. Will be glad for confirmation anyway. :)