Pdf to image conversion in Linux

Hi,

Below is the error that is occurring when trying to convert
PDF document into Images using Aspose API on Linux. Same code is working fine
on windows.

at com.aspose.ms.System.a.f.get_Item(Unknown Source)
at com.aspose.pdf.a.b.e.b.d.a(Unknown Source)
at com.aspose.pdf.a.e.a.a(Unknown Source)
at com.aspose.pdf.a.j.b.g.a(Unknown Source)
at com.aspose.pdf.a.j.h.a(Unknown Source)
at com.aspose.pdf.Z.a(Unknown Source)
at com.aspose.pdf.TiffDevice.processInternal(Unknown Source)
at com.aspose.pdf.TiffDevice.process(Unknown Source) at com.aspose.ms.System.a.f.get_Item(Unknown Source)
at com.aspose.pdf.a.b.e.b.d.a(Unknown Source)
at com.aspose.pdf.a.e.a.a(Unknown Source)
at com.aspose.pdf.a.j.b.g.a(Unknown Source)
at com.aspose.pdf.a.j.h.a(Unknown Source)
at com.aspose.pdf.Z.a(Unknown Source)
at com.aspose.pdf.TiffDevice.processInternal(Unknown Source)
at com.aspose.pdf.TiffDevice.process(Unknown Source)

I am using Aspose.pdf 4.2.0.

Below is the code for the same.

com.aspose.pdf.Resolution resolution =

new com.aspose.pdf.Resolution(

300);

// Create a thumbnail image (100x100)

com.aspose.pdf.facades.PageSize thumbnailPageSize =

new com.aspose.pdf.facades.PageSize(

24f, 24f);

// 100 x 100

com.aspose.pdf.TiffDevice thumbnailTiffDevice =

new com.aspose.pdf.TiffDevice(

thumbnailPageSize, resolution);

ByteArrayOutputStream thumbnailPageOutputStream =

new ByteArrayOutputStream();

thumbnailTiffDevice.process(pdfDocument, pageIndex, pageIndex,

thumbnailPageOutputStream);

com.aspose.pdf.Resolution resolution =

new com.aspose.pdf.Resolution(

300);

// Create a thumbnail image (100x100)

com.aspose.pdf.facades.PageSize thumbnailPageSize =

new com.aspose.pdf.facades.PageSize(

24f, 24f);

// 100 x 100

com.aspose.pdf.TiffDevice thumbnailTiffDevice =

new com.aspose.pdf.TiffDevice(

thumbnailPageSize, resolution);

ByteArrayOutputStream thumbnailPageOutputStream =

new ByteArrayOutputStream();

thumbnailTiffDevice.process(pdfDocument, pageIndex, pageIndex,

thumbnailPageOutputStream);

I have attached the test document.

Hi Sarika,

Thanks for your inquiry. I have investigated the scenario and found that you need to set font folder path before the processing. Please check following code snippet for the purpose, hopefully it will help you to accomplish the task.

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(
“TestPdf.pdf”);
// Set font folder path
String path = “/usr/share/fonts/truetype/msttcorefonts/”;
// String path = “/usr/share/fonts/truetype/freefont/”;
// Adding a font directory
com.aspose.pdf.Document.addLocalFontPath(path);
com.aspose.pdf.devices.Resolution resolution =

new com.aspose.pdf.devices.Resolution(

300);

// Create a thumbnail image (100x100)

com.aspose.pdf.PageSize thumbnailPageSize =

new com.aspose.pdf.PageSize(

24f, 24f);

// 100 x 100

com.aspose.pdf.devices.TiffDevice thumbnailTiffDevice =

new com.aspose.pdf.devices.TiffDevice(

thumbnailPageSize, resolution);

ByteArrayOutputStream thumbnailPageOutputStream =

new ByteArrayOutputStream();

thumbnailTiffDevice.process(pdfDocument, 1, 3,

thumbnailPageOutputStream);

Please feel free to contact us for any further assistance.

Best Regards,

Hi,

Thanks for the quick response. But I dont see any method like addLocalFontPath in Document class. Can you please suggest.

Regards,

Sarika Bansal

Hi Sarika,


Thanks for your feedback. I have used Aspose.Pdf for Java 4.6.0 for testing the scenario. Please download and try latest version of Aspose.Pdf for Java, it will help you to fix the issue.

Please feel free to contact us for any further assistance.

Best Regards,

Hi,

Thanks for your response.

I got the latest version and updated the code but the path that you have mentioned for font path is it something we need to install in linnux because I am not able to find out the location in linux.

Regards,

Sarika Bansal

Hi Sarika,


Thanks for your feedback. Actually I have set font folder path according to my system path, you also need to set font folder path as per you system path. I have used Microsoft fonts for the testing. You may install these as following.

sudo apt-get install msttcorefonts

Please feel free to contact us for any further assistance.

Best Regards,

Hi,

This is working now I am able to read the pdf after setting font path on linux.

but the image that is getting created does not show the correct content.

Please suggest.

Regards,

Sarika Bansal

Hi Sarika,


Thanks for your feedback. we are looking into issue and will get back to you soon.

Best Regards,

Hi sarika,


Thanks for your inquiry. We have tested the scenario over Ubuntu 13.10 using Microsoft fonts as shared in above code snippet and unable to replicate the issue. It seems it is font related issue at your machine. Can you please test the scenario with Microsoft fonts and share the results? So we will investigate it further.

sudo apt-get install ttf-mscorefonts-installer

We are sorry for the inconvenience caused.

Best Regards,

Hey,

Thanks a lot this is working perfectly now.

Regards,

Sarika Bansal

Hi Sarika,


Thanks for your feedback. It is good to know that you have managed to resolve your issue.

Please feel free to contact us for any further assistance, we will be more than happy to extend our support.

Best Regards,

Hi.

Again I am facing the same issue. I am not able to convert pdf to images.belwo is the error.

com.aspose.ms.System.d.u.a(Unknown Source)
com.aspose.ms.System.d.u.c(Unknown Source)
com.aspose.ms.System.d.u.(Unknown Source)
com.aspose.pdf.b.k.b.h.(Unknown Source)
com.aspose.pdf.b.k.k.a(Unknown Source)
com.aspose.pdf.b.c.e.b.f.(Unknown Source)
com.aspose.pdf.b.f.b.b(Unknown Source)
com.aspose.pdf.b.c.e.b.c.k.a(Unknown Source)
com.aspose.pdf.devices.d.a(Unknown Source)
com.aspose.pdf.devices.d.cTs(Unknown Source)
com.aspose.pdf.devices.TiffDevice.processInternal(Unknown Source)
com.aspose.pdf.devices.TiffDevice.process(Unknown Source)v

Please help

Hi Sarika,


Thanks for contacting support. Please share that you are facing issue with particular PDF files or this problem is appearing for all the documents. if the case is related to some particular PDF files, please share the documents so that we can test the scenario at our end. We are sorry for this inconvenience.


This problem is appearing for all the documents. Still I am attaching a sample document.

I am using Linux OS and weblogic Web server.

fonts are already installed in linux server and path is included in localfontpath.

Hi Sarika,


Thanks for your patience.

I have tested the scenario using Aspose.Pdf for Java 9.3.0 over Red Hat Enterprise Linux Server release 5.7 (Tikanga) where I have JDK 1.6 and I am unable to notice any issue. The PDF file is properly being converted to TIFF format. Can you please try using the latest release and in case you still face the same issue, please share some details regarding your working environment. We are sorry for this inconvenience.