Accusoft.PdfXpress7.ActiveX
Add Watermark to a PDF document

You can add a source-based watermark or a text watermark to a PDF. Source-based means the source of the watermark is another PDF.

To add a source-based watermark to a PDF, do the following:

  1. Create a PDFXpress object and initialize it.
  2. Create a PdfDocument object from an existing PDF file.
  3. Create a PdfDocument object from an existing PDF file to be used as the watermark source.
  4. Create a PageArtifactOptions object.
  5. Set the PageArtifactOptions:
    • ArtifactType – specifies the type of watermark, in this case SourceWatermark
    • Opacity – we set this to .5 to make the watermark translucent
    • PageList – we set this to specify to what pages the watermark will be added
    • SourceDocument – we set this to our source PDF watermark
    • SourcePageNumber – we set this to 0 to specify the first page
  6. Call AddWatemark() on the PdfDocument object to add the watermark.
  7. Create a SaveOptions object.
  8. Call Save() on the PdfDocument object to save the watermarked PDF.
VB6 Example
Copy Code
Private Sub Form_Load()
    Dim pdf As New PdfXpress
    pdf.InitializePaths "C:\Users\Public\Documents\Accusoft\PDFXpress\V7.0\Support\Font", _
        "C:\Users\Public\Documents\Accusoft\PDFXpress\V7.0\Support\CMap"
    Dim doc As New PdfDocument
    doc.SetParentControl pdf
    doc.OpenDocument "C:\myfile.pdf", ""
   
    Dim sourceDoc As New PdfDocument
    sourceDoc.SetParentControl pdf
    sourceDoc.OpenDocument "C:\source.pdf", ""
    Dim po As New PageArtifactOptions
    po.ArtifactType = PDF_TypeOfArtifact_SourceWatermark
    po.Opacity = 0.5
    Dim pl As New PageList
   
    Dim pr As New PageRange
   
    pr.PageCount = 1
    pr.StartPageNumber = 0
    pl.Add pr
   
    po.PageList = pl
    po.SourceDocument = sourceDoc
    po.SourcePageNumber = 0
    doc.AddWatermark po
   
    Dim so As New SaveOptions
    so.FileName = "C:\watermarked.pdf"
    so.Linearized = True
    so.Overwrite = True
    doc.SaveDocument so
    Set so = Nothing
    Set pr = Nothing
    Set pl = Nothing
    Set po = Nothing
    Set sourceDoc = Nothing
    Set doc = Nothing
    pdf.Terminate
    Set pdf = Nothing
End Sub

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback