use of com.itextpdf.io.source.IRandomAccessSource in project i7js-highlevel by itext.
the class C03E19_PagedImages method createPdf.
public void createPdf(String dest) throws IOException {
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
Image img;
// Animated GIF
URL url1 = UrlUtil.toURL(TEST1);
List<ImageData> list = ImageDataFactory.createGifFrames(url1);
for (ImageData data : list) {
img = new Image(data);
document.add(img);
}
// JBIG2
URL url2 = UrlUtil.toURL(TEST2);
IRandomAccessSource ras2 = new RandomAccessSourceFactory().createSource(url2);
RandomAccessFileOrArray raf2 = new RandomAccessFileOrArray(ras2);
int pages2 = Jbig2ImageData.getNumberOfPages(raf2);
for (int i = 1; i <= pages2; i++) {
img = new Image(ImageDataFactory.createJbig2(url2, i));
document.add(img);
}
// TIFF
URL url3 = UrlUtil.toURL(TEST3);
IRandomAccessSource ras3 = new RandomAccessSourceFactory().createSource(url3);
RandomAccessFileOrArray raf3 = new RandomAccessFileOrArray(ras3);
int pages3 = TiffImageData.getNumberOfPages(raf3);
for (int i = 1; i <= pages3; i++) {
img = new Image(ImageDataFactory.createTiff(url3, true, i, true));
document.add(img);
}
document.close();
}
Aggregations