Solved

Insert graphic into pdf with vbscript

Posted on 2013-02-05
4
1,470 Views
Last Modified: 2013-02-21
Hello,

I have a small diagram (jpg) that I need to insert into a pdf on a daily basis. I am sick of going through the menus so I would like to automate it. I 've seen some code to do something similar  on EE, but it was far too complicated. The requirement is that the jpg file goes at the back layer and is positioned at 7.5 inches from the top and 1,25 inches from the left.

Thanks,

Bruce
0
Comment
Question by:Diaphanosoma
[X]
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
  • 2
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 38864111
The only way you can do this is by adding a watermark. The VB interface does not have access to the "real" PDF objects, so you cannot insert an image directly. The following code shows how to use the JSO object to accomplish this from VB:

        Dim gApp As Acrobat.CAcroApp
        Dim gPDDoc As Acrobat.CAcroPDDoc
        Dim jso As Object

        Set gApp = CreateObject("AcroExch.App")
        Set gPDDoc = CreateObject("AcroExch.PDDoc")
        If gPDDoc.Open("c:\temp\test.pdf") Then
            Set jso = gPDDoc.GetJSObject

            i = jso.addWatermarkFromFile("c:\temp\watermark.jpg", 0, 0, 99999, False, True, True, 0, 3, 1.25 * 72, -7.5 * 72, False, 0.5, False, 0, 1#)
            If gPDDoc.Save(PDSaveFull, "C:\temp\watermark.pdf") = False Then
                MsgBox ("Cannot save the file!")
            End If

        End If

Open in new window


To get more information about the JSO object, take a look at this blog post: http://khkonsulting.com/2009/03/acrobat-javascript-and-vb-walk-into-a-bar/ It contains more links to relevant information

To understand the call to addWatermarkFromFile, take a look at it's documentation:
ttp://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/JS_API_AcroJS.88.436.html
0
 
LVL 1

Author Comment

by:Diaphanosoma
ID: 38874348
I will try this out this week. Backed-up with other things...
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 38874404
No problem, let me know how it goes.
0
 
LVL 1

Author Closing Comment

by:Diaphanosoma
ID: 38914598
That's sweet.  Thanks,

Bruce.
Been on Vacation!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is in response to a question here (http://www.experts-exchange.com/Other/URLs/Q_28283850.html) at Experts Exchange. The Original Poster has a scanned signature and wants to make the background transparent so that the signature may be pl…
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 second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…
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…

733 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