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.
Unfortunately, activation email could not send to your email. Please try again.

WebKitHtmlConverter auto fit to single pdf document page

Thread ID:

Created:

Updated:

Platform:

Replies:

125249 Aug 2,2016 05:56 PM Aug 4,2016 12:23 PM ASP.NET MVC 1
loading
Tags: PDF
Lory
Asked On August 2, 2016 05:56 PM

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 12:23 PM

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. 


CONFIRMATION

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.

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.

;