Xportability / css-to-pdf

Convert any HTML page or region to PDF - supports CSS, SVG, embedded XML objects, and more..
http://www.cloudformatter.com/CSS2Pdf
207 stars 77 forks source link

Margin and alignment issue #34

Closed prashant-sehta closed 8 years ago

prashant-sehta commented 8 years ago

Hi,

My html looks fine in the browser with proper page margins and aligned tables. However once it's converted to pdf, the page alignment doesn't look proper. The right margin of the page is greater than left margin.

Also, the table alignment is also affected. Please check out the sample fiddle:

http://jsfiddle.net/t1gocqkj/5/

Could you please have a look and explain why it is happening?

kbrown01 commented 8 years ago

You need to understand that the code is not formatting "your web page" as you are thinking. It is taking the contents of your specified "div" or "div"s and flowing them into a page that you can specify in calling the application. When you call the code, you can specify left/right/top/bottom margins and page size. You can look here for default values ... http://www.cloudformatter.com/CSS2Pdf.APIDoc.Usage

So do not think of it as formatting your HTML page, it is pouring the content of the "div" into a page size with margins that you specify.