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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

WebKitHtmlConverter auto fit to single pdf document page

Thread ID:





125249 Aug 2,2016 09:56 PM UTC Aug 4,2016 04:23 PM UTC ASP.NET MVC 1
Tags: PDF
Asked On August 2, 2016 09:56 PM UTC

Hi Team,

How do I set the converted html to fit into a single page pdf?

            var htmlContent = RenderViewToString(ControllerContext, viewPath, model, true);

            PdfPage page = document.Pages.Add();
            SizeF pageSize = SizeF.Empty;
            PdfUnitConvertor convertor = new PdfUnitConvertor();
            float width = -1;
            float height = -1;

            width = convertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point);
            height = convertor.ConvertToPixels(page.GetClientSize().Height, PdfGraphicsUnit.Point);
            // Create a new instance of HtmlConverter class.
            WebKitHtmlConverter html = new WebKitHtmlConverter();
            //WebKit assembly path
            string WebKitBinaryPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "QTBinaries");
            html.WebKitPath = WebKitBinaryPath;

            // Convert to metafile.
            HtmlToPdfResult result = html.Convert(htmlContent, viewPath, (int)width, (int)height);
            // Draw metafile in PdfPage.
            result.Render(page, metafileFormat);            

            //Save pdf on location

Prakash Viswanathan [Syncfusion]
Replied On August 4, 2016 04:23 PM UTC

Hi Lory, 

Thank you for contacting syncfusion support. 
Currently, we do not have support for fitting HTML content in single PDF page. We will implement this feature in any of our upcoming release, and let you know once this is implemented. 

Prakash V. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon