doc = new PdfDocument();
doc.PageSettings.SetMargins(0, 10, 0, 10);
doc.PageSettings.Orientation = PdfPageOrientation.Portrait;
doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle0;
PdfPage page = null;
SizeF pageSize = SizeF.Empty;
PdfUnitConvertor convertor = new PdfUnitConvertor();
float width = -1;
float height = -1;
page = doc.Pages.Add();
pageSize = page.GetClientSize();
width = convertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point);
//height = convertor.ConvertToPixels(page.GetClientSize().Height, PdfGraphicsUnit.Point);
//PdfGraphics g = page.Graphics;
//PdfPageBase lpage = doc.Pages[0];
//PdfTemplate template = lpage.CreateTemplate();
//var b = new Bitmap(1, 1);
//b.SetPixel(0, 0, Color.White);
//var backgr = new Bitmap(b, (int)width, 1024);
//PdfImage img = new PdfBitmap(b);
//g.DrawImage(img, new PointF());
//g.DrawPdfTemplate(template, PointF.Empty, page.Size);
using (var html = new Syncfusion.HtmlConverter.HtmlConverter())
{
html.EnableJavaScript = true;
html.AutoDetectPageBreak = true;
html.EnableHyperlinks = false;
HtmlToPdfResult result = html.Convert(url, ImageType.Metafile, (int)width, (int)height,
AspectRatio.KeepWidth);
//htmltopdfresult result = html.convert(url, imagetype.metafile, (int) width, (int) height,
// aspectratio.keepheight);
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;
doc.PageSettings.Width = result.RenderedImage.Size.Width;
//doc.PageSettings.Height = result.RenderedImage.Size.Height;
format.SplitTextLines = false;
format.SplitImages = false;
mf.Draw(page, new PointF(0, 0), format);
result.Render(page, format);
}