从URL添加图像到PDF? [英] Add image to PDF from a URL?

查看:91
本文介绍了从URL添加图像到PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将URL地址中的图像添加到我的pdf中。代码是:

Im trying to add a image from a URL address to my pdf. The code is:

Image image=Image.getInstance("http://www.google.com/intl/en_ALL/images/logos/images_logo_lg.gif");
image.scaleToFit((float)200.0, (float)49.0);
paragraph.add(image);

但它不起作用。可能有什么问题?

But it does not work. What can be wrong?

推荐答案

使用iText从远程位置加载.gif时这是一个已知问题。

This is a known issue when loading .gif from a remote location with iText.

对此的修复是使用Java下载.gif(不是通过iText的Image类的getInstance方法),并使用Image类的getInstance方法中的下载字节。

A fix for this would be to download the .gif with Java (not via the getInstance method of iText's Image class) and to use the downloaded bytes in the getInstance method of the Image class.

编辑:
我继续在iText中修复远程gif加载,它包含在iText 5.4.1及更高版本中。

I went ahead and fixed remote gif loading in iText, it is included from iText 5.4.1 and later.

这篇关于从URL添加图像到PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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