PDA

View Full Version : PdfPen Applescript help.




M-B-P
Jun 30, 2011, 10:02 PM
Hey everyone,

I am using PdfPen 5 and need some help making an applescript command for PdfPen.

I am looking to create a folder action, where I would drop a pdf file into a folder and make some modifications to the pdf file.

1. I need a dialog box to ask "Is there a coversheet" with a "yes" or "no" button.
- -If the user answers yes, then delete page 1 of the document

2. Next, if the page count of the document is less than 10, then end the script, otherwise continue

3. If the remaining page count of document is 19
->then delete pages 5 through 19
or If the remaining page count of document is 20
->then delete pages 6 through 20
4. Then I need to make imprint A on page 1, imprint B on page 2, imprint C on page 3, etc. [I learned how to make the imprints, but don't know how to assign imprint A to page 1, imprint B to page 2, etc.)

Purpose: The documents are typically 19-20 pages long, with the first page being a coversheet, which can be deleted. The next four pages are the important pages that need an imprint. The remaining pages (around 15-16) are unimportant. I know this can be done manually, but it would be really inefficient because I go through about 100 of these documents a week. So a folder action that would allow me to drop a pdf file into and automate this whole process will be really nice.

I don't know much other than the basics about programming, and almost nothing about applescript. Any input will be appreciated. Even if you can only help one single part of the problem, I will be very thankful. If you have any other suggestion on how to solve this problem, please give your input.



M-B-P
Jul 1, 2011, 11:58 PM
No replies? Maybe I didn't explain myself clearly.

Well, I managed put together the script to delete the pages. However, I am stuck on part 4, getting the imprints(png overlays) on the right pages.

I will be working with 3 pages on a pdf file. I have defined to path for each image. Page 1 of the pdf get imprint 1, page 2 get imprint 2, etc.

This is the code that I have put together.
------------------------------------------------------------------------
------------------------------------------------------------------------

set theFilePage1 to "/Users/UserName/Documents/Imprints/Page1.png"
set thePathPage1 to POSIX path of theFilePage1

set theFilePage2 to "/Users/UserName/Documents/Imprints/Page2.png"
set thePathPage2 to POSIX path of theFilePage2

set theFilePage3 to "/Users/UserName/Documents/Imprints/Page3.png"
set thePathPage3 to POSIX path of theFilePage3

tell application "PDFpen"
set PageNumber1 to 1
set PageNumber2 to 2
set PageNumber3 to 3


make new imprint with properties {path:thePathPage1} at beginning of imprints of page PageNumber1 of document 1
make new imprint with properties {path:thePathPage2} at beginning of imprints of page PageNumber2 of document 1
make new imprint with properties {path:thePathPage3} at beginning of imprints of page PageNumber3 of document 1
end tell

------------------------------------------------------------------------
----------------------------------------------------------------------
The code compiles without any errors. I am having one problem.

The only page that overlays the image (imprints it) is the first page of the document. The second and third page do not imprint anything, even though I don't receive any errors in compiling or running the script.

I noticed something odd under the "replies" section, which I colored in red. This is what it read:

------------------------------------------------------------------------
-----------------------------------------------------------------------
tell application "PDFpen"
make new imprint with properties {path:"/Users/UserName/Documents/Imprints/Page1.png"} at beginning of every imprint of page 1 of document 1
--> imprint 1 of page 1 of document "Full PDF.PDF"
make new imprint with properties {path:"/Users/UserName/Documents/Imprints/Page2.png"} at beginning of every imprint of page 2 of document 1
--> imprint 1
make new imprint with properties {path:"/Users/UserName/Documents/Imprints/Page3.png"} at beginning of every imprint of page 3 of document 1
--> imprint 1
end tell
Result:
imprint 1 of application "PDFpen"

------------------------------------------------------------------------
-----------------------------------------------------------------------

The first page, which imprinted the png, returned-> imprint 1 of page 1 of document "Full PDF.PDF"

The other pages returned -> Imprint

I've only played around with applescript for about a day, so I don't know much about it, so any help will be appreciated.

M-B-P
Jul 2, 2011, 12:21 PM
Nevermind, got it to work.
There was a problem with the path.