🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.acrobat.sdk
Article #30

Re: Add a watermark, the hard way

#30
From: scollaris
Date: Tue, 19 May 2009 14:32
89 lines
4215 bytes
On Mar 31, 3:29 am, Jon_P...@adobeforums.com wrote:
> Hi.
> I've been drooling over the Acrobat 7.0 SDK documentation. It talks about an addWatermarkFromFile() function in JavaScript. You lucky, lucky, lucky people.
> I have Acrobat 6.0 (Pro). Ugh. You can add a watermark in the application, but there is no addWatermarkFromFile(). I had thought of using MenuItemExecute to work the menus...
>
> acrApp.MenuItemExecute "COMP:AddBack"
> SendKeys "%b"
> SendKeys MY_PATH & "MY_FILE.pdf"
> SendKeys "{ENTER}"
>
> However, the crafty dialog seems to be modal, ie the code halts at MenuItemExecute and waits for me to dismiss it before executing the SendKeys commands.
> Is there a way round this?
> Jon
>
> MS Office 2003
> MS Windows XP Pro SP2
> Adobe Acrobat 6.0 Pro

****************************************************************************************************
*    Procedure:     m_insertWatermark
*    Author:        Larry Leo
*    Creation Date: 04/23/2008
*    Purpose:       Add water mark to pdf document from another pdf
document
*    Parameters:    l_pInputFile     - full path of pdf to be "water
marked"
*                   l_pWatermarkFile - full path of pdf file
containing water mark to be used
*                   l_pOutPutFile    - full path of resulting pdf with
water mark added
*                   ALL PARAMETERS ARE REQUIRED STRINGS
****************************************************************************************************
*    Modifications:
*    Date        Init    Reason
* 	 04/14/2009	 CLB	 Moved into PDF doc,
****************************************************************************************************

LPARAMETERS l_pInputFile, l_pWatermarkFile, l_pOutPutFile

LOCAL l_opdDoc, l_oJSobj,l_nTotalDocs

l_oAcrobat = CREATEOBJECT("AcroExch.App")  && Acrobat
l_opdDoc = CREATEOBJECT("AcroExch.PDDoc")  && Document Object
l_opdDoc.OPEN(l_pInputFile)

l_oJSobj = l_opdDoc.GetJSobject  && JavaScript Object
l_nTotalDocs = ALEN(l_oJSobj.app.activedocs) && needed so we don't
close acrobat if others are opened

l_oJSobj.addWatermarkFromFile( ;
    l_pWatermarkFile ;  && Watermark File
	,	0 ;                 && SourcePage
	,	0 ;                 && Start
	,	99999 ;             && End
	,	.T. ;               && OnTop
	,	.T. ;               && OnScreen
	,	.T. ;               && OnPrint
	,	0 ;                 && HorizAlign 1000
	,	2000 ;              && VertAlign 2000
	,	140 ;               && HorizValue 40
	,	10 ;               && VertValue -35
	,	.F, ;               && Percentage
	,	.5 ;                && Scale
	,	.F. ;               && FixedPrint
	,	0 ;                 && Rotation
    ,	1.0)                 && Opacity

* save file
l_opdDoc.SAVE(21, l_pOutPutFile)
l_opdDoc.CLOSE()

IF l_nTotalDocs = 1
	l_oAcrobat.Exit()
ENDIF

l_opdDoc   = NULL
l_oJSobj   = NULL
l_oAcrobat = NULL

RETURN
Technical Details
Message-ID: <c80c49db-8aa3-4f7d-85e6-7d9abe3862aa@s20g2000vbp.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!s20g2000vbp.googlegroups.com!not-for-mail
References: <59b87558.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: 2105b4c04d,70093c1cad5bff98
X-Google-Attributes: gid2105b4c04d,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!s20g2000vbp.googlegroups.com!not-for-mail
From: scollaris@gmail.com
Newsgroups: adobe.acrobat.sdk
Subject: Re: Add a watermark, the hard way
Date: Tue, 19 May 2009 07:32:17 -0700 (PDT)
Organization: http://groups.google.com
Lines: 89
Message-ID: <c80c49db-8aa3-4f7d-85e6-7d9abe3862aa@s20g2000vbp.googlegroups.com>
References: <59b87558.-1@webcrossing.la2eafNXanI>
NNTP-Posting-Host: 71.251.146.91
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1242743537 23402 127.0.0.1 (19 May 2009 14:32:17 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 19 May 2009 14:32:17 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: s20g2000vbp.googlegroups.com; posting-host=71.251.146.91; 
 posting-account=b9eDJwoAAADfmZViwgv3LkwKCulQXWvJ
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) 
 Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe)