Solved

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

Posted on 2014-04-15
9
715 Views
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")
oNew.open("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 ?
0
Comment
Question by:meep_meep
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:Olaf Doschke
Comment Utility
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")
oBlank.open("C:\blank.pdf"), then you can insert that.

Bye, Olaf.
0
 

Author Comment

by:meep_meep
Comment Utility
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 ?
0
 
LVL 29

Expert Comment

by:Olaf Doschke
Comment Utility
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.
0
 

Author Comment

by:meep_meep
Comment Utility
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")
acroAvDoc.Open("c:\blank2.pdf","Temp")
acroPDDoc = acroAVDoc.GetPDDoc
acroRect = CREATEOBJECT("AcroExch.Rect")
acroRect.bottom=380
acroRect.Top=400
acroRect.Left=100
acroRect.right=500
PDTextSelect = acroPDDoc.CreateTextSelect(0,acroRect)
?PDTextSelect.GetText(0)

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 :(

Thanks.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

by:Olaf Doschke
Comment Utility
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.
0
 

Author Comment

by:meep_meep
Comment Utility
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".
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
Comment Utility
>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.
0
 

Author Comment

by:meep_meep
Comment Utility
Bingo.
0
 

Author Closing Comment

by:meep_meep
Comment Utility
Always a pleasure to be assisted by you, Olaf.
Meep_meep
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe In a previous Experts Exchange article, How To Rename-Move a Batch of PDF Files Based on Contents of the Files (http://www.experts-exchan…
Have you ever come up with a need of emailing only few pages of PDF file to one of yourfriend or colleague, instead of whole Adobe file? If yes, then surely you have face problems in doing that! Read this section as I have suggested multiple solutio…
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now