Hi,
I m using the code below to convert a Tiff file (attached) with multiple page into PDF. The resulting PDF contains only the first page in Tiff. Is this the right way of doing this? If not, could you please provide a code snippet explaining how to do it?
static private ByteArrayOutputStream convertTIFToPdf(byte[] inByteArray) {
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
ByteArrayInputStream srcStream = null;
try {
srcStream = new ByteArrayInputStream(inByteArray);
Pdf pdf = new Pdf();
// add a section
Section sec1 = pdf.getSections().add();
// create an image object
aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
// set image
img1.getImageInfo().setImageStream(srcStream);
// specify the image file type
img1.getImageInfo().setImageFileType(ImageFileType.Tiff);
img1.getImageInfo().setTiffFrame(-1);
//System.out.println(img1.getImageInfo());
// add image to paragraphs collection of Section object
sec1.getParagraphs().add(img1);
// specify the image height information equal to Section height
// minus Top and Bottom margin of page
img1.getImageInfo().setFixHeight(
sec1.getPageInfo().getPageHeight()
- sec1.getPageInfo().getMargin().getTop()
- sec1.getPageInfo().getMargin().getBottom());
// specify the image Width information equal to Section Width minus
// Left and Right margin of page
img1.getImageInfo().setFixWidth(
sec1.getPageInfo().getPageWidth()
- sec1.getPageInfo().getMargin().getLeft()
- sec1.getPageInfo().getMargin().getRight());
// save the pdf file
pdf.save(dstStream);
} catch (Exception e) {
e.printStackTrace();
}
return dstStream;
}
Thanks