如何为JPG格式转换为PDF Android中Java的 [英] how to convert jpg to pdf in Android java

查看:173
本文介绍了如何为JPG格式转换为PDF Android中Java的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要转换多个.jpg文件到ONE .​​pdf文件(使用设备相机拍摄)。
我看到了很多像iText的,mupdf,PDFjet,pdjBox工具。

I want to convert several .jpg files (taken using the device camera) to ONE .pdf file. I saw a lot of tools like iText, mupdf, PDFjet, pdjBox.

是不是有什么更简单? (如准备为Android的API?)

Is there something more simple? (like an API ready for android?)

感谢。

推荐答案

使用iText库将文本转换为PDF。使用此图像转换为PDF格式。

using iText Library to convert the text to pdf. Use this to convert image to 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();
   }
}

这篇关于如何为JPG格式转换为PDF Android中Java的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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