We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

HtmlToPdf AspectRatio issue

hi everyone,

i'm quite new about syncfusion pdf, but i manage to do almost the thinks i needed..

i need to get a pdf from url.

the page i have to render is a page with a table with attribute 100% width (to avoid scrollbars)

the problem i found is to resize the pdf to fit the page to the pdf page.

i saw that part of code :


#############################################################

SizeF pageSize = page.GetClientSize();

PdfUnitConvertor convertor = new PdfUnitConvertor();
float width = -1;
float height = -1;

// Calculates the height and width of the pdf image
if (dimension == AspectRatio.KeepHeight)
{
height = convertor.ConvertToPixels(pageSize.Height, PdfGraphicsUnit.Point);
}
else if (dimension == AspectRatio.KeepWidth)
{
width = convertor.ConvertToPixels(pageSize.Width, PdfGraphicsUnit.Point);
}

...

HtmlToPdfResult result = html.Convert(url, ImageType.Metafile, (int)width, (int)height, dimension);



#############################################################

if i use fit dimension = AspectRatio.FitPageSize;

the page seems to "shrink" only the right part of the table (like you can see in the attachemenet)

any idea to solve that behaviour ?

thanks :)




AspectRatio.KeepWidth.pdf_bd8c76b3.zip

1 Reply

GM Geetha M Syncfusion Team August 24, 2011 09:50 AM UTC

Hi,

Thank you for your interest in Syncfusion products.

In order the complete HTML page in PDF, please make use of AspectRatio.KeepWidth. This will maintain the width of the content to fit the PDF page and then paginates if the height exceeds PDF page height.

Please let me know if you have any questions.

Regards,
Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon