Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Creating an empty sheet in an existing PDF and adding a watermark

Posted on 2014-04-15
Medium Priority
Last Modified: 2014-04-17
Hi experts.  Want to know how to VFP9 programmatically insert a blank pdf sheet in an existing PDF file (as the first page) and put a watermark "Confidential stamp" on it.  I already use that portion of code, but do not succeed to insert a blank sheet so far:

lo = createobject("AcroExch.App")
oNew = createobject("AcroExch.PDDoc")"C:\test.pdf")
oNew.InsertPages(-1,oNew,0,oNew.GetNumPages(),1)  && this insert a copy of first page, not empty page...

Can you be of any help ?
Question by:meep_meep
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 30

Expert Comment

by:Olaf Doschke
ID: 40004345
Refer to the documentation.

Inserts the specified pages from the source document after the indicated page within the current document.

So the method isn't there to insert blank pages, it inserts pages (one page) of the oNew document to the oNew document, because you specify so in the parameters.

You need a blank page PDF and load it as oBlank=createobject("AcroExch.PDDoc")"C:\blank.pdf"), then you can insert that.

Bye, Olaf.

Author Comment

ID: 40004638
Exact, I found this a few hours ago.  Since I'm trying to either change a text on a "controlled inserted page" or adding a watermark.  So far no success.  Any ideas ?
LVL 30

Expert Comment

by:Olaf Doschke
ID: 40005894
I already proopsed an idea, didn't I?

Open Word or Wordpad, print a new empty document as PDF and you have a blank.pdf you can use to insert into your other PDFs.

Bye, Olaf.
TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.


Author Comment

ID: 40006350
Sorry, I gave a bad explanation of my understanding :(   This is exactly what I've done: printed an empty WordPad into PDF.  This gave me the possibility to insert a white page.  Next step is to programmatically either edit a previously saved Watermark or create a new one.  I already found how to get a previouslay saved watermark

acroAvDoc = CREATEOBJECT("AcroExch.AVDoc")
acroPDDoc = acroAVDoc.GetPDDoc
acroRect = CREATEOBJECT("AcroExch.Rect")
PDTextSelect = acroPDDoc.CreateTextSelect(0,acroRect)

From that point, I have watermark text but did not fnd so far how to replace it by something else...  At this point, I'm not even sure I could do it :(

LVL 30

Expert Comment

by:Olaf Doschke
ID: 40006361
I don't know the AcroExch API, I just could google again, what it offers.

The simplest method would be to delete the previous empty/watermark page and create a new one, wouldn't it? If there is InsertPages, isn't there DeletePages, too?

Bye, Olaf.

Author Comment

ID: 40006384
Yes, but I manually wrote watermark, not programmatically.  I was thinking by manually position it, font it, orient it and so on it would be easier to "just change text" after: obviouly not !   At this point, if I can't "just change text", my turn around would be to create a VFP report, fill it with table's data and make it PDF so that will be the "inserted page".
LVL 30

Accepted Solution

Olaf Doschke earned 2000 total points
ID: 40006423
>my turn around would be to create a VFP report, fill it with table's data
>and make it PDF so that will be the "inserted page".

Indeed, or write it in Word/Wordpad and create the "watermark.pdf" to insert, which can also be done by Word automation, for example.

Bye, Olaf.

Author Comment

ID: 40006438

Author Closing Comment

ID: 40006441
Always a pleasure to be assisted by you, Olaf.

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the questions I get asked again and again is how to validate a field value in an AcroForm with a custom validation script. Adobe provided a lot of infrastructure to do that with just a simple script. Let’s take a look at how to do that wit…
Inserting page numbers in Portable Document Files not only enhances manageability but also makes them look professional. With numbered pages, the file appears more organized and it becomes easier to search for a particular page. The size and the vol…
In this video, we show how to perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question