我正在使用 itext 2.1.7 在 spring MVC Controller 中动态创建 rtf 文件。
我使用的类是RTFWriter2
。这效果很好。但我无法向其中添加图像。
该图像是我从 JPA 域对象获取的字节数组。我还尝试从文件中读取示例图像。但这也行不通。图像类来自 itext 包,其构造函数允许字节数组。
这是我使用的代码:
Image img = Image.getInstance(user.getStammdaten().getProfileImage());
document.add(img);
document.newPage();
有什么线索吗?
最佳答案
也许这个脚本会对您有所帮助。 https://joseluisbz.wordpress.com/2011/06/22/script-de-clases-rtf-para-jsp-y-php/ 现在, 这里有一个使用示例: https://joseluisbz.wordpress.com/2011/07/16/subiendo-imagenes-png-y-jpg-y-archivos-a-mysql-con-php-y-jsp-y-mostrarlos-en-rtf-usando-clases/
关于java - 使用 iText 将图像添加到 java 中的 rtf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8443050/