?
Solved

Insert graphic into pdf with vbscript

Posted on 2013-02-05
4
Medium Priority
?
1,647 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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe INTRODUCTION This article presents a solution to a question (http://www.experts-exchange.com/Programming/Installation/Q_28396542.html)…
This article explains how to perform batch conversion of PDF, TIFF, and other image file formats into PDF, PDF Searchable, and TIFF files via a command line interface, using Nuance's latest document imaging software — Power PDF Advanced.
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

719 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