Hi. I am trying to convert a Multipage TIF file to PDF using Javascript. I have used the following code, but the output is blank:
function convertTIFFMutliToPDF() {
var bytes = qie.readFile('C:\\tif.tif');
var encodedBytes = qie.base64EncodeBytes(bytes);
try{
var license = new com.aspose.words.License();
license.setLicense("Aspose.Words.Product.Family.lic");
var doc = new com.aspose.pdf.Document();
var page = doc.getPages().add();
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setLeft(0);
page.getPageInfo().getMargin().setRight(0);
var image = new com.aspose.pdf.Image();
image.setInNewPage(true);
image.setImageStream(new java.io.ByteArrayInputStream(qie.base64DecodeToBytes(encodedBytes)));
page.getParagraphs().add(image);
doc.save("C:\\Output\\test.pdf");
}catch(Exception)
{
qie.info("Error: " + Exception);
}
}
The code snippet that you shared seems correct except you are setting license for Aspose.Words API and using Aspose.PDF. Please try to set the license for Aspose.PDF and try again. In case issue still persists, please share your sample TIFF file for our reference so that we can test the scenario in our environment and address it accordingly.
Hi. I have an Aspose.Total evaluation licence, which hasn’t worked either. Unfortunately, I can’t share this particular tif file as it contains patient data. Are you able to test my code against a sample tif file with multiple pages you might have please?
It looks like you are not setting license for Aspose.PDF before conversion. We have noticed the evaluation message in the output PDF that you shared. Please try to use the license and convert again. For your kind reference, attached are the sample TIFF and output PDF files that we used in our environment. Files.zip (280.0 KB)
Hi. Thanks for the sample file. It seems to work OK for me too. The problem file that I have contains personal data; I am trying to get permission to share these privately with the Aspose support team.
In the meantime, I have attached a screenshot of the properties of the file.
Thanks for sharing the screenshot. However, we do need sample file to carry out the investigation properly. Please share it as soon as you have enough permissions and we will continue accordingly.