- 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.