ABCpdf不会在IIS6下的Web应用程序中呈现图像

时间:2022-05-01 02:09:22

I'm trying to render a web page that contains images into a pdf document using ABCpdf. This is done from a web application.

我正在尝试使用ABCpdf将包含图像的网页渲染到pdf文档中。这是通过Web应用程序完成的。

When I run the application on my development machine in IIS5, everything is fine. When I deploy the application on IIS6, the images don't appear in the pdf.

当我在IIS5中的开发机器上运行应用程序时,一切都很好。当我在IIS6上部署应用程序时,图像不会出现在pdf中。

To reproduce the problem, I made a simple web application to render a pdf file from a simple web page and I found out that the images which are not local are the ones that don't appear in the pdf.

为了重现这个问题,我创建了一个简单的Web应用程序来从一个简单的网页渲染一个pdf文件,我发现非本地的图像是那些没有出现在pdf中的图像。

The relevant code that interacts with ABCpdf is:

与ABCpdf交互的相关代码是:

Doc theDoc = new Doc();
theDoc.Rect.Inset(18, 18);
theDoc.HtmlOptions.PageCacheEnabled = false;
theDoc.HtmlOptions.PageCacheClear();
theDoc.HtmlOptions.UseNoCache = true;
theDoc.HtmlOptions.Timeout = 60000;

int theID = theDoc.AddImageUrl(theUrl);

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(location);
theDoc.Clear();

The html page that I'm using for test is this:

我用于测试的html页面是这样的:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Test page</title></head>

<body>
<p>This is a local image</p>
<img src="http://myserver/test/images/testimage.gif" />

<p>This is a remote image</p>
<img src="http://l.yimg.com/a/i/ww/beta/y3.gif" />

</body>
</html>

So I'm trying to render the page at this url: http://myserver/test/testpage.html (the code above) into a pdf.

所以我正在尝试将此页面上的页面呈现为:http://myserver/test/testpage.html(上面的代码)为pdf。

In IIS6, the second image (that is not local for the server) doesn't appear in the pdf.

在IIS6中,第二个映像(不是服务器的本地映像)不会出现在pdf中。

It seems to be a problem with access rights, but I couldn't figure it out.

这似乎是访问权限的问题,但我无法弄明白。

Thank you.

2 个解决方案

#1


I know this is a little late, but hopefully will help someone else!

我知道这有点晚了,但希望能帮到别人!

Just been experiencing a very similar problem (which is how I landed at this page..). The version of IIS was the same, but it was being run on a different server. Looks like the problem was more generation of the PDF before the image has finished downloading.

刚刚遇到一个非常类似的问题(这就是我在这个页面上的登陆方式..)。 IIS的版本是相同的,但它是在不同的服务器上运行。看起来问题是在图像下载完成之前生成更多的PDF。

I got in touch with WebSuperGoo. The said under the hood it uses MSHTML (good chance that's the difference in your environments) and a couple of suggestions were to try:

我与WebSuperGoo取得了联系。在幕后说它使用MSHTML(很有可能是你的环境的差异)和一些建议尝试:

theDoc.SetInfo(0, "CheckBgImages", "1");

and

theDoc.SetInfo(0, "RenderDelay", "5000");  // You can change this value, just an initial test.

The second will delay rendering the PDF, giving the image a chance to download.

第二个将延迟渲染PDF,使图像有机会下载。

#2


I had a similar issue and found it was caused by the size of the image file being too large.

我有一个类似的问题,发现它是由图像文件的大小太大造成的。

#1


I know this is a little late, but hopefully will help someone else!

我知道这有点晚了,但希望能帮到别人!

Just been experiencing a very similar problem (which is how I landed at this page..). The version of IIS was the same, but it was being run on a different server. Looks like the problem was more generation of the PDF before the image has finished downloading.

刚刚遇到一个非常类似的问题(这就是我在这个页面上的登陆方式..)。 IIS的版本是相同的,但它是在不同的服务器上运行。看起来问题是在图像下载完成之前生成更多的PDF。

I got in touch with WebSuperGoo. The said under the hood it uses MSHTML (good chance that's the difference in your environments) and a couple of suggestions were to try:

我与WebSuperGoo取得了联系。在幕后说它使用MSHTML(很有可能是你的环境的差异)和一些建议尝试:

theDoc.SetInfo(0, "CheckBgImages", "1");

and

theDoc.SetInfo(0, "RenderDelay", "5000");  // You can change this value, just an initial test.

The second will delay rendering the PDF, giving the image a chance to download.

第二个将延迟渲染PDF,使图像有机会下载。

#2


I had a similar issue and found it was caused by the size of the image file being too large.

我有一个类似的问题,发现它是由图像文件的大小太大造成的。