PDF In-Depth

IAC - Setting the info fields on every PDF

May 15, 1998

Advertisement
Advertisement
 

This method sets the info on all the PDFs in the folder c:\acrobatdocstosetinfo

This code sample is posted here for the general benefit of the PDF development community. Attribution and usage guidelines are as noted in the code source; please respect the wishes of the author when using this code.


Option Explicit ' Force variable declaration	

' Author : Planet PDF
' Date : 23 March 1998
' Description: SetInfoForAllAcrobatDocsInDir
' This vb method uses IAC to set the Document Info fields for all files in
' a directory.
' This method / function should be extended to suit the requirements
' of an organisation

Public Const POSTSCRIPT_LEVEL = 2
Public Const PDF_WILDCARD = "*.pdf"
Public Const PDF_DIRECTORY = "c:\acrobatdocstosetinfo\"
	
Sub SetInfoForAllAcrobatDocsInDir()
Dim AcroExchAVDoc As Object, AcroExchPDDoc As Object, _
	
	        AcroExchApp As Object	
    Dim strFileName As String, strPath As String	
	Dim strTitle As String, strSubject As String, _
	
    strAuthor As String, strKeywords As String	
	   
Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")

' Get the fields from the user
	strTitle = InputBox("Enter the Title - click cancel to leave this 
field as is", _
            "RTSSetInfo - http://www.aroundtablesolution.com/", "Type your 
title here")
	strSubject = InputBox("Enter the Subject - click cancel to leave 
this field as is", _
            "RTSSetInfo - http://www.aroundtablesolution.com/", "Type your 
subject here")
	strAuthor = InputBox("Enter the Author - click cancel to leave 
this field as is", _
            "RTSSetInfo - http://www.aroundtablesolution.com/", "Type your 
author here")
	strKeywords = InputBox("Enter the Keywords - click cancel to leave 
this field as is", _
            "RTSSetInfo - http://www.aroundtablesolution.com/", "Type your 
keywords here")

' Show the Acrobat Exchange window
	    AcroExchApp.Show

' Set the directory / folder to use
	    strPath = PDF_DIRECTORY

' Get the first pdf file in the directory
	    strFileName = Dir(strPath + PDF_WILDCARD, vbNormal)   

' Start the loop.
Do While strFileName <> ""
	
    ' Open the [strFileName] pdf file
        AcroExchAVDoc.Open strPath + strFileName, ""
	
    ' Get the PDDoc associated with the open AVDoc
 Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc
	
	' If the user has entered a title then set the title
    If strTitle <> "" Then AcroExchPDDoc.SetInfo "Title", strTitle
	
    If strSubject <> "" Then AcroExchPDDoc.SetInfo "Subject", strSubject
	    ' If the user has entered an author then set the author

    If strAuthor <> "" Then AcroExchPDDoc.SetInfo "Author", strAuthor
	    ' If the user has set keywords then set the keywords

    If strKeywords <> "" Then AcroExchPDDoc.SetInfo "Keywords", strKeywords
	' Save the modified file

AcroExchPDDoc.Save &H1, strPath + strFileName
	
    ' Close this file
        AcroExchAVDoc.Close True
	
    ' Get the name of the next file in the directory
	    	    strFileName = Dir
Loop	

' Close Acrobat Exchange
	    AcroExchApp.Exit
End Sub	
PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Quick PDF Library

Get products to market faster with this amazing PDF developer SDK. Over 900 functions and an equally...

Download free demo

Why eBooks and mobile devices don't (yet) pose an existential threat to the PDF

Continuous upheaval is what makes watching the technology industry so exciting. David vs. Goliath battles are waged every day, with startups often winning against much larger businesses. For years and years, many have predicted the decline of the PDF given its age and perceived disadvantages. Today, with the PDF losing ground in emerging areas like mobile and eBooks, the calls for its ultimate demise are growing louder.

February 02, 2016
Platinum Sponsor



Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist 12

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.