Free Support Forum - aspose.com

Strange behavior when convert pdf to doc

Hello,


I’m using simple code for converting pdf to doc:

Document pdfDocument = new Document(“path_to_pdf”);
pdfDocument.save(“path_to_save_doc”, SaveFormat.Doc);


I try convert 2 pdf files:
1. liferay-portlet-development.pdf
2. Portal_Prep_Guide.pdf



When I convert second file I have got error in this line: pdfDocument.save(“path_to_save_doc”, SaveFormat.Doc);

java.lang.NullPointerException
at com.aspose.pdf.internal.p654.z29.m27(Unknown Source)
at com.aspose.pdf.internal.p643.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p643.z5.m1(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m3(Unknown Source)
at com.aspose.pdf.internal.p633.z7.m4(Unknown Source)

but when I convert first file everything is fine

Bot files in attachment.
p.s. I use trial version and don’t add license key

Could you help me please?

Hi Yury,


Thanks for using our API’s.

I have tested the scenario using Aspose.Pdf for Java 10.6.1 in Eclipse Juno application running over Windows 7 (x64) with JDK 1.7 and I am unable to notice any issue. For your reference, I have also attached the documents generated over my end.

[Java]

Document pdfDocument = new Document(“c:/pdftest/Portal_Prep_Guide.pdf”);<o:p></o:p>

pdfDocument.save(“c:/pdftest/Portal_Prep_Guide_path_to_save.doc”,
com.aspose.pdf.SaveFormat.
Doc);

Thank you for your response.


I’m running code on tomcat 7 (win7 64) and it works fine. But when I try to run application on CentOS I have got error as in my first post.
Do you have any suggestions?

Hi Yury,


Thanks for your inquiry, Please note on non-windows OSs issue caused due to font folder path setting. For example, at my machine Ubuntu 13.10 I have installed Microsoft fonts and set font folder path as following. You need to set font folder path according to your machine setting, it will resolve the issue.

sudo apt-get install ttf-mscorefonts-installer

// Set font folder path
String path = “/usr/share/fonts/truetype/msttcorefonts/”;
// Adding a single font directory
// com.aspose.pdf.Document.addLocalFontPath(path);

// seting the user list for standard font directories
java.util.List list = com.aspose.pdf.Document.getLocalFontPaths();
list.add(path);

com.aspose.pdf.Document.setLocalFontPaths(list);



Please feel free to contact us for any further assistance.

Best Regards,

Thank you, it helped me.


Could you explain one more question?
After converting PDF to DOC, I got .doc file which contains textbox.
Textbox I mean like the screenshot in attachment.

Could you help me, how I can get text instead textbox?

Also, I get after convertation text:

Evaluation Only. Created with Aspose.Pdf. Copyright 2002-2015 Aspose Pty Ltd.

How I can switch off this text message?


Thank you very much,
Yury

Hi Yury,


In order to get/update form field values, please following the instructions specified over


Now concerning to evaluation watermark issue, it appears that you are using the API in Trial mode. I would suggest you to please request a 30 days temporary license to test the API without any limitations. Once you have evaluated the API, then you may consider purchasing the license. For further details, please visit

Hi,


Thank you for your reply,
I attached screenshot again, my question was about text in .doc file after convert place in box. Look my screen in attachment.

Can I to do with it something or so aspose library convert file?


Thank you.

Hi Yury,


Thanks for providing additional information. Please check DocSaveOptions object detail, It seems you are using TextBox RecoginitionMode so it converts PDF to DOC in form text boxes to preserve the formatting as much as possible. Please use Flow document keeps the flow of original document. Please find attached sample output, hopefully it will fulfill your requirements.


Document doc = new Document(myDir+“Portal_Prep_Guide.pdf”);<o:p></o:p>

// Instantiate Doc SaveOptions instance

DocSaveOptions saveOptions = new DocSaveOptions();

// Set output file format as DOCX

saveOptions.setFormat(DocSaveOptions.DocFormat.Doc);

saveOptions.setMode(DocSaveOptions.RecognitionMode.Flow);

// Save resultant DOCX file

doc.save(myDir+"Portal_Prep_Guide_flow.doc", saveOptions);


Please feel free to contact us for any further assistance.


Best Regards,