You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法找到类型或命名空间PdfHtmlLayoutFormat的技术咨询

解决PdfHtmlLayoutFormat类型或命名空间找不到的问题
  • 排查版本功能限制
    FreeSpire.PDF作为免费版本,部分高级功能类(如PdfHtmlLayoutFormat)仅在付费版Spire.PDF中提供。你当前使用的免费包可能不包含该类,若需此功能,需升级至付费版本。

  • 核对命名空间引用
    若已使用付费版,需确认代码中添加了正确的命名空间:

    using Spire.Pdf.HtmlConverter;
    

    PdfHtmlLayoutFormat类归属此命名空间,未引用会导致识别失败。

  • 免费版替代方案
    若不想升级付费版,可使用FreeSpire.PDF支持的LoadFromHTML重载方法,移除PdfHtmlLayoutFormat参数,调整后代码如下:

    //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);
    
    String url = "https://www.wikipedia.org/";
    
    Thread thread = new Thread(() =>
    { 
        // 使用无PdfHtmlLayoutFormat参数的重载
        doc.LoadFromHTML(url, false, false, false, setting); 
    });
    thread.SetApartmentState(ApartmentState.STA);
    thread.Start();
    thread.Join();
    
    //Save pdf file.
    doc.SaveToFile("output-wiki.pdf");
    

内容的提问来源于stack exchange,提问作者Shiraz Bhaiji

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 02:25:42