
Choose View → Non-printing Characters from the pull down menus (so that the choice is checked).If you still have problems, try the step below: Type Ctrl + End then press ← Backspace until you get back to your content. First make sure that there's really not any extra content.All of my content seems to fit on the previous page. have a blank page in my word processing document. If(textBody.ChildEntities is WTable) break Never remove a page break on a page with a table. private static void RemoveEmptyItems(WTextBody textBody)įor (int itemIndex = - 1 itemIndex >= 0 & !IsRenderableItem itemIndex-) I use the next Code to remove empty page without table. Take a moment to peruse the documentation, where you can find basic Word document processing options along with features like mail merge, merge and split documents, find and replace text in the Word document, protect the Word documents, and most importantly PDF and Image conversions with code examples.Ī empty page should not include a table with visible elements or any table at all. (itemIndex)Ī complete working example of how to remove empty page in Word document in C# can be downloaded from Remove empty page in Word document.zip. 'Remove empty paragraph and the paragraph with bookmarks only 'Found renderable item and break the iteration. If Not (TypeOf paragraphItem Is (TypeOf (BookmarkStart OrElse paragraphItem) Is BookmarkEnd)) Then 'Check paragraph contains any renderable items. If (TypeOf textBody.ChildEntities(itemIndex) Is WParagraph) Thenĭim paragraph As WParagraph = CType(textBody.ChildEntities(itemIndex),WParagraph)ĭim pIndex As Integer = ( - 1)ĭim paragraphItem As ParagraphItem = paragraph.Items(pIndex)ĪndAlso (CType(paragraphItem,Break).BreakType = BreakType.PageBreak))) Then Private Sub RemoveEmptyItems(ByVal textBody As WTextBody) 'Ī flag to determine any renderable item found in the Word document.ĭim itemIndex As Integer = ( - 1) Remove empty paragraph and the paragraph with bookmarks only Found renderable item and break the iteration. Check paragraph contains any renderable items.Įlse if (!(paragraphItem is BookmarkStart || paragraphItem is BookmarkEnd)) If ((paragraphItem is Break & (paragraphItem as Break).BreakType = BreakType.PageBreak)) ParagraphItem paragraphItem = paragraph.Items WParagraph paragraph = textBody.ChildEntities as WParagraph įor (int pIndex = - 1 pIndex >= 0 pIndex-) If (textBody.ChildEntities is WParagraph)


Checks item is empty paragraph and removes it. A flag to determine any renderable item found in the Word document.įor (int itemIndex = - 1 itemIndex >= 0 & !IsRenderableItem itemIndex-) Private void RemoveEmptyItems(WTextBody textBody)
