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

HtmlConverter not applying stylesheet when using WebKit

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

4 Replies

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



SA Sauro 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