Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
From HTML to PDF
Message
From
16/05/2011 22:07:13
 
 
To
16/05/2011 13:52:24
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01510788
Message ID:
01510832
Views:
42
I have found this:

http://www.html-to-pdf.net

It works. It allows you to convert a URL to a PDF file. There is only one DLL to add as a reference to your project. Basically, you can build a class similar to something like this:
Imports ExpertPdf.HtmlToPdf
Imports System.IO

Namespace Framework

    Public Class PDF

        Public cFile As String = ""
        Public cMessage As String = ""
        Public cURL As String = ""
        Public oApp As Framework.App = Nothing
        Private oProcess As Framework.LXProcess = Nothing

        ' This is when we access the class in a desktop mode
        Sub New(ByVal toApplication As Framework.App)
            oApp = toApplication
        End Sub

        ' This is when we access the class in a Web or Web Service mode
        Public Sub New(ByVal toProcess As Framework.LXProcess)
            oProcess = toProcess
            oApp = oProcess.oApp
        End Sub

        ' Generate the PDF file
        Public Function GeneratePDF() As Boolean
            Dim llSuccess As Boolean = False
            Dim loDownloadBytes() As Byte = Nothing
            Dim loFileStream As FileStream = Nothing
            Dim loPDFConverter As PdfConverter = New PdfConverter

            ' Reset the values
            cMessage = ""

            Try

                loPDFConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4
                loPDFConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal
                loPDFConverter.PdfDocumentOptions.ShowHeader = False
                loPDFConverter.PdfDocumentOptions.ShowFooter = False
                loPDFConverter.PdfDocumentOptions.LeftMargin = 5
                loPDFConverter.PdfDocumentOptions.RightMargin = 5
                loPDFConverter.PdfDocumentOptions.TopMargin = 5
                loPDFConverter.PdfDocumentOptions.BottomMargin = 5
                loPDFConverter.PdfDocumentOptions.GenerateSelectablePdf = True

                loPDFConverter.PdfDocumentOptions.ShowHeader = False
                loPDFConverter.PdfHeaderOptions.HeaderText = ""
                loPDFConverter.PdfHeaderOptions.HeaderTextColor = Drawing.Color.Blue
                loPDFConverter.PdfHeaderOptions.DrawHeaderLine = False

                loPDFConverter.PdfFooterOptions.FooterText = ""
                loPDFConverter.PdfFooterOptions.FooterTextColor = Drawing.Color.Blue
                loPDFConverter.PdfFooterOptions.DrawFooterLine = False
                loPDFConverter.PdfFooterOptions.PageNumberText = "Page"
                loPDFConverter.PdfFooterOptions.ShowPageNumber = True

                'loPDFConverter.LicenseKey = "put your serial number here"
                loDownloadBytes = loPDFConverter.GetPdfFromUrlBytes(cURL)

                ' Create a file and write the byte data to a file.
                loFileStream = New System.IO.FileStream(cFile, System.IO.FileMode.Create)
                loFileStream.Write(loDownloadBytes, 0, loDownloadBytes.Length)
                loFileStream.Close()

                llSuccess = True

            Catch loError As Exception
                cMessage = loError.Message
            End Try

            Return llSuccess
        End Function

    End Class

End Namespace
And, then, you can call it like this:
        Dim loPDF As Framework.Framework.PDF = New Framework.Framework.PDF(oApp)

        loPDF.cURL = "http://www.levelextreme.com"
        loPDF.cFile = "d:\Test.pdf"
        If Not loPDF.GeneratePDF() Then
            MessageBox.Show(loPDF.cMessage)
            Exit Sub
        End If
The tool seems to generate the PDF as is. I have not taken the time to analyze all the details, but the HTML in the browser seems to be what is generated as a PDF.

The licensing however, is something else. You may take a look at http://www.html-to-pdf.net/Pricing.aspx for the information.

I would like to know if someone else already used that one. Any related comment would be appreciated.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform