Author Topic: Rasterizing PDF's  (Read 4370 times)

0 Members and 1 Guest are viewing this topic.

Offline larsen67

  • Sr. Member
  • ****
  • Posts: 459
  • Karma: 10
  • Gender: Male
Rasterizing PDF's
« on: April 10, 2007, 09:29:39 AM »
Always being asked to do this to one format or other. Here is the bones of a script I came up with to handle single and multi-page PDF's. Changing the open and save options should be a doddle. Requires Acrobat in addition to Photoshop.

001   set TodaysDate to do shell script "date \"+%d-%m-%y\""
002   -- Create new folder to save to
003   tell application "Finder"
004        set RasterImages to make new folder at desktop with properties
005             {name:"Rasterized PDF's " & TodaysDate}
006   end tell
007   -- Check for application processes else launch
008   tell application "System Events"
009        if not (exists process "Acrobat") then
010             launch application "Adobe Acrobat 7.0 Pr#2CB915"
011        end if
012        if not (exists process "Adobe Photoshop CS2") then
013             launch application "Adobe Photoshop CS2"
014        end if
015   end tell
016   -- Set Photoshop settings
017   tell application "Adobe Photoshop CS2"
018        set display dialogs to never
019        set UserPrefs to properties of settings
020        set ruler units of settings to pixel units
021        -- set background color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:0}
022        -- set foreground color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:100}
023   end tell
024   -- Get list of PDF's
025   set Q1 to "Do you want to include all the subfolders" & return & "within your folder selection?"
026   set theDialog to display dialog Q1 buttons {"No", "Yes"} default button 1 with icon note
027   if button returned of theDialog is "Yes" then
028        set inputFolder to choose folder with prompt "Where is the top level folder of PFD's?" without invisibles
029        tell application "Finder"
030             set filesList to (files of entire contents of inputFolder whose name extension is "pdf")
031        end tell
032   else
033        tell application "Finder"
034             set inputFolder to choose folder with prompt "Where is the folder of PFD's?" without invisibles
035             set filesList to (files of inputFolder whose name extension is "pdf")
036        end tell
037   end if
038   set countA to count of filesList
039   if countA = 0 then
040        display dialog "This folder contains no PDF files to rasterize!" giving up after 2
041   end if

Offline larsen67

  • Sr. Member
  • ****
  • Posts: 459
  • Karma: 10
  • Gender: Male
Re: Rasterizing PDF's
« Reply #1 on: April 10, 2007, 09:31:20 AM »
The rest:

001   -- Loop through the files in list
002   repeat with aFile in filesList
003        tell application "Finder"
004             set theFile to aFile as alias
005        end tell
006        -- Open in Acrobat to count the pages
007        tell application "Adobe Acrobat 7.0 Pr#2CB915"
008             -- activate
009             open theFile with invisible
010             tell document 1
011                  set PageCount to count of pages
012             end tell
013             close document 1 saving no
014        end tell
015        -- Loop Photoshop through the page count
016        repeat with i from 1 to PageCount
017             tell application "Adobe Photoshop CS2"
018                  activate
019                  open theFile as PDF with options
020                       {class:PDF open options, bits per channel:eight, constrain proportions:true, crop page:trim box, mode:CMYK, page:i, resolution:300, suppress warnings:true, use antialias:true, use page number:true}
021                  set docRef to the current document
022                  tell docRef
023                       flatten
024                       -- New file naming options
025                       set docName to name of docRef
026                       set ASTID to AppleScript's text item delimiters
027                       set AppleScript's text item delimiters to " "
028                       set docName to text items of docName
029                       set AppleScript's text item delimiters to "_"
030                       set docName to docName as string
031                       set AppleScript's text item delimiters to "-"
032                       set docName to text item 1 of docName
033                       set AppleScript's text item delimiters to ASTID
034                       if PageCount = 1 then
035                            set newFileName to (RasterImages as string) & docName & ".tif"
036                       else
037                            set fileNum to ""
038                            repeat until (length of (fileNum as text)) = (length of (PageCount as text))
039                                 if fileNum = "" then
040                                      set fileNum to i
041                                 else
042                                      set fileNum to "0" & fileNum
043                                 end if
044                            end repeat
045                            set newFileName to (RasterImages as string) & docName & "_" & fileNum & ".tif"
046                       end if
047                  end tell
048                  save docRef in file newFileName as TIFF with options {byte order:Mac OS, embed color profile:true, image compression:LZW, save alpha channels:false, save layers:false}
049                  close current document without saving
050             end tell
051        end repeat
052   end repeat
053   -- Set ruler units back to user prefs
054   tell application "Adobe Photoshop CS2"
055        set ruler units of settings to ruler units of UserPrefs
056   end tell

Offline Glenn

  • Full Member
  • ***
  • Posts: 139
  • Karma: 4
  • Gender: Male
Re: Rasterizing PDF's
« Reply #2 on: April 11, 2007, 03:43:30 AM »
This script should carry a warning about not doing it for high quality print purposes. :P

Offline marcusstringer

  • Newbie
  • *
  • Posts: 22
  • Karma: 1
  • Gender: Male
    • Midland Typesetters
Re: Rasterizing PDF's
« Reply #3 on: April 11, 2007, 05:04:09 PM »
Hi guys,
I am feeling a little bit dumb today, but why would you want to rasterise PDFs  ???

Offline ZvyaginzevaE

  • Visitor
  • Posts: 1
  • Karma: 0
  • Gender: Male
    • Смотрела хентай -  Василиса
Rasterizing
« Reply #4 on: July 09, 2011, 12:37:14 AM »
There are a lot of shareware type programs out there for the PC, and Id guess for Macs too.

Just google them and you should find a bunch.

Generally what you do is create a document in your normal manner, then you "print" it to a virtual printer, which is the program creating the PDFs.

What you get is the print image of your document, saved in PDF format.