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?
Asked
Active
Viewed 2,413 times
0

Ludger
- 362
- 3
- 16
-
Look here: http://stackoverflow.com/questions/5389994/convert-image-to-pdf-in-android – Mohamed Feb 19 '15 at 12:13
-
I advise you to accept the answer by João Marcos because it's a correct answer. – Bruno Lowagie Feb 19 '15 at 12:39
1 Answers
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
-
-
look this link http://itextpdf.com/pricing/android_license you must to purchase one license – Ludger Feb 19 '15 at 12:31
-
2What 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
-