VBA WatermarkParams .Scale

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Stefan - PDF-XChange

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
User avatar
OfficeWorker
User
Posts: 1
Joined: Mon Aug 04, 2025 12:51 pm

VBA WatermarkParams .Scale

Post by OfficeWorker »

Hello there,

So i am working on adding a watermark to a pdf in ms Access using VBA.
I recently got the PDFXCoreAPI dll's and the company i work at hasn't bought the license yet. That is probably the reason why the watermark itself isn't showing and only the demo stamps are there so ill skip that for now.

When i have a IPXC_WatermarkParams object and try to change the scale i get a compile error no matter what value entered
image.png
I am fairly new to VBA and working with PDFXChange core API so i am not sure if it is a VBA or a PDFXChange thing. Looking at the documentation and other posts i am pretty certain this is the correct syntax so i don't know what's happening.

Here is some sample code below, same thing happens in Access and Excel so test where you prefer.

Code: Select all

Public Sub testWatermarkImage()
    Dim objIPXC As PDFXCoreAPI.IPXC_Inst
    Dim objIAUX As PDFXCoreAPI.IAUX_Inst
    Dim objIAFS As PDFXCoreAPI.IAFS_Inst

    Dim objDocMain As IPXC_Document
    Dim rect As PXC_Rect
    Dim bitset As IBitSet
    Dim wp As IPXC_WatermarkParams
    Dim resultPath As IAFS_Name

    Set objIPXC = New PDFXCoreAPI.PXC_Inst
    Set objIAUX = objIPXC.GetExtension("AUX")
    Set objIAFS = objIPXC.GetExtension("AFS")

    'I don't have a license key (yet)
    objIPXC.init ""

    Debug.Print objIPXC.APIVersion ' Prints: 33751040

    Set objDocMain = objIPXC.NewDocument()

    ' Define A4 size
    rect.Left = 0
    rect.bottom = 0
    rect.Right = 595
    rect.Top = 842

    ' Add a blank page
    objDocMain.Pages.AddEmptyPages 0, 1, rect

    ' Create watermark parameters
    Set wp = objIPXC.CreateWatermarkParams()
    wp.WatermarkType = 1 ' Image
    wp.ImageFile = "C:\temp\myImage.png"
    wp.Opacity = 1
    wp.Rotation = 0
    wp.HAlign = 2 ' Center
    wp.VAlign = 2 ' Middle
    wp.HOffset = 0
    wp.VOffset = 0
    wp.Start = 0
    'wp.Scale = 76 ' Gives: "compile error: Expected: ("

    ' Apply watermark to all pages
    Set bitset = objIAUX.CreateBitSet(objDocMain.Pages.Count)
    objDocMain.PlaceWatermark bitset, wp

    ' Save the document
    objDocMain.WriteToFile ("C:\temp\testWatermark.pdf")

End Sub

You do not have the required permissions to view the files attached to this post.