We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to convert pdf to docx

I am using below code to convert pdf input stream to Docx format. its working in windows.
But its giving below error in linux.

     com.aspose.pdf.Document document = new com.aspose.pdf.Document(inputStream);                  
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      document.save( outputStream, com.aspose.pdf.SaveFormat.DocX );        

Error:
Cannot find any fonts installed on the system.
com.aspose.pdf.internal.ms.System.I174
com.aspose.pdf.internal.l57l.I17.lif(Unknown Source)
com.aspose.pdf.internal.l57l.I17.lif(Unknown Source)
com.aspose.pdf.internal.l57l.I17.lif(Unknown Source)
com.aspose.pdf.internal.l357.Il.lI(Unknown Source)
com.aspose.pdf.internal.l357.Il.lIF(Unknown Source)
com.aspose.pdf.internal.l344.I01.l1(Unknown Source)
com.aspose.pdf.internal.l344.I01.lif(Unknown Source)
com.aspose.pdf.internal.l344.I04.lI(Unknown Source)
com.aspose.pdf.internal.l344.I04.lif(Unknown Source)
com.aspose.pdf.internal.l344.I04.lif(Unknown Source)
com.aspose.pdf.internal.l344.I4.lif(Unknown Source)
com.aspose.pdf.internal.l34l.I7.lif(Unknown Source)
com.aspose.pdf.internal.l34l.I7.lif(Unknown Source)
com.aspose.pdf.internal.l34l.I7.lif(Unknown Source)
com.aspose.pdf.internal.l347.II.lif(Unknown Source)
com.aspose.pdf.internal.l3l.Il.lif(Unknown Source)
com.aspose.pdf.I104.lif(Unknown Source)
com.aspose.pdf.I104.lif(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.ADocument.ll(Unknown Source)
com.aspose.pdf.Document.ll(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)

@nyanamadala900014

Thank you for contacting support.

Please note Aspose.PDF for Java API needs to access fonts while working with documents. You may install MS Core fonts. Otherwise you may specify path to local fonts or connect custom fonts directory as under:

// Before initilaizing Document object
com.aspose.pdf.Document.addLocalFontPath("/home/farhan/Pdf/test/fonts/"); 

or you can connect custom directory:

// connect custom font directory
com.aspose.pdf.FolderFontSource fs = new FolderFontSource("path/to/my/folder");
FontRepository.getSources().add(fs);

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thanks for your reply.
I added a fonts folder in my project resource folder and copied some font files. Now i want to load all the fonts which are in my fonts folder using the below code but its not working. Is anything wrong with my code.

com.aspose.pdf.Document.addLocalFontPath("/fonts");

@nyanamadala900014

Please try to install MS Core fonts and check if custom font directory works. Also try to specify complete classified path to the folder and then share your kind feedback with us. These approaches will hopefully work because the API is compatible with Linux.