Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert jpg to pdf in Android java

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.

like image 966
Ofer Segev Avatar asked Apr 01 '13 13:04

Ofer Segev


1 Answers

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();
   }
}
like image 122
Nathan Avatar answered Oct 17 '22 14:10

Nathan