If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself. Thread.SetApartmentState(ApartmentState.STA) 'Load HTML from html string using LoadFromHTML methodĭoc.LoadFromHTML(htmlString, True, setting, htmlLayoutFormat) Setting.Margins = New (20)ĭim htmlLayoutFormat As PdfHtmlLayoutFormat = New PdfHtmlLayoutFormat() 'Save page size and margins through the object Namespace ConvertHtmlStringToPdfWithoutPluginĭim doc As PdfDocument = New PdfDocument()ĭim setting As PdfPageSettings = New PdfPageSettings() Load HTML from a URL path using LoadFromHTML method PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat() Save page size and margins through the object PdfPageSettings setting = new PdfPageSettings() Save the document to a PDF file using PdfDocument.SaveToFile() method.Load HTML from the URL path using PdfDocument.LoadFromHTML() method.PDFsharp 1.31 can be downloaded from SourceForge or CodePlex. It's a beta version, but AFAIK it supports nearly everything and may work for your needs. Create a PdfHtmlLayoutFormat object, and set the IsWaiting property of it to true. There is an XPS Converter that was included with PDFsharp 1.31. In this sample you can see how you convert your PDF document to an XPS format (which is Microsoft Windows version of PDF). Create a PdfPageSettings object, and set the page size and margins through it.The following are the steps to convert a URL to PDF using Spire.PDF without plugin. HtmlConverter.Convert(htmlString, fileName, True, 100000, New Size(1080, 1000), New PdfMargins(0), .SourceCode) Namespace ConvertHtmlStringToPdfWithPluginĭim htmlString As String = File.ReadAllText("C:\Users\Administrator\Desktop\Document\Html\Sample.html")ĭim fileName As String = "HtmlStringToPdf.pdf" If you have an external CSS style sheet, please convert it to inline or internal CSS style. Step 1: Introduce a class named pdfDocument which is used to initialize a, and load a XPS file by calling the method of LoadForm File. Note: Only inline CSS style and internal CSS style can be rendered correctly on PDF. Call HtmlConverter.Convert(string htmlString, string fileName, bool enableJavaScript, int timeout, SizeF pageSize, PdfMargins margins, htmlType) method to convert HTML string to a PDF document.Specify the plugin path, and assign it as the value of the HtmlConverter.PluginPath property.
0 Comments
Leave a Reply. |