DocumentBuilder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE) does not work for PDF output

I use the following Code:


private DocumentBuilder mBuilder = null;

and later after assigning a DocumentBuilder

mBuilder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE)

When generating output in DOC and DOCX-Format it works fine, I get separate pages. But when saving in PDF format the page break is missing. Also page numbering is incorrect due to missing section breaks.

I use
Document.save(…)

My Version is 14.1.0.0 from 2014.01.31.

Is this a bug or am I using wrong features?


kind regards

Mario







Hi Mario,


Thanks for your inquiry.

I am afraid, while using the latest version of Aspose.Words for Java i.e. 14.3.0 and the following code, I was unable to reproduce this issue on my side.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln(“Before break”);
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.writeln(“After break”);

doc.save(“C:\Temp\out.docx”);
doc.save(“C:\Temp\out.pdf”);

I have attached the output PDF i.e. generated on my side here for your reference. So, I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link:
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/default.aspx

In case the problem still remains, please share your complete code to reproduce this issue on our end. Also, please attach your output PDF file which shows the undesired behavior here for testing. We will investigate the issue further on our end and provide you more information.

Best regards,

Tahnk you,


I downloaded th elatest version and copiled the project, but there is no change.
unfortunately I can’t send you the documents due to cutomer related data.


please find attached the code for the affected report. MAy be you see the issue.

However:
saving in Word (DOCX) works fine, pdf does not.


kind regards

Mario

Hi Mario,


Thanks for sharing your code. Unfortunately, it is difficult to say what the problem is without the input/output documents. We need these documents (Word/PDF files) to reproduce the problem on our end. Please note that it is safe to attach files in the forum. If you attach your documents here, only you and Aspose staff members can download it. Also you can send the files to my e-mail as described here:
http://www.aspose.com/corporate/purchase/faqs/send-license-to-aspose-staff.aspx
Best regards,

Please find attached a ZIP file containing:


1)report.pdf - generated PDF Report
2)report.doc - generated DOC Report
3)Dosisnachweis_BHB-Template.docx - template used for generation
4) Dosisnachweis_BHB.java - class file used for generation (including field call back)
5) ReportBase.java - base class for 4)

Please consider the following:
1) the only difference between 1) and 2) is the parameter in the save procedure
2) It seens the callback function for formatting is not reached (“Hello World” is missing in PDF output), but when running in debugger I can step into the callback function. I’ am puzzled.

I would be happy to have an Idea about a solution.

Thanks in advance!

kind regards

Mario

Hi Mario,


Thanks for the additional information. Unfortunately, at the moment, we’re not able to reproduce this issue on our end because some bits of code are missing from your shared code (e.g. nis.wordreportgenerator.DBUtils, nis.wordreportgenerator.XMLResource are missing). We suggest you please create a standalone runnable simple Java application that helps us reproduce the same problem on our end and attach it here for testing. As soon as you get this application ready, we’ll investigate the issue further and provide you more information. Also, please attach the XML file you’re using as data source (and any other resources required to reproduce the issue on our end) here for testing. Thanks for your cooperation.

Best regards,