Removing or Hiding Page Number After Convert From Word Doc

I'm using Aspose.words and aspose.pdf together to convert word documents to pdf for final delivery to our customers. Everything is working great except for the fact that after I convert a word doc to a pdf, its adding page numbers in the footer even though page numbers are not present in the word document. We do not want page numbers showing up in the document unless they are in the source document to start with.

I couldn't find anything in the forums about, removing, hiding, deleting page numbers.

Worst case scenario, if I can't remove them, I would settle for being able to change the color to match the background color so they are not visible. Please provide me with a working solution.

Below, you will find the code I'm using for the conversion, its pretty straight forward I think...

'Set the license (must be a the start for each process that access Aspose.Words):

Dim wordsLicense As Aspose.Words.License = New Aspose.Words.License()

wordsLicense.SetLicense("Aspose.Words.lic") 'Must be in the bin directory of host application

'Set the license (must be a the start for each process that access Aspose.Pdf):

Dim pdfLicense As Aspose.Pdf.License = New Aspose.Pdf.License()

pdfLicense.SetLicense("Aspose.Pdf.lic") 'Must be in the bin directory of host application

'Create a word document from the LegalDocument.DocumentFile Byte() property:

Dim wordDoc As New Aspose.Words.Document(New MemoryStream(Me.DocumentFile))

'Save the Word Document in XML Format that can be handled by Aspose.Pdf:

Dim xmlStream As New MemoryStream()

wordDoc.Save(xmlStream, Aspose.Words.SaveFormat.AsposePdf)

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()

pdf.BindXML(xmlStream, Nothing)

'Added these two lines to Speed up the conversion from doc to pdf:

pdf.IsTruetypeFontMapCached = True

pdf.TruetypeFontMapPath = System.IO.Path.GetTempPath()

'Finally, get the pdf bytes:

pdf.Save(filePath)

Hello Heath,

Thanks for considering Aspose.

Aspose.Words is used to manipulate, create, edit, and transform word documents. Whereas, Aspose.Pdf is a component which is used to generate PDF documents from scratch. You can generate documents using an API, convert XML, Image files into PDF format or you can even convert Word documents (requires Aspose.Words and only the .Net version supports) and Excel worksheets into PDF format (Aspose.Cells required).

Let me share some details on how Aspose.Words and Aspose.Pdf coordinate with each other when converting the Word document into PDF format.

First, Aspose.Words exports all the content of Word documents into an intermediate XML file, and Aspose.Pdf uses that XML file to generate the PDF documents (as we know Aspose.Pdf can generate documents using XML file). So all the information present over the PDF file comes from the XML file.

I’m not sure how the page information is being displayed over the PDF when it’s not present in the word document. Can you please share the source word file so that we can test the issue at our end?

We apologize for your inconvenience.

PS, you can also try the Direct-to-Pdf save method of Aspose.Words. For more information, please visit Convert a document into PDF.

Hi,

We can't use the direct to file save as after the conversion, I need to return the file as an array of bytes and really don't want to have to save to the server.

Attached you will find the word document we are converting and also the PDF post conversion. You already have my code block above so that should help you duplicate this issue.

As you can see, the conversion to pdf is putting in page numbers where there shouldn't be any based on the original word doc. A solution to this issue will be greatly appreciated.

If you need anything else, please advise...

Thanks!

Heath

Hello Heath,

Thanks for the information and resource documents.

As far as I can see, the attached word file contains a Footer section in which page number information is being displayed, and same information is being exported to PDF format. In order to see the page number information in footer section, view the document in “Print Layout View” rather than "Normal View". Please take a look over the following image, on how to switch the view in MS Word 2003.

For your convenience, I’ve removed the page number information from word file and have converted it into PDF format. The files are in attachment, please take a look.

FYI, Using Direct-to-PDF save method of Aspose.Words, you can save the resultant document in a Stream Object and can easily convert it into Byte array (as per your requirement).

In case of any further query, please feel free to contact.

You are correct, thanks for catching that, I spoke with our legal department and they are going to remove page numbers from all our source word documents.

Thanks again.