将 HTML 保存为 PDF ABCPdf 4

发布于 2024-08-05 13:56:37 字数 761 浏览 3 评论 0原文

我正在使用以下代码将 html 保存到 pdf 文件。但它无法编译 if (!theDoc.Chainable(theID))。我确实使用了 WebSupergoo.ABCpdf4;添加在代码的开头。是这个版本的问题吗?是否有其他方法可以将 HTML 字符串保存到 ABCPdf 4 中的 pdf 文件。

错误消息是“'WebSupergoo.ABCpdf4.Doc' 不包含 'Chainable' 的定义,并且没有扩展方法 'Chainable' 接受类型为 ' 的第一个参数可以找到“WebSupergoo.ABCpdf4.Doc”(您是否缺少 using 指令或程序集参考?)

Doc theDoc = new Doc();
theDoc.Rect.Inset(10, 50);
theDoc.Page = theDoc.AddPage();
int theID;
theID = theDoc.AddImageHtml(str);
while (true)
{
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
theDoc.Save("path where u want 2 save" + ".pdf");
theDoc.Clear();

感谢所有帮助。

I'm using following code to save html to pdf file. But it fails to compile at
if (!theDoc.Chainable(theID)). I do have using WebSupergoo.ABCpdf4; added at the begining of the code. Is this version issue? Is there any other method to save HTML string to pdf file in ABCPdf 4.

Error Message is "'WebSupergoo.ABCpdf4.Doc' does not contain a definition for 'Chainable' and no extension method 'Chainable' accepting a first argument of type 'WebSupergoo.ABCpdf4.Doc' could be found (are you missing a using directive or an assembly reference?)

Doc theDoc = new Doc();
theDoc.Rect.Inset(10, 50);
theDoc.Page = theDoc.AddPage();
int theID;
theID = theDoc.AddImageHtml(str);
while (true)
{
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
theDoc.Save("path where u want 2 save" + ".pdf");
theDoc.Clear();

All the help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

焚却相思 2024-08-12 13:56:37

我修好了这个。以下是将 html 字符串保存到 pdf 的代码。

Doc theDoc = new Doc(); 
theDoc.Rect.Inset(10, 50); 
theDoc.Page = theDoc.AddPage(); 
int theID; 
theID = theDoc.AddImageHtml(str); 
while (true) 
{ 
   if (theDoc.GetInfo(theID, "Truncated") != "1") 
    break; 
   theDoc.Page = theDoc.AddPage(); 
   theID = theDoc.AddImageToChain(theID); 
} 
for (int i = 1; i <= theDoc.PageCount; i++) 
{ 
      theDoc.PageNumber = i; 
      theDoc.Flatten(); 
} 
theDoc.Save("path where u want 2 save" + ".pdf");
theDoc.Clear();

I fixed this. Following is the code to save html string to pdf.

Doc theDoc = new Doc(); 
theDoc.Rect.Inset(10, 50); 
theDoc.Page = theDoc.AddPage(); 
int theID; 
theID = theDoc.AddImageHtml(str); 
while (true) 
{ 
   if (theDoc.GetInfo(theID, "Truncated") != "1") 
    break; 
   theDoc.Page = theDoc.AddPage(); 
   theID = theDoc.AddImageToChain(theID); 
} 
for (int i = 1; i <= theDoc.PageCount; i++) 
{ 
      theDoc.PageNumber = i; 
      theDoc.Flatten(); 
} 
theDoc.Save("path where u want 2 save" + ".pdf");
theDoc.Clear();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文