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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HtmlConverter not applying stylesheet when using WebKit

Thread ID:

Created:

Updated:

Platform:

Replies:

145849 Jul 10,2019 04:30 PM UTC Jul 16,2019 01:33 PM UTC WinForms 4
loading
Tags: PDF
Sauro
Asked On July 10, 2019 04:30 PM UTC

Hi,
I am trying to convert an xml file to pdf using an xsl. IE engine generates the correct pdf (almost correct, that is why I am trying to use WebKit), Webkit generates a pdf not formatted. Attached both of them with xsl used.
Below the code; to test engines I comment declaration of HtmlConverter and Settings accordingly. WriteFattura_GetWkSettings() has many settings but disabling them result does not change. I spent all day performing several test without success, any idea?
Thanks

Private Sub WriteFattura
            Dim Writer = Xml.XmlWriter.Create(FullXmlFilename, New System.Xml.XmlWriterSettings With {.Indent = True})
            Writer.WriteProcessingInstruction("xml-stylesheet", "type=""text/xsl"" rel='nofollow' rel='nofollow' href=""" & FullXslFilename & """")
            WriteXml(Writer)
            Writer.Close()
            'Dim HtmlConverter As New Syncfusion.HtmlConverter.HtmlToPdfConverter(Syncfusion.HtmlConverter.HtmlRenderingEngine.WebKit)
            Dim HtmlConverter As New Syncfusion.HtmlConverter.HtmlToPdfConverter(Syncfusion.HtmlConverter.HtmlRenderingEngine.IE)
            'Dim Settings = WriteFattura_GetWkSettings()
            Dim Settings = WriteFattura_GetIESettings()
            HtmlConverter.ConverterSettings = Settings
            Dim PdfDocument As Syncfusion.Pdf.PdfDocument
            PdfDocument = HtmlConverter.Convert(FullXmlFilename)
            PdfDocument.Save(FullPrintFilename)
            PdfDocument.Close()
End Sub

Private Function WriteFattura_GetWkSettings() As Syncfusion.HtmlConverter.WebKitConverterSettings
            Dim S As New Syncfusion.HtmlConverter.WebKitConverterSettings
            S.WebKitPath = Environment.CurrentDirectory & "\QtBinaries"
            S.AdditionalDelay = 5000
            S.MediaType = Syncfusion.HtmlConverter.MediaType.Print
            S.EnableJavaScript = True
            S.EnableOfflineMode = True
            S.EnableRepeatTableFooter = True
            S.EnableRepeatTableHeader = True
            Return S
End Function

Private Function WriteFattura_GetIESettings() As Syncfusion.HtmlConverter.IEConverterSettings
            Dim S As New Syncfusion.HtmlConverter.IEConverterSettings
            S.AdditionalDelay = 5000
            S.EnableJavaScript = True
            'IESettings.AspectRatio = Syncfusion.HtmlConverter.AspectRatio.KeepWidth
            'IESettings.Margin.Left = 130
            'IESettings.Margin.Right = 30
            'Dim Margin = New Syncfusion.Pdf.Graphics.PdfMargins()
            'Margin.All = 30
            'IESettings.Margin = Margin
            Return S
End Function



Attachment: Attachments_4ddd5602.zip

Prakash Viswanathan [Syncfusion]
Replied On July 11, 2019 08:45 AM UTC

Hi Sauro, 

Thank you contacting Syncfusion support.  

WebKit HTML converter internally make use of QtWebKit rendering engine for the conversion, WebKit rendering engine itself do not have support for converting XML to PDF with XLS. We can use IE rendering engine, which supports the XML to PDF conversion. If you are facing any issue with XML to PDF conversion with IE, kindly provide us the complete details about the issue. So, that it will be helpful for us to analyze and assist you further on this.  

Regards, 
Prakash V 


Sauro
Replied On July 11, 2019 01:02 PM UTC

Hi Prakash,
thanks for supporting me. As you can see in the image the right margin doesn't display correctly (one of the two decimal digit is missing and also the remaining margin).
After many tests I argue it is a problem with the mix of margins, sizes of IeSettings and PdfDocument.PegeSettings.
- Can you drive me to some documentation where is explained how to master this aspect?
- Do you plan to implement xml to Pdf in WebKit? Pdf as image of IE Engine is not the max, at all.
Thanks again


Gowthamraj Kumar [Syncfusion]
Replied On July 12, 2019 01:40 PM UTC

Hi Sauro, 

Query 
Response 
As you can see in the image the right margin doesn't display correctly (one of the two decimal digit is missing and also the remaining margin). 
After many tests I argue it is a problem with the mix of margins, sizes of IeSettings and PdfDocument.PegeSettings. 
- Can you drive me to some documentation where is explained how to master this aspect? 
We are able to reproduce the “PDF content is clipped while converting XML to PDF using IE” issue in our end. Currently we are analysing on this and we will update you with validation details by July 16th, 2019.  
Do you plan to implement xml to Pdf in WebKit? Pdf as image of IE Engine is not the max, at all. 
WebKit HTML converter internally make use of QtWebKit rendering engine for the conversion, WebKit rendering engine itself do not have support for converting XML to PDF with XLS. So, there is no plan to implement XML to PDF in WebKit. 
 
Regards, 
Gowthamraj K 


Gowthamraj Kumar [Syncfusion]
Replied On July 16, 2019 01:33 PM UTC

Hi Sauro, 

Thanks for the patience. 

We have further checked about the reported behavior, In IE based HTML to PDF converter we internally make use of MSHTML(IE rendering engine) to convert HTML/XML to intermediate image, we will render the intermediate image to the PDF document. As IE itself creates the image with the cropped content due to browser itself unable to find the minimum content width from the XML. So, it is generating the cropped image, as a workaround we can overcome this issue by increasing the page width, which will be set to the browser size. Can you please try the conversion with below page size and let us know the result. Please refer below code snippet for set the manual page size to converter settings,   

'Set manual pdf page size.   
settings.PdfPageSize = New System.Drawing.SizeF(618, 842) 


Please refer the below output PDF documents,   

Please let us know if you need any further assistance on this. 

Regards, 
Gowthamraj K 


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.

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

Live Chat Icon For mobile
Live Chat Icon