0

I need to convert an image to PDF file in my Android application but i found two library iTextG and iText. Are they open source?

Ludger
  • 362
  • 3
  • 16

1 Answers1

2

YES, iText is an open source library. Infomation from itext oficial site: "iText is a free/open source software (F/OSS) project, giving you a lot of freedom and flexibility.... You have to respect the Affero General Public License (AGPL)."

and you can use it like that:

import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.Image;


public class ImageToPDF {
  public static void main(String ... args) {
    Document document = new Document();
    String input = "c:/temp/capture.png"; // .gif and .jpg are ok too!
    String output = "c:/temp/capture.pdf";
    try {
      FileOutputStream fos = new FileOutputStream(output);
      PdfWriter writer = PdfWriter.getInstance(document, fos);
      writer.open();
      document.open();
      document.add(Image.getInstance(input));
      document.close();
      writer.close();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}
João Marcos
  • 3,872
  • 1
  • 19
  • 14
  • My question is if this library is open source – Ludger Feb 19 '15 at 12:19
  • look this link http://itextpdf.com/pricing/android_license you must to purchase one license – Ludger Feb 19 '15 at 12:31
  • 2
    What is your point @Ludger? Are you assuming that open source means that you can use the software for free no string attached? If so, you should read the legal section of the free ebook [The Best iText Questions on StackOverflow](http://pages.itextpdf.com/ebook-stackoverflow-questions.html). iText is an open source library (you can download the source code and look inside), but that doesn't mean that you might not need a commercial license in order to use it. See also: http://stackoverflow.com/questions/27867400/is-itext-java-library-free-of-charge-or-have-any-fees-to-be-paid – Bruno Lowagie Feb 19 '15 at 12:37
  • Ludger, please approve my answer if it is useful for you. regards – João Marcos Feb 19 '15 at 17:11