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_c8c0e2ba.zip