Welcome Guest Search | Active Topics | Sign In | Register

[RESOLVED] Adding image over existing PDF, changes rotation Options
stephan
Posted: Friday, February 2, 2018 7:44:37 AM
Rank: Newbie
Groups: Member

Joined: 2/26/2013
Posts: 5
Hi,

I'm trying to add a (full screen) overlay over existing PDF files.

I have changed several options, using convertHTML and PdfImageContent, and tried all kinds of output- and page settings, but the image is always added in the lower right of the PDF and looks like it rotated automatically.


Code: C#
HtmlToPdfOptions options = new HtmlToPdfOptions();
options.PageSize = PdfPageSizes.A4;

foreach (var page in pdfDoc.Pages)
    HtmlToPdf.ConvertHtml("<img src='" + watermarkImageUrl + "' />", page, options);


Brought it down to barebone and it does exactly the same.
The image is exactly the size of A4.

What am i doing wrong? How would i continue ?

Thanks.
eo_support
Posted: Friday, February 2, 2018 2:48:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

What version do you use? It appears that the original PDF file you use has been rotated. You can send us both the PDF file and the image file and we will be happy to take a look. See here for more details on how to send test files to us:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!
stephan
Posted: Tuesday, February 6, 2018 4:04:18 AM
Rank: Newbie
Groups: Member

Joined: 2/26/2013
Posts: 5
2018 version fixes this.

Thanks
eo_support
Posted: Tuesday, February 6, 2018 6:43:26 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Great. Thanks for confirming the fix!
stephan
Posted: Tuesday, February 6, 2018 6:46:19 AM
Rank: Newbie
Groups: Member

Joined: 2/26/2013
Posts: 5
One minor change in the code though.

it seems that pdf.Pages is yielding the result (?).
Making changes to page causes the collection to change, thus throwing an error.

This can be fixed by casting it to a list.

Code: C#
foreach (var page in pdfDoc.Pages.ToList())
// etc 

eo_support
Posted: Tuesday, February 6, 2018 7:16:09 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Yes. If you modify the page collection you will get an exception. Thanks for sharing your solution.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.