We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML tables (sized in pixles) converted to pdf



We have a client asking about converting HTML tables (sized in pixles) to pdf. Can you please help us with the questions regarding the conversion?


"If we were to setup a HTML table with CSS styles inline for widths using pixels as a unit of measure would the output render ok? If so do you know how it converts pixels into a unit of measure for printing>? I’m assuming via page size/paper size maybe?"


Hi John,


Thanks for contacting support.

The basic unit of measurement in Aspose.Pdf for .NET is Point where 1 inch = 72 points and 1 cm = 1/2.54 inch = 0.3937 inch = 28.3 points. Now as you are using pixel for page measurement, you my consider using following formula. Please note that pdfx is x coordinate inside PDF file and pixelX is X coordinates over screen.

  • pixelX = (pdfX/72)* DPI
  • pdfX = pixelX * 72 / DPI

Where DPI is screen resolution and usually its 96 and can be calculated programmatically.

[C#]

float dpiX, dpiY;<o:p></o:p>

Graphics graphics = this.CreateGraphics();<o:p></o:p>

dpiX = graphics.DpiX;<o:p></o:p>

dpiY = graphics.DpiY;<o:p></o:p>

Console.WriteLine("DPIx = " + dpiX + " DPIy " + dpiY);<o:p></o:p>