生成PDF然后下载为JPEG或图像文件

时间:2021-10-14 17:06:55

I am using iText to generate PDF and is working fine, and I can also download it via browser as PDF. However, is it possible for java or iText to convert it to JPEG or any IMAGE file and allow users to download the image file.

我正在使用iText生成PDF并且工作正常,我也可以通过浏览器以PDF格式下载。但是,java或iText是否可以将其转换为JPEG或任何IMAGE文件,并允许用户下载图像文件。

response.setContentType("application/pdf; charset=utf-8");

Merely changing the contentType to image/jpg is not possible. I am continuously looking for answer but struggling to find one.

仅仅将contentType更改为image / jpg是不可能的。我一直在寻找答案但很难找到答案。

Any idea would be a lot of help

任何想法都会有很多帮助

2 个解决方案

#1


0  

I dont know more about iText. But using PDFBox we can convert pdf document into images. After splitting you can push images to response.

我不太了解iText。但是使用PDFBox我们可以将pdf文档转换为图像。拆分后,您可以将图像推送到响应。

Here some reference links :

这里有一些参考链接:

http://pdfbox.apache.org/commandlineutilities/PDFToImage.html

Converting a PDF into multiple JPGs with iText or other

使用iText或其他方式将PDF转换为多个JPG

http://www.javatpoint.com/example-to-display-image-using-servlet

#2


0  

you can use iText only for generating a pdf nothing else. see the link http://itextpdf.com/itext.php . see this to convert a pdf to image. See this link as well for clearer understanding with an example.

您只能使用iText生成pdf。请参阅http://itextpdf.com/itext.php链接。看到这个将pdf转换为图像。请参阅此链接以便通过示例更清楚地理解。

#1


0  

I dont know more about iText. But using PDFBox we can convert pdf document into images. After splitting you can push images to response.

我不太了解iText。但是使用PDFBox我们可以将pdf文档转换为图像。拆分后,您可以将图像推送到响应。

Here some reference links :

这里有一些参考链接:

http://pdfbox.apache.org/commandlineutilities/PDFToImage.html

Converting a PDF into multiple JPGs with iText or other

使用iText或其他方式将PDF转换为多个JPG

http://www.javatpoint.com/example-to-display-image-using-servlet

#2


0  

you can use iText only for generating a pdf nothing else. see the link http://itextpdf.com/itext.php . see this to convert a pdf to image. See this link as well for clearer understanding with an example.

您只能使用iText生成pdf。请参阅http://itextpdf.com/itext.php链接。看到这个将pdf转换为图像。请参阅此链接以便通过示例更清楚地理解。