Type or namespace PdfHtmlLayoutFormat could not be found

474 views Asked by At

I am testing Spire.PDF with example code from this site: https://www.nuget.org/packages/FreeSpire.PDF

    //Create a pdf document.
    PdfDocument doc = new PdfDocument();

    PdfPageSettings setting = new PdfPageSettings();

    setting.Size = new SizeF(1000,1000);
    setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

    PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
    htmlLayoutFormat.IsWaiting = true;
    
    String url = "https://www.wikipedia.org/";
 
    Thread thread = new Thread(() =>
    { doc.LoadFromHTML(url, false, false, false, setting,htmlLayoutFormat); });
    thread.SetApartmentState(ApartmentState.STA);
    thread.Start();
    thread.Join();

    //Save pdf file.
    doc.SaveToFile("output-wiki.pdf");

enter image description here

I have imported the nuget package. It manages to find several of the types but not PdfHtmlLayoutFormat.

2

There are 2 answers

0
Dheeraj Malik On

You need to add the following namespace:

using Spire.Pdf.HtmlConverter;

For more information, you can visit this link: https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Convert-HTML-to-PDF-Customize-HTML-to-PDF-Conversion-by-Yourself.html

1
Toteau On

The LoadFromHtml method is now removed.