Convert HTML document to PDF from ASP.NET

Question:I've got an ASP.NET web page that is a dynamically generated report. For business reasons, this exact report needs to be produced as a PDF. What's the best way to do this? Setting the selected printer to Adobe PDF is not an option. Learn to programmatically create PDF files from scratch? Is there a way on VeryPDF to render it in some browser HTML file to PDF?

Answer: According to my understanding, you need to convert HTML file to PDF from ASP.NET web page. If I understand your question right, maybe you can have a free trial of software VeryPDF Document Printer SDK, by which you can convert all the printable files like Word, Excel, and PowerPoint documents and others to PDF or image together with C#, VB .NET, MS Visual Basic, Borland Delphi, VBA (MS Office products such as Access) and C++ via COM, C and C++ via native C. Please check more related information of this software on homepage, in the following part, let us check how to use this software.

Step 1. Free download Document Printer SDK

  • Same with other software toolkit, for uploading and downloading easily, we have compressed this software to zip file. When downloading finishes, you need to unzip file then you can use it normally.
  • There are many versions of this software on Try and Buy website, please download the proper version according to your needs.

Step 2. Convert HTML to PDF from ASP

  • When you use this software, please refer to the usage and code template examples.
  • Here are some parameters you may need to specify output PDF, please have a check.
    -f <paper size>   : set the paper size to printer
  • -o <output files> : filename for output
           '-j <subject>      : "subject" for PDF file
           '-t <title>        : "title" for PDF file
           '-a <author>       : "author" for PDF file
           '-k <keywords>     : "keywords" for PDF file
           '-g <page range>   : page range for conversion, eg: 1,2-4,6
           '-G                : don't append suffix to filename for single page file
           '-p <output Flag>  : a flag for PDF output
           '    -p 0          : overwrite if PDF file exists
    doc2pdf -i https://www.verypdf.com -o C:\output.pdf
    doc2pdf -l 10000 -i https://www.verypdf.com -o C:\output.pdf

  • Here is one code template of calling this software from ASP, please have a check.
  • ASP Example:

    After you installed docPrint Pro into your system, you can simple run following ASP code to convert your documents to other formats,
    <%
    'On Error Resume next
            Set docPrint = Server.CreateObject("DocPrintCom.docPrint")
    DocumentConverter docPrint, "VeryPDF.doc", "VeryPDF.pdf", ""
    function DocumentConverter(byval docPrint, strInFile, strOutFile, strOptions)
        Dim strFullInFileName,strFullOutFileName
    Dim strRootPath
    Dim strAllOptions
    strRootPath = Server.MapPath(".") & "\"
    strFullInFileName = strRootPath & strInFile
    strFullOutFileName = strRootPath & strOutFile
    strAllOptions = """-*"" ""XXXXXXXXXXXXXX"""
    strAllOptions = strAllOptions & strOptions
    nRet = docPrint.docPrintCOM_Register("XXXXXXXXXXXXXX", "VeryPDF.com Company")
                ' Execute document conversion from "Administrator" user account,
    nRet = docPrint.docPrintCOM_DocumentConverterEx("Administrator", "123456", strFullInFileName, strFullOutFileName,  strAllOptions)
                strHTMLCode = strFullInFileName & " ==> " & strFullOutFileName & "<br>"
                strHTMLCode = strHTMLCode & "<A href=""" & strOutFile & """ target=""_blank"">" & strOutFile & "</A><br>"
                Response.write strHTMLCode
    end function
    %>

During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!