Stamp on PDF / CreateObject / pdfforge / PDFCreator Pro

Hi everyone,

We have been using Excel (VBA) to create and add stamps on PDF (PDFCreator version 1.7.3) since many years.
The Excel function was : Set pdf = CreateObject("pdfforge.pdf.pdf"), and it worked perfectly.
We had to download the new version of PDFCreator Pro, and since then, the function doesn't work anymore. Is it replaced by another function? If so, which one? How to change the code?

Here a part of our actual code:

Sub STAMP()
Dim pdf As Object, pdfText As Object, pdfText1 As Object, pdfText2 As Object, pdfLine As Object, pdfLine2 As Object, pdfLine3 As Object, pdfLine4 As Object
Dim sNomDoc As String
Dim Num As Long
Dim REF As String
Dim nlot As String

Set pdf = CreateObject("pdfforge.pdf.pdf")
Set pdfText = CreateObject("pdfforge.pdf.pdfText")
Set pdfText1 = CreateObject("pdfforge.pdf.pdfText")
Set pdfText2 = CreateObject("pdfforge.pdf.pdfText")
Set pdfLine = CreateObject("pdfforge.pdf.pdfline")
Set pdfLine2 = CreateObject("pdfforge.pdf.pdfline")
Set pdfLine3 = CreateObject("pdfforge.pdf.pdfline")
Set pdfLine4 = CreateObject("pdfforge.pdf.pdfline")

REF = ThisWorkbook.Sheets("FEUIL2").Range("B2")
nlot = ThisWorkbook.Sheets("FEUIL2").Range("B4").Value

sNomDoc = ThisWorkbook.Path & ThisWorkbook.Sheets("FEUIL2").Range("B7") & "" & REF & "_" & ThisWorkbook.Sheets("FEUIL2").Range("B3").Value & ".pdf"
If Dir(sNomDoc) <> "" Then
Num = pdf.NumberOfPages(sNomDoc)
Else
MsgBox "FICHIER INTROUVABLE"
End If

With pdfText
    .fillOpacity = 1

    .FontColorBlue = 255
    .FontColorGreen = 0
    .FontColorRed = 0

    .FontName = "ariblk.TTF"
    .FontSize = 10
    .Rotation = 0
    .Text = "VALABLE POUR"
    .XPosition = 254
    .YPosition = 193

    pdf.AddTextToPDFFile sNomDoc, ThisWorkbook.Path & "\" & "AddText.pdf", 1, Num, pdfText
End With

[...]
End Sub

Thanks for your help,
Best regards
Sarah

Hi Sarah,

sorry for the trouble.
The entire PDFCreator application was rewritten after version 1.7.3 and the COM-interface was, too.
You can find the current documentation as well as a migration guide here:
https://docs.pdfforge.org/pdfcreator/4.0/en/pdfcreator/com-interface/

Best regards

Robin

Thanks Robin for the documentation, but it's not very helping.. Do you have an example of how using the new COM-interface ?
Thanks

Hi Sarah,

you can find a VBA example for the current COM interface inside the COM Scripts folder of the PDFCreator installation directory.

Best regards

Robin

Hi everyone,
I have just installed PDFCreator 4.0.4 and the vba example inside Testpage2PDF.docm still contain
Set pdf = CreateObject("pdfforge.pdf.pdf")
It doesn't work!!
The description of the new COM-interface is too complicated for me. Could someone give a working example ? I need to merge several PDF from Word.

Best regards
Christine

Hi everyone,
I just found the solution. Perhaps it will help someone :slight_smile:
Sub MergePdf()
'Dim Pdf As Object, Fichiers(2)
Dim pdfCreator As Object
Dim pdfCreatorQueue As Object
Dim pdfCreatorPrintJob As Object
Dim Fichiers(2)
Dim pj As printJob

'Set Pdf = CreateObject("pdfforge.pdf.pdf")

Fichiers(0) = ActiveDocument.Path & "\" & "1.pdf"
Fichiers(1) = ActiveDocument.Path & "\" & "2.pdf"
Fichiers(2) = ActiveDocument.Path & "\" & "3.pdf"

Set pdfCreator = CreateObject("PDFCreator.PDFCreatorObj")
Set pdfCreatorQueue = CreateObject("PDFCreator.JobQueue")
Call pdfCreatorQueue.Initialize

Call pdfCreator.AddFileToQueue(Fichiers(0))
Call pdfCreator.AddFileToQueue(Fichiers(1))
Call pdfCreator.AddFileToQueue(Fichiers(2))

Call pdfCreatorQueue.MergeAllJobs

Set pj = pdfCreatorQueue.NextJob
With pj
.SetProfileByGuid "DefaultGuid"
.SetProfileSetting "Printing.PrinterName", "PDFCreator"
.SetProfileSetting "Printing.SelectPrinter", "SelectedPrinter"
.SetProfileSetting "ShowProgress", "false"
.ConvertTo (ActiveDocument.Path & "\Testfusion.Pdf")
End With

Call pdfCreatorQueue.ReleaseCom

End Sub

Best regards
Christine

1 Like