We have purchased the aspose for java, I am trying to covert Tif to searchable pdf. have followed the instructions to install jai-1_1_3-lib-windows-i586.exe, but 0 size PDF generated.
Hi Zhang,
As requested, Please see the attached docs. FYI, Noticed that bufferImage object is null when i print this object. No sure if this is the cause
Hi Zhang,
aspose.pdf.Pdf pdf1 = new
aspose.pdf.Pdf();<o:p></o:p>
aspose.pdf.Section sec1 = pdf1.getSections().add();
aspose.pdf.Image image = new aspose.pdf.Image(sec1);
// java.net.URL url = new java.net.URL("file:///D:/pdftest/TIF.tif");
//BufferedImage bufferImage=ImageIO.read(url);
image.getImageInfo().setFile("D:/pdftest/TIF.tif");
image.getImageInfo().setTiffFrame(-1);
image.getImageInfo().setImageFileType(aspose.pdf.ImageFileType.Tiff);
sec1.getParagraphs().add(image);
pdf1.save(“c:/pdftest/TIFF_Coverted.pdf”);
// instantiate Document object<o:p></o:p>
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
// add page to PDF file
doc.getPages().add();
// create Image object
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
// load TIFF image
img.setFile("c:/pdftest/TIF.tif");
// add image to paragraphs collection of first page
doc.getPages().get_Item(1).getParagraphs().add(img);
// save resultant PDF
doc.save(“c:/pdftest/DOM_Approach.pdf”);
Great, It works for me. Thanks a lot for your help.
Hi Zhang,
The DOM approach handles multipage tiff to multipage pdf. But what I am getting now that my 1bpp Tiff file all pages CCITT4 compression is being converted to PDF with color. Can I control that by querying Tags within the tiff file and setting save options?
Hi Mike,
// instantiate Document object<o:p></o:p>
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
// add page to PDF file
doc.getPages().add();
// create Image object
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
// load TIFF image
img.setFile(myDir+"3pagetiff.tif");
// add image to paragraphs collection of first page
doc.getPages().get_Item(1).getParagraphs().add(img);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// save resultant PDF
doc.save(outputStream);
doc= new Document(new ByteArrayInputStream(outputStream.toByteArray()));
Document.OptimizationOptions opt = new Document.OptimizationOptions();
opt.setRemoveUnusedObjects ( false );
opt.setLinkDuplcateStreams ( false );
opt.setRemoveUnusedStreams ( false );
// Enable image compression
opt.setCompressImages ( true );
// Set the quality of images in PDF file
opt.setImageQuality (10);
doc.optimizeResources(opt);
doc.save(myDir+"DOM_Approach_opt.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
Is there a way to query the Tags in the Tiff image. The original 3pagetiff.tif file uses 1 bit per pixel. When the above approach completes the conversion to PDF 24 bit per pixel has been introduced. I would like the resulting PDF to still use 1 bit per pixel. So the resulting PDF is still about 9 times larger than it should be.
So 2 questions:
1. Can I query the Tiff Tags?
2. Can I use those results when saving the PDF?
Is querying Tiff Tags only available using Aspose.Imaging? Goal is to convert Tiff to PDF, but if the Tiff is CCITT4 compression 1bpp then the PDF should also use only 1bpp.
Hi Mike,Mike.Oakley:Is there a way to query the Tags in the Tiff image. The original 3pagetiff.tif file uses 1 bit per pixel. When the above approach completes the conversion to PDF 24 bit per pixel has been introduced. I would like the resulting PDF to still use 1 bit per pixel. So the resulting PDF is still about 9 times larger than it should be.So 2 questions:
- Can I query the Tiff Tags?
- Can I use those results when saving the PDF?
Is querying Tiff Tags only available using Aspose.Imaging? Goal is to convert Tiff to PDF, but if the Tiff is CCITT4 compression 1bpp then the PDF should also use only 1bpp.