Free Support Forum - aspose.com

Continuous break is converted to Page break

Hi Team,


With Aspose.Words for Java 15.6, a continuous break is converted to Page break. The word document in Aspose 15.5 is good.

See attached code and documents.

Thanks,
Kumar

public class TestMultipart
{
public static void main(String[] args) throws Exception
{
TestAsposeUtils.setupLicense(TestAsposeUtils.LICENSE_FILE_PATH);
Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);
writeDocWithBreaks(docBuilder);
int count = doc.getSections().getCount();
int currentSectionIndex = 0;
java.util.List serializedParts = new ArrayList();
java.util.List sectionList = new ArrayList();
boolean continueLoop = true;
while (continueLoop)
{
Section section = doc.getFirstSection();
if (count == 1)
{
docBuilder.moveToDocumentEnd();
docBuilder.insertBreak(BreakType.SECTION_BREAK_CONTINUOUS);
docBuilder.getCurrentSection().getPageSetup().setOrientation(Orientation.PORTRAIT);
continueLoop = false;
}
sectionList.add(section);
doc.getFirstSection().remove();

count = doc.getSections().getCount();
if (count == 1)
{
Document partDocument = new Document();
addSectionsToPartDocument(sectionList, partDocument);
String partPath = “c:/ref_” + currentSectionIndex++ + “.doc”;
int sectionstart = partDocument.getFirstSection().getPageSetup().getSectionStart();
partDocument.getFirstSection().remove();
partDocument.getFirstSection().getPageSetup().setSectionStart(sectionstart);
partDocument.save(partPath);
serializedParts.add(partPath);
sectionList = new ArrayList();
}
}
for (String path : serializedParts)
{
insertIncludeTextField(docBuilder, path);
docBuilder.writeln();
}

doc.updateFields();
TestAsposeUtils.save(doc);

System.out.println(“done”);
}

private static void addSectionsToPartDocument(List sectionsList, Document partDocument) throws Exception
{
for (Section section : sectionsList)
{
Node dstSection = partDocument.importNode(section, true, ImportFormatMode.KEEP_SOURCE_FORMATTING);
partDocument.getSections().add(dstSection);
}
}

private static void insertIncludeTextField(DocumentBuilder docBuilder, String path) throws Exception
{
String field = “INCLUDETEXT “” \* MERGEFORMAT”; //$NON-NLS-1$
field = field.replace("", path); //$NON-NLS-1$
docBuilder.insertField(field, “”); //$NON-NLS-1$
}

private static void writeDocWithBreaks(DocumentBuilder docBuilder) throws Exception
{
// section 1 - ref_0.doc
docBuilder.write(“Line 1”);
docBuilder.writeln();
docBuilder.write(“1 - before section break new page”);
docBuilder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);

// section 2
docBuilder.write(“2”);
docBuilder.writeln();
docBuilder.write(“Before section break continuous”);
docBuilder.insertBreak(BreakType.SECTION_BREAK_CONTINUOUS);

// section 3 - ref_1.doc
docBuilder.write(“After section break”);

// section 4
docBuilder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
}
}

Hi Kumaraswamy,


Thanks for your inquiry. Please also share the definition of following method:

  • TestAsposeUtils.save

Do you see the same issue when converting to DOCX format. Please attach DOCX outputs generated using both Aspose.Words for Java 15.5.0 and 15.6.0 versions here for our reference. We will investigate the issue on our end and provide you more information.

Best regards,

Hi Awais,


The issue with seen with docx format as well. See attached.

Save is a normal save (doc.save(path))

Thanks,
Kumar

public static void save(Document doc) throws Exception
{
String baseFolder = System.getProperty(“java.io.tmpdir”);
String unique = UUID.randomUUID().toString().replaceAll(" ", “");
String docpath = baseFolder + "test” + unique + “_” + BuildVersionInfo.getVersion(); //$NON-NLS-1$ //$NON-NLS-2$
doc.save(docpath + “.doc”); //$NON-NLS-1$
doc.save(docpath + “.pdf”); //$NON-NLS-1$
System.out.println(docpath + “.doc”);
System.out.println(docpath + “.pdf”);
}
Hi Kumaraswamy,

Thanks for the additional information. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-12104. Our product team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi Awais,


Since this is a regression, I’m expecting a fix for this sooner. Can I expect something this month?

Thanks,
Kumar

Hi Kumar,


Thanks for your inquiry. Yes, our product team is actively working on this issue. We will keep you informed of any developments and let you know once this issue is resolved.

Best regards,

The issues you have found earlier (filed as WORDSNET-12104) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.