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

Free Support Forum - aspose.com

Get a missing pages PDF file after transform from an existed word file

Hi there,

I got missing pages problem when I transform existed word file to pdf format.
The detail steps are shown below

Step 1. Use word template file to generate temp word file.
Step 2. Transform generated temp word file to PDF.

In step 1, I just want to check whether or not the mail merge works and it does work. But in step 2, I get a missing pages PDF.
Does anyone get this problem before ? How could I get the right PDF file ?

All related files are enclosed.
CAAML_natural.docx is the template file;
CAAML_natural_tmp.docx is the generated temp file;
CAAML_natural.pdf is the missing pages file.

My testing code is:
public static void main(String… args) throws Exception {
Document doc = new Document(getMyDir() + “CAAML_natural.docx”);
final String[] keysArray = {“background”};
final Object[] valuesArray = {testStr2};
final FormFieldCollection formFields = doc.getRange().getFormFields();

for (final FormField field : formFields) {
if (“background”.equals(field.getName())) {
field.setResult(testStr2);
}
}
doc.getMailMergeSettings().setViewMergedData(true);

doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
doc.getMailMerge().execute(keysArray, valuesArray);

doc.save(getMyDir() + “CAAML_natural_tmp.docx”, SaveFormat.DOCX);

Document doc2 = new Document(getMyDir() + “CAAML_natural_tmp.docx”);
System.out.println(“doc2.getPageCount():” + doc2.getPageCount());
doc2.save(getMyDir() + “CAAML_natural.pdf”, SaveFormat.PDF);
}

I’ve checked how to apply formatting on the row level in the online, the url link: http://www.aspose.com/docs/display/wordsjava/Applying+Formatting+on+the+Row+Level, and it works when I save the document as word format.


But why it does not work when saving the document as pdf format ?

Hi there,

Thanks for your inquiry. You are using Aspose.Words without license. Please note that in evaluation mode there are some limitations applied. E.g. Aspose.Words injects an evaluation watermark at the top of the document. The document's content are truncated after a certain number of paragraphs during import or export.

Please request for temporary license from here:
Get temporary license

Please read about applying license from here:
Applying a License

We suggest you please upgrade to the latest version of Aspose.Words for Java 16.1.0 and let us know how it goes on your side. If you still face problem, please share the value of testStr2 variable which you are using at your side. We will investigate the issue on our side and provide you more information on this.
Hi

I've applied license and re-run the application, but the difference between the new result and previous result is that I do not get the "evaluation only" wording this time.

What matters is not the value of testStr2, but its length. If the length of testStr2 can be contained in 2 pages, then everything works fine. However, if the testStr is so long that it cannot be contained in 2 pages, then the problem will occur.

You can refer to the enclosed CAAML_natral_tmp.docx to see the column that has a lot of 'd' characters in it.
Hi there,

Thanks for your inquiry. We have tested the scenario at Windows 7, Jdk 1.8 and have not found the shared issue. Please check the attached output documents and testStr2.txt for testStr2 value.

Could you please share your environment detail e.g. operating system, Jdk version (32 bit or 64 bit)? We will investigate the issue on our side and provide you more information.
Hi,
My environment is Windows 7, jdk 1.6.0_45 64 bit.
I set your testStr2 value as my testStr2's value. I get worse result. The value is gone when saving as PDF file. You can see enclosed files for further information.
Hi there,

Thanks for your inquiry.
Hugh Yang:
I set your testStr2 value as my testStr2's value. I get worse result. The value is gone when saving as PDF file. You can see enclosed files for further information.
We tested the scenario using latest version of Aspose.Words for Java 16.1.0 and have not found the shared issue. Please check the output Pdf document from my previous post. We would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. Hope, this helps.
Hugh Yang:
I've checked how to apply formatting on the row level in the online, the url link: http://www.aspose.com/docs/display/wordsjava/Applying+Formatting+on+the+Row+Level, and it works when I save the document as word format.
Could you please share which row level formatting you applied before exporting document to Pdf? We will then provide you more information on this query. Moreover, please share the value of testStr2 which you are using at your side here for further testing. We will investigate the issue and provide you more information.