how to convert jpg to pdf in Android java

坚强是说给别人听的谎言 提交于 2019-12-07 04:51:43

问题


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.

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

Thanks.


回答1:


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();
   }
}


来源:https://stackoverflow.com/questions/15744454/how-to-convert-jpg-to-pdf-in-android-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!