Hello,
Hi Stanislava,
Hi,
Hi Vincent,
Document doc = new Document();<o:p></o:p>
Page page = doc.getPages().add();
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setLeft(0);
page.getPageInfo().getMargin().setRight(0);
page.setCropBox(new com.aspose.pdf.Rectangle(0, 0, 400, 400));
com.aspose.pdf.Image image = new com.aspose.pdf.Image();
image.setFile("test.tif");
image.setBlackWhite(true);
doc.getPages().get_Item(1).getPageInfo().setLandscape(true);
doc.getPages().get_Item(1).getParagraphs().add(image);
doc.save("Converted_Aspose.pdf");
Iterator readers = ImageIO.getImageReaders(iis);
ImageReader ir = readers.next();
ir.setInput(iis);
Section sec1 = pdf1.getSections().add();
for (int i = 0; i <frameCount; ++i)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(ir.read(i), "jpg", baos);
baos.flush();
Image img1 = new Image(sec1);
sec1.getParagraphs().add(img1);
img1.setImageStream(new ByteArrayInputStream(baos.toByteArray()));
img1.setImageFileType(com.aspose.pdf.ImageFileType.Jpeg);
}
pdf1.save("aspose.pdf");
iis.close();
Hi Stanislava,
Document pdf1 = new Document();<o:p></o:p>
com.aspose.pdf.Page sec1 = pdf1.getPages().add();
// iterate through each TIFF frame
for (int i = 0; i <frameCount; ++i)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(ir.read(i), "jpg", baos);
baos.flush();
com.aspose.pdf.Image img1 = new com.aspose.pdf.Image();
sec1.getParagraphs().add(img1);
img1.setImageStream(new ByteArrayInputStream(baos.toByteArray()));
//img1.setImageFileType(com.aspose.pdf.ImageFileType.Jpeg);
}
pdf1.save("aspose.pdf");
iis.close();
com.aspose.pdf.Page page = doc.getPages().add();
Thanks a lot for your help!Best regards,
Document pdf = new Document();
com.aspose.imaging.fileformats.tiff.TiffImage tiff = (com.aspose.imaging.fileformats.tiff.TiffImage)com.aspose.imaging.Image.load("D:\\Downloads\\TIFF_100.tif") ;
for (TiffFrame f : tiff.getFrames())
{
com.aspose.pdf.Page page = pdf.getPages().add();
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
page.getParagraphs().add(img);
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setLeft(0);
page.getPageInfo().getMargin().setRight(0);
page.setCropBox(new com.aspose.pdf.Rectangle(0, 0, 400, 400));
ByteArrayOutputStream output = new ByteArrayOutputStream();
{
f.save(output, new JpegOptions());
img.setImageStream(new ByteArrayInputStream(output.toByteArray()));
}
}
pdf.save(myDir + "test11.pdf");
spopovIris:Thank you for your answer. By increasing the JVM heap settings we have improved some performance : using Aspose.PDF for Java 16.10.0 we have 40 sec (agains 1 min) for processing the 200 pages file. Despite this improvement, the performance are worse than using the conversion Tiff frames to Jpg (Java conversion) and then to Pdf (Aspose.Pdf) : the conversion with this method is 18 sec with Aspose.Pdf 16.10.0 and 6,5 with Aspose.Pdf 11.9. Using Aspose.Imaging in this case doesn't imrove the performance because the conversion of tiff frames to images is faster with Java.
spopovIris:We tested your example in a separate project (not in a WebApp). But when we added the property setBlackWhite() of com.aspose.pdf.Image we had the same message ("Insufficient data for an image". ) when opening the generated pdf file with AcrobatReader. No exception in the log.