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

Issue with HTML Page Height

My page is getting cut off... I'm only getting the top part of the page in HTMLtoPDF instead of the 3 pages i'd expect to see.

This is what my code looks like:

PdfDocument doc = new PdfDocument();

//Set page margins
doc.PageSettings.SetMargins(30);

//Set page orientation
doc.PageSettings.Orientation = PdfPageOrientation.Portrait;

//Add a page
PdfPage page = doc.Pages.Add();

// Footer.
// Create a Template that can be used as a footer.
//Create a page template
RectangleF rect = new RectangleF(0, 0, doc.Pages[0].GetClientSize().Width, 50);
PdfPageTemplateElement footer = new PdfPageTemplateElement(rect);

//Creates a solid brush.
PdfBrush brush = new PdfSolidBrush(Color.Silver);
//Sets the font.

PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);

//Add the fields in composite fields
PdfCompositeField compositeField = new PdfCompositeField(font, brush, IKS.ConfigOptions.Config.Label.Get("LABEL_REPORT_GENERATED") + ": " + DateTime.Now.ToString());
compositeField.Bounds = footer.Bounds;

//Draw the composite field in footer
compositeField.Draw(footer.Graphics, new PointF(20, 20));
//Add the footer template at the bottom
//doc.Template.Bottom = footer;


SizeF pageSize = page.GetClientSize();

PdfUnitConvertor convertor = new PdfUnitConvertor();
float width = convertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point);
float height = convertor.ConvertToPixels(page.GetClientSize().Height, PdfGraphicsUnit.Point);

using (HtmlConverter html = new HtmlConverter())
{
// setting Javascript
html.EnableJavaScript = false;
// Setting Pagebreak
html.AutoDetectPageBreak = false;
// set hyperlink
html.EnableHyperlinks = false;

//Metafile
HtmlToPdfResult result;
if (ConfigurationManager.AppSettings.Get("REPORT_REQUIRES_SECURE_CONNECTION") == "1")
{
result = html.Convert(ConfigurationManager.AppSettings.Get("REPORT_EXECUTIVE_SUMMARY_PATH") + "?period=" + month + "&year=" + year + "&cat=" + category.Id, ImageType.Metafile, (int)width, -1, AspectRatio.KeepWidth, ConfigurationManager.AppSettings.Get("SECURE_CONNECTION_USERNAME"), ConfigurationManager.AppSettings.Get("SECURE_CONNECTION_PASSWORD"));
}

else
{
result = html.Convert(ConfigurationManager.AppSettings.Get("REPORT_EXECUTIVE_SUMMARY_PATH") + "?period=" + month + "&year=" + year + "&cat=" + category.Id, ImageType.Metafile, (int)width, -1, AspectRatio.KeepWidth);
}

if (result != null)
{
PdfMetafile mf = new PdfMetafile(result.RenderedImage as Metafile);
mf.Quality = 100;

PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Break = PdfLayoutBreakType.FitPage;
format.Layout = PdfLayoutType.Paginate;

format.SplitTextLines = true;
format.SplitImages = false;

result.Render(page, format);
}
else
Response.Write("Warning ! Please check the HTML link");
}

return doc;

This is an ASPX page, not an HTML page. All controls are in an unstyled div. Thanks.

3 Replies

AG Angappan G Syncfusion Team June 22, 2010 02:45 PM UTC

Hi Matt,

Thank you for your interest in Essential Studio.

We are unable to reproduce the issue on our side, could you please send us the sample and the template document, this will help us a lot in further investigating this issue.

Please let us know if you have any queries.

Regards,
Angappan.


MD Matt Dixon June 23, 2010 01:42 PM UTC

Due to the nature of our product, it would be difficult to post the nessecary code on this forum. Would it be possible to set up a webcast where I could share my code with you?


AG Angappan G Syncfusion Team June 24, 2010 11:10 AM UTC

Hi Matt,

Could you please report these issues through Direct Trac Developer Support Systemhttps://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time and we hope you will take advantage of this system as well.In this mode your code will be kept as confidential.

Please let us know if you have any other questions.

Regards,
Angappan.

Loader.
Live Chat Icon For mobile
Up arrow icon