anderson pdfscripting

Upload: deeptisadasya

Post on 15-Oct-2015

21 views

Category:

Documents


0 download

DESCRIPTION

anderson pdfscripting

TRANSCRIPT

  • Scripting Acrobat with VB

    PDF Conference 23 November 2002

    Robert Anderson - Publishing Technologist

    E-mail: [email protected]

    Presentations and scripts:

    homepage.mac.com/bobanderson

  • Topics

    Why Scripting?

    Scripting Languages for Acrobat

    How to get started

    VB sample

    Resources

  • Why Scripting?

    Doing the same manual operations over and over again with Acrobat?

    Scripting provides a way to combine many manual steps into a single operation.

  • Visual Basic is powerful

    Create custom GUI

    Control multiple programs

    Create a custom workflow

    Create installable .exe apps

    Include JavaScript and Perl

  • JavaScript

    Internal to Acrobat

    Cross-platform

    Access other aspects of ACRO SDK Art Box

    Bleed Box

    Trim Box

  • Perl

    The quintessential file munger

    We use it to repair PS files before Distilling

    Runs on virtually every computer platform

    Wicked fast

    Callable with VB Shell function

  • Getting Started with VB

    In-house training

    Course at local college

    Buy a tutorial from local bookstore Includes Visual Basic 6 Learning Edition

    Learn how to create a GUIand write simple apps

  • VB Demo Sample: Check Papersize

    Select PDF file

    Open with Acrobat

    Get papersize of page 1

    Compare with other pages

    Display non-matching pages

  • File Open Dialog Box

    Dim filename As String

    cdbOpen.Flags = &H1000 file must exist

    cdbOpen.ShowOpen

    filename = cdbOpen.filename

    MsgBox (filename)

  • Launch Acrobat

    Set gAcro = CreateObject("AcroExch.App")

    Set newPD = CreateObject("AcroExch.PDDoc")

    Set newAV = CreateObject("AcroExch.AVDoc")

    gAcro.Show

  • Open & Display PDF

    OK = newPD.open(filename)

    If Not OK Then

    MsgBox ("Could not open PDF file: " + filename)

    Exit Sub

    End If

    Set newAV = newPD.openAVDoc("Paper Size Check")

  • Get size of page 1

    Set newPage = newPD.AcquirePage(0)

    x1 = newPage.GetSize.x

    y1 = newPage.GetSize.y

  • Make a list of bad pages

    j = 0

    For i = 1 To newPD.GetNumPages

    Set newPage = newPD.AcquirePage(i - 1)

    If (x1 newPage.GetSize.x) And(y1 newPage.GetSize.y) Then

    j = j + 1

    badpages(j) = I

    End If

    Next I

  • Display bad pages

    For i = 1 To j

    k = badpages(i)

    newAV.GetAVPageView.Goto (k)

    Set newPage = newPD.AcquirePage(k - 1)

    xk = newPage.GetSize.x

    yk = newPage.GetSize.y

    MsgBox ("Page: " + Str(k) + " Size: + Str(xk) + " x " + Str(yk))

    Next i

  • Resources

    VB Books from computer bookstore

    Adobe SDK documentation

    Newgroups

    User Forums and Email lists

    Collegues and friends

  • Adobe Acrobat Docs

    http://partners.adobe.com

    Acrobat SDK files IACOverview Tech Note 5164

    IACReference.pdf Tech Note 5465

    VBJavaScript.pdf Tech Note 5417

    CoreAPIReference.pdf Tech Note 5191

    Tell VB to reference acrobat.tlb(comes with Acrobat)

  • Newsgroups

    comp.lang.visual.basic comp.text.pdf

    Searching newsgroups: http://groups.google.com/

    Search for the name of newsgroup

    Then, search for your topic

  • http://groups.goodle.com

  • User forums and mailing lists

    http://pdfzone.com/resources/discussions.html

    http://forum.planetpdf.com/scripts/wbpx.dll/~planetpdfforum

    http://www.adobe.com/support/forums/main.html

  • Select Folder using standard VB objects:

  • Select Folder code from newsgroup:

  • Adobe watches newsgroups & forums

    Dov Issacs frequents the PDF Discussion list

    Adobe Support MarketPlace $ but effective

    Get answers from Adobe support

    Bugs often fixed in next release

    Best time: just after major point release

    Reporting bugs to Adobe

  • http://www.adobe.com/support/marketplace.html

  • The End