Delete the last Page Break

Last post 10-05-2010, 7:52 AM by alexey.noskov. 7 replies.
Sort Posts: Previous Next
  •  06-14-2010, 5:20 AM 243206

    Delete the last Page Break .NET

    There is a requirement for me to delete the last page break that is inserted in the document section. How do I do that?
     
  •  06-14-2010, 7:50 AM 243230 in reply to 243206

    Re: Delete the last Page Break

    Hello

     

    Thanks for your inquiry. Could you please attach your input document here for testing? We will check it and provide you more information.

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  06-14-2010, 9:11 AM 243264 in reply to 243230

    Re: Delete the last Page Break

    Hi,

    Please use the code below, it should remove the last page break in a document.

    NodeCollection runs = doc.LastSection.GetChildNodes(NodeType.Run, true);

    // Find the runs that contain the last page break characters in this section and remove the character.

    for(int i = runs.Count-1; i >= 0; i--)

    {

       Run run = (Run)runs[i];

       if(run.Text.IndexOf(ControlChar.PageBreakChar) >= 0)

       {

          run.Text = run.Text.Remove(run.Text.IndexOf(ControlChar.PageBreakChar), 1);

          break;

       }

    }

    If you need any futher help then please feel free to ask.

    Thanks,


    Adam Skelton
    Programming Writer
    Aspose Auckland Team
     
  •  06-15-2010, 2:25 AM 243404 in reply to 243264

    Re: Delete the last Page Break

    Great!!! Thanks for your inputs. It works like charm.

     
  •  10-05-2010, 5:50 AM 261936 in reply to 243264

    Re: Delete the last Page Break .NET

    Hello,

    We use Aspose.Words 9.4
    The mentioned code doesn't work.
    Do you have an advice?

    Friendly Greetings,
    Pieter
    (The Netherlands)

    Filed under: .NET aspose.words
     
  •  10-05-2010, 6:09 AM 261941 in reply to 261936

    Re: Delete the last Page Break

    Hi Pieter,

    Thanks for your inquiry.

    Can you attach your documents here for testing? Most likely the break in your document is actually a section break and not a page break.

    Thanks,


    Adam Skelton
    Programming Writer
    Aspose Auckland Team
     
  •  10-05-2010, 7:42 AM 261956 in reply to 261941

    Re: Delete the last Page Break .NET

    Attachment: Present (inaccessible)

    Hello,

    Hereby the document before mailmerge and the document after mailmerge.

    With friendly greetings,
    Pieter

     
  •  10-05-2010, 7:52 AM 261960 in reply to 261956

    Re: Delete the last Page Break

    Attachment: Present (inaccessible)

    Hi

     

    Thanks for your inquiry. If it is acceptable for you , you can resolve the problem by small modification of your template (just disable “Page Break Before” option of the penultimate paragraph). Please try using the attached template.

     

    Hope this helps.

     

    Best regards,


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
View as RSS news feed in XML