Page contains continuous section, first para in section has “keep with next” and “keep with next” is not being enforced during Word save as PDF

@awais.hafeez, @schappa

Hi, We’re having the same problem.

We just moved from AsposeWords.Net 17.9.0 to 20.2.0. We have hundreds of documents that contain, sometimes multiple instances, of the situation described for WORDSNET-19699 (page contains continuous section, first para in section has “keep with next” and “keep with next” is not being enforced during save as PDF).

Can you please let us know what the latest version of AsposeWords.Net WITHOUT this issue is?
Can we get any idea of when this situation might be addressed?
Could you suggest a viable work-around for the time being.

Thanks in advance for your help with this issue,
Jeff

@JDiamond,

Please ZIP and attach the following resources here for testing:

  • Your simplified input Word document you are getting this problem with
  • Aspose.Words 20.2 generated PDF file showing the undesired behavior.
  • Please also provide a comparison screenshot highlighting the problematic areas in Aspose.Words 20.2 generated PDF (with respect to MS Word’s output)

As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you more information. Thanks for your cooperation.

Awais,

Thanks for your quick reply to our issue.

The uploaded Zip file, “AsposeKeepTogetherTest.zip” contains the following:

  • InputTestDocument.docx simplified source Word document

  • OutputTestDocument_AsposeVer17-9-0.pdf output file showing desired result generated with ver 17.9.0

  • OutputTestDocument_AsposeVer20-2-0.pdf output file showing unwanted result generated with ver 20.2.0

  • ScreenCaptureGoodVsBad.PNG comparison screenshot highlighting the problematic area

  • Simple “AsposeKeepTogetherTest” VS2019/VB.Net/WinForm solution that we built to demonstrate the issue. The solution contains 2 projects (KeepTogetherTest_AsposeVer17-9-0 & KeepTogetherTest_AsposeVer20-2-0). Note to run an Aspose license file is needed, Nuget pakages for Aspose ver 17-9-0 & ver 20-2-0 need to be added to (859.8 KB)
    corresponding projects & adjustment to the “TestPath” variable for your environment.

Thanks again for your help,
Jeff

AsposeKeepTogetherTest.zip

@JDiamond,

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. The ID of this issue is WORDSNET-20054. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Awais,

We can report that this problem (WORDSNET-20054) persists in Aspose.Words for .NET version 20.3 and have developed a temporary work-around for the issue. We call the following code just prior to exporting to PDF:

*Private Sub PdfKeepTogetherBugWorkAround(srcDoc As Aspose.Words.Document)*
  •    'Loop through all sections in the source document.*
    
  •    For Each srcSection As Section In srcDoc.Sections*
    
  •        Dim para As Paragraph = srcSection.Body.FirstParagraph*
    
  •        If Not para.IsEndOfSection AndAlso para.ParagraphFormat.KeepWithNext = True Then*
    
  •            ' insert new empty & hidden 1st paragraph in section*
    
  •            ' now 1st para in section IS NOT Keep-With-Next *
    
  •            Dim newFirstPara As Paragraph = New Paragraph(srcDoc)*
    
  •            newFirstPara.ParagraphBreakFont.Hidden = True*
    
  •            newFirstPara.ParagraphBreakFont.Color = Color.Orange*
    
  •            srcSection.Body.PrependChild(newFirstPara)*
    
  •        End If*
    
  •    Next srcSection*
    
  • End Sub*


Although our testing is not complete, in our specific environment, this work-around seems to resolve the issue without any negative side effects.

We are still anxious for an Aspose provided fix, please keep us up to date on when that fix can be expected.

Thanks again for your help,
Jeff

@JDiamond,

We have logged these details in our issue tracking system. There is no ETA available at the moment. But, we will inform you via this thread as soon as this issue will be resolved or any estimates may be available in future. We apologize for any inconvenience.

@JDiamond,

Regarding WORDSNET-20054, it is to update you that we are currently working on this issue and can provide you a rough ETA of 20.4 i.e. if everything goes by plan, we are hopeful to include the fix to your issue in Aspose.Words’ 20.4 release (next version). We will keep you posted here on any more updates.

Thanks very much for the update. We look forward to testing the new release.

The issues you have found earlier (filed as WORDSNET-20054) have been fixed in this Aspose.Words for .NET 20.4 update and this Aspose.Words for Java 20.4 update.