ABCpdf不会在IIS6下的Web应用程序中呈现图像 [英] ABCpdf doesn't render images in an web application under IIS6

查看:68
本文介绍了ABCpdf不会在IIS6下的Web应用程序中呈现图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ABCpdf将包含图像的网页呈现为pdf文档.这是通过Web应用程序完成的.

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

当我在IIS5的开发计算机上运行应用程序时,一切都很好.当我在IIS6上部署应用程序时,图像未显示在pdf中.

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.

为重现此问题,我制作了一个简单的Web应用程序,以从一个简单的网页呈现pdf文件,结果发现非本地的图像是那些未出现在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.

与ABCpdf交互的相关代码是:

The relevant code that interacts with ABCpdf is:

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();

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

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

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

因此,我试图在此URL上呈现页面: http://myserver/test/testpage.html (上面的代码)转换为pdf.

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

在IIS6中,第二个图像(对于服务器而言不是本地的)没有出现在pdf中.

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

访问权限似乎存在问题,但我无法弄清楚.

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

谢谢.

推荐答案

我知道这有点晚了,但希望能对其他人有所帮助!

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

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

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.

我与WebSuperGoo联系了.内幕说,它使用MSHTML(很可能是您的环境有所不同),并且有一些建议可以尝试:

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:

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

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

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

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

这篇关于ABCpdf不会在IIS6下的Web应用程序中呈现图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆