Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Jan 13, 2015 5:02 pm

I have an hrtml page that I am converting to a pdf like
Code: Select all
Spire.Pdf.PdfDocument pp = new Spire.Pdf.PdfDocument();
        Spire.Pdf.PdfPageSettings pst = new Spire.Pdf.PdfPageSettings();
        PdfHtmlLayoutFormat format = new PdfHtmlLayoutFormat();

        format.FitToPage = Clip.Both;
        format.Layout = PdfLayoutType.OnePage;

        pst.Size = Spire.Pdf.PdfPageSize.Letter;
        pst.Orientation = Spire.Pdf.PdfPageOrientation.Portrait;
        pst.SetMargins(0);

        string testUrl = theDestUrl;

        Thread thread = new Thread(() =>
        {
            pp.LoadFromHTML(testUrl, true, true, false, pst, format);
        });

        thread.SetApartmentState(ApartmentState.STA);
       
            thread.Start();
            thread.Join();
       
        string path = pathToSaveFile;
        pp.SaveToFile(path, Spire.Pdf.FileFormat.PDF);


The page has some background images that are set and configured in css. Sometimes the background images appear in the generated pdf, sometimes they don't, and sometimes some of the background images appear while others do not.

I am using the Spire.Pdf dll version 3.2.31.5040.

If I bring the html page up in IE it appears fine with all the background images.

danm
 
Posts: 6
Joined: Mon Jan 05, 2015 3:01 pm

Wed Jan 14, 2015 1:47 am

Dear damn,

Thanks for your inquiry.

After some investigation, I guess the problem is the page don't load at all sometimes, please set
Code: Select all
format.IsWaiting = true;

to wait the page load completely.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Thu Jan 15, 2015 8:25 am

Hello damn,

Have you tried the solution I provided? Did it work?

Looking forward to your response.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.PDF

cron