Search code examples
evopdf

EvoPdf Page backgrounds and Margins


I am converting HTML pages using EvoPdf and would like to add a background image. I am generating documents and would like to add a cover page, I am doing this by prepending the HTML for the cover page then putting a page break directly after.

I am using this demo as a guide http://www.evopdf.com/demo/HTML_to_PDF/PDF_Pages_Background/Add_Elements_in_Background.aspx and have found that I need to remove the page margins for the image to cover the whole page otherwise it sits inside the margins. If I remove the margins this means the content that flows over pages now starts directly at the top of the page and flows right to the bottom. I can fix this for left and right margins by putting this in the HTML but this does not work for top and bottom margins that flow over pages. (see the generated PDF from the above demo)

Is there a way to set the PDF page background irrespective of the page margins? I have been looking at creating multiple documents with their own configuration and merging the PDF's but I really want to avoid this.


Solution

  • You can set up a header and footer with the heights you wanted for the top and bottom margins, and then choose to not display them on the first page. This should give you the effect you're looking for.

    You can find more information about how to do this here: http://www.evopdf.com/demo/HTML_to_PDF/Headers_and_Footers/HTML_in_Header_Footer.aspx