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

WebKitHtmlConverter auto fit to single pdf document page

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


1 Reply

PV Prakash Viswanathan Syncfusion Team 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. 

Regards, 
Prakash V. 


Loader.
Live Chat Icon For mobile
Up arrow icon