Hi Team, We are trying to covert TIF File to PDF using Aspose Total, Aspose PDF. But, the result is not as expected. Image is shrinked and is showing as line.
Aspose PDF version : 25.7
Current JDK : 21-jre-alpine
vertopalSample50kb.pdf (100.4 KB)
Hi Team, We are trying to covert TIF File to PDF using Aspose Total, Aspose PDF. But, the result is not as expected. Image is shrinked and is showing as line.
Aspose PDF version : 25.7
Current JDK : 21-jre-alpine
vertopalSample50kb.pdf (100.4 KB)
It sounds like you’re experiencing an issue where the TIF image is being converted to a PDF-A-1B format but appears as a line instead of the expected image. This can happen due to several reasons, such as incorrect image dimensions or issues with the image stream.
Cause: The problem may stem from incorrect image dimensions, a mismatch between the PDF page size and the image size, or issues with how the image stream is initialized.
Solution: Here are some steps you can take to troubleshoot and resolve the issue:
Check Image Dimensions: Ensure that the dimensions of the TIF image are correctly set before adding it to the PDF. Verify that the width and height of the image are not zero or too small.
Set Page Size: Make sure that the page size of the PDF document matches the dimensions of the image. You can set the page size using the pdfPage.setPageSize(width, height);
method.
Image Stream: Confirm that the image stream is correctly initialized and that the TIF image is being read properly. Check if the input stream is valid and contains the expected data.
Use TiffImage Class: If you are not already doing so, consider using the TiffImage
class from the Aspose.Imaging library to load the TIF image. This class provides more control over TIF images and can help ensure that the image is processed correctly.
Update Aspose Libraries: Since you are using an older version of Aspose.PDF (25.7), consider updating to the latest version. There may have been bug fixes or improvements related to TIF to PDF conversions.
Next Steps: Here’s a minimal code snippet to illustrate how you might load a TIF image and convert it to PDF:
// Load the TIF image
TiffImage tiffImage = (TiffImage) Image.load(inputStream);
// Create a new PDF document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document();
Page pdfPage = pdfDocument.getPages().add();
// Set the page size to match the TIF image dimensions
pdfPage.setPageSize(tiffImage.getWidth(), tiffImage.getHeight());
// Create an image object and set the image stream
com.aspose.pdf.Image immg = new com.aspose.pdf.Image();
immg.setImageStream(new ByteArrayInputStream(tiffImage.saveToStream().toByteArray()));
// Add the image to the PDF page
pdfPage.getParagraphs().add(immg);
// Validate and convert to PDF-A-1B
pdfDocument.validate("Validation_log.xml", PdfFormat.PDF_A_1B);
pdfDocument.convert("Conversion_log.xml", PdfFormat.PDF_A_1B, ConvertErrorAction.None);
Try these steps and see if they help resolve the issue. If the problem persists, please provide any error messages or additional details, and I will be happy to assist you further!
The TIF image is given as string of filecontent
Would you please share your sample TIFF image along with the sample code snippet that you have been using? We will test the scenario in our environment and address it accordingly.