Copy link to clipboard
Copied
I have some +900 legacy pdf's that need to have a title and date change.
The pdf's where generated in ArcMAP 10 so the text appears as individual letters.
So I wrote a script that creates a knockout and adds the required text.
I can get this to work for an individual file but I can't figure out is how to have the script perform it for all the pdf's in a folder.
Very new to scripting form the illustrator end so any help would be appreciated, Kevin
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Open("C:\Work\City_Wide_Zoning\0_Spring_2013\Test\A001.pdf")
' *************************
'Knockout
'Create a new rectangle with measured in points (top, left side, width, height)
'Ref y, x, w, h
Set newRectangle = docRef.PathItems.Rectangle(66,55,118,20)
' *************************
'Text
'Ref y, x, w, h
Set rectRef = docRef.PathItems.Rectangle(62, 54.5, 100, 15)
Set areaTextRef = docRef.TextFrames.AreaText(rectRef)
areaTextRef.Contents = "New Date" & vbCrLf & "New Name"
areaTextRef.Selected = True
' *************************
' Colour Settings for Knockout
Set colorRef = CreateObject("Illustrator.RGBColor")
colorRef.Red = 255
colorRef.Green = 255
colorRef.Blue = 255
newRectangle.FillColor=colorRef
newRectangle.StrokeColor=colorRef
appRef.Redraw
' *************************
areatextRef.TextRange.CharacterAttributes.textFont = appRef.textfonts.getByName("Arial-BoldMT")
areaTextRef.TextRange.CharacterAttributes.Size = 5.25
appRef.Redraw
docRef.Close 1 'aiSaveChanges
Set docRef = Nothing
Thank you Carlos for pointing me in the right direction since I am still new to scripting. I will take Mark's advice and try tto make the move to Javascript.
Anyway here is the solution that works for me in a Win XP environment
Thanks again gentlemen, Kevin
' *************************
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
set pdfFolder = fso.getFolder("C:\Work\City_Wide_Zoning\0_Spring_2013\1to5")
Set pdfFiles = pdfFolder.Files
For Each pdfFile In pdfFiles
' MsgBox pdfFil
Copy link to clipboard
Copied
If you are NEW to scripting then what apps etc. do you need to script…? and how new are you…? A change of language gets you much more help in the Adobe forums…
Copy link to clipboard
Copied
Mark is correct, if you're new to scripting you'll be better off learning Javascript
in the mean time, here's a sample of how to use the files in a folder, try it with a folder with a few files, just to test
Set fso = CreateObject("Scripting.FileSystemObject")
'set pdfFolder = fso.getFolder("C:\Work\City_Wide_Zoning\0_Spring_2013\Test")
set pdfFolder = fso.getFolder("c:\temp")
Set pdfFiles = pdfFolder.Files
For Each pdfFile In pdfFiles
MsgBox pdfFile.Name
'////////////////////////
'insert your script here
'////////////////////////
Next
set pdfFile = Nothing
set pdfFiles = Nothing
set pdfFoler = Nothing
set fso = Nothing
Copy link to clipboard
Copied
Thank you Carlos for pointing me in the right direction since I am still new to scripting. I will take Mark's advice and try tto make the move to Javascript.
Anyway here is the solution that works for me in a Win XP environment
Thanks again gentlemen, Kevin
' *************************
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
set pdfFolder = fso.getFolder("C:\Work\City_Wide_Zoning\0_Spring_2013\1to5")
Set pdfFiles = pdfFolder.Files
For Each pdfFile In pdfFiles
' MsgBox pdfFile.Name
' *************************
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Open(pdfFolder & "\" & pdfFile.Name)
' *************************
' My script here
' *************************
Next
set pdfFile = Nothing
set pdfFiles = Nothing
set pdfFolder = Nothing
set fso = Nothing
Copy link to clipboard
Copied
you're welcome, you may want to move the application ref out of the loop, it does not need to be created for each file
Set appRef = CreateObject("Illustrator.Application")
For Each pdfFile In pdfFiles
'
Set docRef = appRef.Open(pdfFolder & "\" & pdfFile.Name)
'
Next
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more