Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

from the last few am faqcing problem in converting ASPX page to pdf. I have gone thru lot of articles but all in vain. Am not getting exact solution to my problem. I have created an ASPX page. i was using "ExpertPDF" dll to convert page to pdf.

On this page, am fetching data from database at runtime. If i try to convert blank page then its working fine. But when am converting this ASPX page after getting data on page load
Am fetting this error

ExpertPdf Could not render the url. Could not get image from url.Navigation timeout


Please help me............
Posted
Updated 21-Mar-17 23:46pm
v2
Comments
[no name] 28-Nov-10 21:40pm    
Have you asked ExpertPDF? They have support available.
Whictopis 31-May-17 5:00am    
You could try this alternative PDF library for C#, it provides a very simple and straightforward way to convert ASPX to PDF.

i think you should use crystal repots for it.Crystal reports have pdf generate option on it.
 
Share this answer
 
I use the Winnovative.WnvHtmlConvert;

You can find it and download the wnvhtmlconvert.dll.
Make reference to the dll.
It is not free but it has demo version with a license. Get it from the site: http://www.winnovative-software.com/[^]
Use the following function:


/// <summary>
    /// Convert the HTML code from the specified URL to a PDF document and send the
    /// document as an attachment to the browser
    /// </summary>
    private void ConvertURLToPDF()
    {

        // Create the PDF converter. Optionally you can specify the virtual browser
        // width as parameter. 1024 pixels is default, 0 means autodetect
        PdfConverter pdfConverter = new PdfConverter();

        // set the license key - required
        pdfConverter.LicenseKey = "you license here";

        // set the converter options - optional
        pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
        pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
        pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;


        // set if header and footer are shown in the PDF - optional - default is false
        pdfConverter.PdfDocumentOptions.ShowHeader = false;
        pdfConverter.PdfDocumentOptions.ShowFooter = false;
        // set to generate a pdf with selectable text or a pdf with embedded image - optional - default is true
        pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;
        // set if the HTML content is resized if necessary to fit the PDF page width - optional - default is true
        pdfConverter.PdfDocumentOptions.FitWidth = true;
        //
        // set the embedded fonts option - optional - default is false
        pdfConverter.PdfDocumentOptions.EmbedFonts = false;
        // set the live HTTP links option - optional - default is true
        pdfConverter.PdfDocumentOptions.LiveUrlsEnabled = true;

        if (true) //(radioConvertToSelectablePDF.Checked)
        {
            // set if the JavaScript is enabled during conversion to a PDF with selectable text
            // - optional - default is false
            pdfConverter.ScriptsEnabled = false;
            // set if the ActiveX controls (like Flash player) are enabled during conversion
            // to a PDF with selectable text - optional - default is false
            pdfConverter.ActiveXEnabled = false;
        }
        else
        {
            // set if the JavaScript is enabled during conversion to a PDF with embedded image
            // - optional - default is true
            pdfConverter.ScriptsEnabledInImage = true;
            // set if the ActiveX controls (like Flash player) are enabled during conversion
            // to a PDF with embedded image - optional - default is true
            pdfConverter.ActiveXEnabledInImage = true;
        }

        // set if the images in PDF are compressed with JPEG to reduce the PDF document size - optional - default is true
        pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = true;

        // enable auto-generated bookmarks for a specified list of tags (e.g. H1 and H2)
        if (false)
        {
            pdfConverter.PdfBookmarkOptions.TagNames = new string[] { "H1", "H2" };
        }

        // set PDF security options - optional
        //pdfConverter.PdfSecurityOptions.CanPrint = true;
        //pdfConverter.PdfSecurityOptions.CanEditContent = true;
        //pdfConverter.PdfSecurityOptions.UserPassword = "";

        //set PDF document description - optional
        //pdfConverter.PdfDocumentInfo.AuthorName = "Winnovative HTML to PDF Converter";

        //// add HTML header
        //if (cbAddHeader.Checked)
        //    AddHeader(pdfConverter);
        //// add HTML footer
        //if (cbAddFooter.Checked)
        //    AddFooter(pdfConverter);

        // Performs the conversion and get the pdf document bytes that you can further
        // save to a file or send as a browser response
        byte[] pdfBytes = pdfConverter.GetPdfBytesFromUrl(urlToConvert);

        // send the PDF document as a response to the browser for download
        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
        response.Clear();
        response.AddHeader("Content-Type", "binary/octet-stream");
        response.AddHeader("Content-Disposition",
            "attachment; filename=ConversionResult.pdf; size=" + pdfBytes.Length.ToString());
        response.Flush();
        response.BinaryWrite(pdfBytes);
        response.Flush();
        response.End();
    }


Good luck.
 
Share this answer
 
Comments
Dalek Dave 29-Nov-10 17:39pm    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900