Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watermark Stream with negative height #416

Open
es-tomas opened this issue Dec 20, 2023 · 0 comments
Open

Watermark Stream with negative height #416

es-tomas opened this issue Dec 20, 2023 · 0 comments

Comments

@es-tomas
Copy link

es-tomas commented Dec 20, 2023

Hi,
I'm working on a watermarking of a document and I've got a stream as an input. I try to open it doing the following:

PdfDocument document = PdfReader.Open(stream, PdfDocumentOpenMode.Modify);

My pdf document is returned but with two problems: Orientation is incorrect (it's set to Portrait when it's actually Landscape) and the Height is a negative value.

This is fine if I just return the document to the user as the PDF is readable. The problem is when I try to create the XGraphics as I'm doing it as follows:

XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append);

This method doesn't accept negative values for the dimensions and therefore throws an exception. If I do Abs on the Height value, then it allows me to do the watermarking but the original pdf content doesn't show up anymore and I can only see the watermark.

Can somebody help with this issue?

Adding up some details about this particular pdf:

image

@es-tomas es-tomas changed the title Stream has negative height Watermark Stream with negative height Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant