我想将几个 .jpg 文件(使用设备相机拍摄)转换为一个 .pdf 文件。 我看到了很多工具,例如 iText、mupdf、PDFjet、pdjBox。
还有更简单的吗? (比如为 Android 准备的 API?)
谢谢。
最佳答案
使用 iText 库将文本转换为 pdf。使用它将图像转换为 pdf。
import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class imagesPDF
{
public static void main(String arg[])throws Exception
{
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("YourPDFHere.pdf"));
document.open();
Image image = Image.getInstance ("yourImageHere.jpg");
document.add(new Paragraph("Your Heading for the Image Goes Here"));
document.add(image);
document.close();
}
}
关于java - 如何在 Android java 中将 jpg 转换为 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15744454/