Programmatically printing a PDF with watermark

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
archan
Posts: 3
Joined: Wed Jan 31 2007

Programmatically printing a PDF with watermark

Post by archan »

Hello All,

I am trying to print a PDF with a watermark.

I have the following code. It does set the text and other options like font color etc so it seems the code works.

However, I cannot get it to PRINT programmatically, (I get no output)
It works only when I open a PDF file and use File-Print manually. I have the AMYUNI PDF driver installed

(Our company has the developer license, but I dont know if the version I installed is the licensed one)

Any advise is much appreciated.

*******************************************************
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Private Sub Command1_Click()

Dim pdfprinter As New CDIntf.CDIntf
Dim lRet As Long

pdfprinter.DriverInit ("Amyuni PDF Converter")

pdfprinter.SetDefaultConfig
pdfprinter.SetDefaultPrinter

lRet = pdfprinter.SetWatermark("Official Copy" & vbNewLine & Now, "Arial", 20, 0, &HFF, 50, -700, True)

pdfprinter.FileNameOptions = 64
pdfprinter.DefaultFileName = "C:\output.pdf"
lRet = ShellExecute(Me.hwnd, "Print", "C:\1.pdf", 0&, 0&, vbMaximizedFocus)

'Restore default configuration
'pdfprinter.DefaultFileName = ""
'pdfprinter.FileNameOptions = 0
'pdfprinter.SetDefaultConfig

pdfprinter.DriverEnd

End Sub



*******************************************************
archan
Posts: 3
Joined: Wed Jan 31 2007

Additional info

Post by archan »

Additionally, I am using AMyUni PDF Convertor 2.08e.
We also have the AmyUni Document Converter suite 2.5g
(I am trying to get it to work with the 2.08e version with just the PDF Converter and not the entire Document Convertor Suite installation)

Thanx.
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

Can you explain what you are tying to print? Are you trying to re-print a PDF document to the PDF converter?
archan
Posts: 3
Joined: Wed Jan 31 2007

Post by archan »

I am trying to print just a regular PDF document.

I have existing PDFs that I want to open programmatically and then add a watermark with the text "Official Copy" to each one of them.

So the Shell Open command to open and print the document.

Also when I change the default printer to a local printer (Lexmark) t works fine and submits the Print job. But when the default printer is AMYUNI it doesnt do anything. Manual Print click operations works.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

What you can do is create a new PDF containing the watermark, Open your PDF and merge it to the new PDF than save it.

Another option would be to open your PDF, add a text object containing the text of the watermak and save your PDF file.
Post Reply