We have purchased the Professional license for DynamicPDF Merger for .NET. We have been using this to merge multiple .PDF files into one and it works great. I am now trying to use it to open each individual file and write a page number at the bottom. For most .PDF files, this works great, with no licensing watermark. However, via VB.NET code, if I open a .DOCX file, save it to .PDF and then try to write the page number, I get the watermark. I get this with all of the Office documents (.DOCX, .XLSX, .PPTX, etc.). I do use Interop to open the .DOCX file and save it to .PDF. Here is the code to create the .PDF file from Word:
Dim word As Microsoft.Office.Interop.Word.Application = Nothing
Dim doc As Microsoft.Office.Interop.Word.Document = Nothing
Dim missing As System.Object = System.Reflection.Missing.Value
Try
word = New Microsoft.Office.Interop.Word.Application With {.Visible = False, .ScreenUpdating = False}
doc = word.Documents.Open(DirectCast(documentFileName, System.Object))
If doc IsNot Nothing Then
doc.Activate()
doc.SaveAs2(DirectCast(tempPdfFileName, System.Object), Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF)
End If
Finally
If doc IsNot Nothing Then
doc.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(doc)
End If
If word IsNot Nothing Then
word.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(word)
End If
'Once the .PDF file is created, I then add the page number:
Me._addPageNumbers(tempPdfFileName)
End Try
Private Sub _addPageNumbers(pdfFileName As System.String)
If System.IO.File.Exists(pdfFileName) AndAlso Me.ShowPageNumbers Then
Dim copyPdfFile As System.String =
System.IO.Path.GetFileName(pdfFileName) & "_p" & System.IO.Path.GetExtension(pdfFileName)
If System.IO.File.Exists(copyPdfFile) Then
System.IO.File.Delete(copyPdfFile)
End If
'Create a copy of the file.
System.IO.File.Copy(pdfFileName, copyPdfFile)
If System.IO.File.Exists(copyPdfFile) Then
'Add the page number to the bottom of each page.
Dim mergeDocument As New ceTe.DynamicPDF.Merger.MergeDocument(copyPdfFile)
'Create a bogus page to get dimensions.
Dim bogusPage As New ceTe.DynamicPDF.Page(ceTe.DynamicPDF.PageSize.Letter, ceTe.DynamicPDF.PageOrientation.Portrait)
Dim pageDimension As ceTe.DynamicPDF.PageDimensions = bogusPage.Dimensions
pageDimension.BottomMargin = 24 '1/4 inch
pageDimension.TopMargin = 48
pageDimension.LeftMargin = 48
pageDimension.RightMargin = 48
Dim fontSize As System.Int32 = 10
'Open the copy and add a label.
For Each mergePage As ceTe.DynamicPDF.Page In mergeDocument.Pages
mergePage.Dimensions.Body.Height = pageDimension.Body.Height
mergePage.Dimensions.Body.Width = pageDimension.Body.Width
mergePage.Dimensions.Body.Top = pageDimension.Body.Top
mergePage.Dimensions.Body.Left = pageDimension.Body.Left
mergePage.Dimensions.Body.Bottom = pageDimension.Body.Bottom
mergePage.Dimensions.Body.Right = pageDimension.Body.Right
'Create a line above the page number.
Dim pageLine As New ceTe.DynamicPDF.PageElements.Line(0,
pageDimension.Body.Height,
pageDimension.Body.Width,
pageDimension.Body.Height)
pageLine.Width = 1
mergePage.Elements.Add(pageLine)
'Create a page Label at the bottom right corner, under the line.
Dim pageLabel As New ceTe.DynamicPDF.PageElements.Label(Me._pageNumber.ToString,
0,
pageLine.Y2,
pageDimension.Body.Width,
fontSize,
ceTe.DynamicPDF.Font.HelveticaBold,
fontSize,
TextAlign.Right)
mergePage.Elements.Add(pageLabel)
Me._pageNumber += 1
Next
If mergeDocument IsNot Nothing Then
mergeDocument.Draw(pdfFileName)
End If
If System.IO.File.Exists(copyPdfFile) Then
System.IO.File.Delete(copyPdfFile)
End If
End If
End If
End Sub
How can I get rid of the licensing watermark for these files? I'm pretty sure it is licensed correctly as other .PDF files work fine for both merging and adding the page numbers. This is just a problem with the Office files being saved to .PDF files. Does it have something to do with using Interop?
Thank you.
Dave