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

HTML to PDF - defected corners

Hi,

I am using HtmlConverter to create PDF from my own web page. It looks good except that the left-bottom corner of every box border has the same defect. The line being drawn to the corner is a bit over-extended and drew over the tip of the box. It happens to the Metafile option only. PDF generated with the ImageType as Bitmap doesn't has this issue. Unfortunately, the resolution of Bitmap option is not good enough for my business need. The following is the code to recreate the attached PDF, which can show you what I mean the defect corner is.

string s = "
Hello world

Testing
";

PdfDocument doc = new PdfDocument();
doc.PageSettings.SetMargins(30.0f);
doc.PageSettings.Orientation = PdfPageOrientation.Portrait;
PdfPage page = doc.Pages.Add();
SizeF pageSize = page.GetClientSize();
PdfUnitConvertor unitConvertor = new PdfUnitConvertor();
float pageWidth = unitConvertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point);

using (HtmlConverter cv = new HtmlConverter())
{
cv.EnableJavaScript = false;
cv.AutoDetectPageBreak = true;
cv.EnableHyperlinks = false;

string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/";

HtmlToPdfResult hpresult = cv.Convert(s, baseUrl, ImageType.Metafile, (int)pageWidth, -1, AspectRatio.KeepWidth);
if (hpresult != null)
{
PdfMetafile mf = new PdfMetafile(hpresult.RenderedImage as Metafile);
mf.Quality = 100;
PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Break = PdfLayoutBreakType.FitElement;
format.Layout = PdfLayoutType.Paginate;
doc.PageSettings.Height = hpresult.RenderedImage.Size.Height;
format.SplitTextLines = false;
format.SplitImages = true;

hpresult.Render(page, format);
doc.Save("hello.pdf", Response, HttpReadType.Open);
}
}


Regards,
Michael







defected corner_12216ac.zip

1 Reply

PJ Priyadharshini J Syncfusion Team November 18, 2010 01:19 PM UTC

Hi Michael,

Thank you for your interest in syncfusion products.

Could you please report this issue through Direct Trac Developer Support System, by visting https://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. We hope you will take advantage of this system as well.

Please let us know if you have any queries.

Regards,
Priyadharshini


Loader.
Live Chat Icon For mobile
Up arrow icon