vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
719 stars 178 forks source link

Information about the pdf orientation gets lost, impossible to sign a pdf in "landscape" mode #108

Closed fleetster closed 3 years ago

fleetster commented 3 years ago

Describe the bug and the expected behaviour the page orientation is missing when signing the document. The pages are always in "portrait" mode, even when creating the pdf in "landscape" mode

Is it a bug in signing or in the helpers? It could be introduced by plainAddPlaceholder

To Reproduce Hi,
I am generating a pdf from HTML using the library html-pdf. When creating the document, I pass the option orientation:'landscape' that rotates the orientation of the page. If I open the pdf generated by this library, everything looks like it should be.
I have recently had the necessity to sign the document, so we started using your library.

  1. First we read the pdf previously generated:

const pdfBuffer = await fs.readFile(path.join(fileDir, fileName));

  1. Then we add the placeholder:

const pdfBufferWithPlaceholder = plainAddPlaceholder({pdfBuffer, reason: 'reason'});

  1. And in the end we sign the document:

const signedPdfBuffer = Signer.sign(pdfBufferWithPlaceholder, p12Cert, {passphrase});

  1. The resulting pdf is properly signed but the orientation of the document is "portrait" and not "landscape". It looks like the information of the orientation got lost in the signing process, or when adding the placeholder.

Thanks in advance for the support!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had activity in the past 90 days. It will be closed if no further activity occurs. Thank you for your contributions.

cassiobt commented 2 years ago

I was using https://github.com/marcbachmann/node-html-pdf to generate the PDF. So I change tohttps://github.com/mrafiqk/html-pdf-node and now it works like a charm

vbuch commented 2 years ago

@fleetster while I trust you that this is reproducible, "I am generating a pdf from HTML using the library html-pdf." is not something I can easily reproduce. Could you add a file as generated by that library so that I can possibly test what and where gets broken?