Getting Page Count for a Multi-Page PDF file using Illustrator script?
Does anyone know how to get the page count of a multi page PDF file? I know you can then open each page using the PDFFileOptions (pagetoopen). But I need to know up front how many pages there are to loop thru to open each page and process each page.
Any Ideas?
This script i did for photoshop:
OK so lets do it working on WIN and MAC without any shell script.
This solution is not the best but its working.
I used Try catch to solve it.
Only issue is that you should at least somehow know how many pages you expect in pdf.. this mean if you are working with books or flyers...
Then set the maxPagesCount to that number.
I am working with pdfs with max 20pages.. so i start open the 20 then 19 then 18 and when i am success i know the amount of pages.
Its not the quicker way but its usable.
var maxPagesCount = 20;
var actPagesCount = maxPagesCount;
var opts1 = new PDFOpenOptions();
opts1.usePageNumber = true;
opts1.antiAlias = true;
opts1.bitsPerChannel = BitsPerChannelType.EIGHT;
opts1.resolution = 10; //it will load faster the test page
opts1.suppressWarnings = true;
opts1.cropPage = CropToType.MEDIABOX;
myFunction = function () {
try {
app.displayDialogs = DialogModes.NO;
var fileList = openDialog();
for (i = 0; i < fileList.length; i++) {
actPagesCount = maxPagesCount;
getPagesCount(fileList[i],maxPagesCount);
alert(actPagesCount);
} catch (exception) {
alert(exception);
getPagesCount = function (checkFile, lastPageID) {
try {
for (var checkPage = lastPageID; checkPage > 0; checkPage--) {
opts1.page = checkPage;
var docRef = open(checkFile, opts1, false);
docRef.close(SaveOptions.DONOTSAVECHANGES);
actPagesCount = lastPageID;
return;
checkPage=0;
} catch (exception) {
// Look for next page
checkPage--;
getPagesCount(checkFile,checkPage);
Similar Messages
-
Safari 7.0.6, using Adobe Acrobat 11.0.10, isn't rendering pdf files in the Print Preview screen. Additionally, only a single, blank page prints for a multi-page pdf document. Any ideas?
Figured it out. It had nothing to do with the software levels of Safari or Adobe Acrobat. Here's the fix:
Open Finder/Applications
Search "Internet Plug-Ins"
Move any Adobe plug-ins to the trash
Quit Safari
Launch Safari
Your pdf document should now render in Print Preview and print properly. -
How to invoke alt-text for images in a PDF file by Automation
Hi,
Can any one help me?
How to invoke Alt-text for Images in a PDF file using script?
Thanks for looking into this.
Regards,
SudhakarWhat do you mean "invoke" alt-text? If Alt-text is there, then it will be presented to a screen reader.
-
Hello, I'm a beinnger apple scripter, and I have 2 questions. First, im trying to find the code to generate a page count for the front document of preview. I tried something like this:
choose file with prompt "Count the number of pages in this PDF file:" without invisibles
do shell script "/usr/bin/mdls -name kMDItemNumberOfPages " & quoted form of POSIX path of result & " | /usr/bin/grep -o '[0-9]\\+$'"
But I dont want to have to choose a file with the prompt, and Im not sure how to get the path or POSIX path of an open pdf that is the front document in prievew to then use that directory to select the file to run the shell script on. This is one step in a much larger sequence of automator/apple script commands for large print jobs.
The large scale view is:
1. seleting a group .musx Finale 2014 files and creating pdfs of all the documents
-Achieved with Automator stuff: [Get selected finder items] [open finder items with Finale 2014] [run applescript to convert to pdf all the open files] (which I have working but without a proper repeat condition)
2. sorting those those exports into even/odd groups
3. making the even pages 2 up with a create booklet plugin
3. combinging even/odd group pdfs in their respective folders
4. sending the 2 up evens to 1 printer, and the singes to another printer.
but at this stage in the code/automator this is what i'll need to be doing:
1. Several pdf documents will be open and I need to determine the page count of the front document.
2. With that result I need to determine if the pagecount is even or odd.
3. If its even, I need to save as pdf in a file folder /desktop/PDF Export/Doubles
- if its odd, I need to save as pdf pages from 1 to (pageCount -1) to /desktop/PDF Export/Doubles, and pages (pageCount) to (pageCount) to desktop/PDF Export/Singles. (example: A 5 page pdf will send pages 1-4 to folder "Doubles", and pages from 5 to 5 to Singles, A 1 page pdf will only send a copy to the folder "Singles." A 2 page pdf will send both pages to "doubles"
4. once the even/odd pages have had pdfs made in the either or both of the folders, Im going to close the document and repeat for all other open pdfs.
Which also brings me to my 2nd repeat condition question: how can I repeat (print, save as pdf, close) commands for open files and end the script once all files are closed? This can help me both at this stage, as well the coding stage before in creating the pdfs from open Finale/sibelius .sib/.musx files
would it be something like this?:
If front document exists
try
tell application "preview"
<bla bla>
end try
end tell
At stage 1 of the large scale i've gotten the files to export pdfs and close multiple files, but if i say "repeat 4 times" and i have 3 files it can do those commands but it gets stuck trying to repeat the code one more time. I need the repeat amount x to be the # of items in selection from the the original finder window.
Thanks for the help!The following AppleScript will get the POSIX path and filename of the current PDF file. It will just return the integer value for page count. Note: The path retrieved is the actual path to the PDF file, unless it is on the Desktop. In the latter case, the path will be ~/Library/Containers/com.apple.Preview/Data/Desktop/filename.pdf.
The script assumes that the following folders exist, otherwise you will need a try block to test for their presence.
The AppleScript dictionary for Preview does not provide a page dictionary entry, that would make a repeat loop and page range possible for saving individual page ranges.
set pdfDoubles to POSIX path of ((path to desktop) & "PDF Export" & Doubles)
set pdfSingles to POSIX path of ((path to desktop) & "PDF Export" & Singles)
tell application "Preview"
-- gets quoted POSIX path and filename
set pdfFile to (get path of front document)
set pdfName to (get name of front document)
log pdfName
set cmdArg to "/usr/bin/mdls -name kMDItemNumberOfPages " & pdfFile ¬
& " | egrep -o \"(\\d+)\""
set pageCnt to do shell script cmdArg
display dialog pageCnt
if pageCnt mod 2 is 0 then
-- even
-- save pdfName in pdfDoubles
else
-- save pdfName in pdfDoubles
-- save individual pages in pdfSingles
end if
end tell -
Laserjet 42x0/43x0 printers: what is the expected life span by page count for these models?
The document here lists the monthly duty cycle at 125,000 to 200,000 pages per month and the devices typically have a one year warranty. Based on this I would expect at least 1.4 - 2.4 million pages for printer life with appropriate maintenance.
Bob Headrick, HP Expert
I am not an employee of HP, I am a volunteer posting here on my own time.
If your problem is solved please click the "Accept as Solution" button ------------V
If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V -
I can't edit multi page PDF file in Illustrator at once.
I made 30-page PDF file in Illustrator last week.
Yesterday my co-woker eited and sent to me.
but i can't open 30-pages all in once
instead of this window pops up and only 1 page of all open it.
How do I open all the page and edit it once without any script?
Last week I Could open it without asking.Keep a backup of the .ai file. Your coworker should not be making edits to pdfs, only commenting tools. Tell your coworker not to do that again, unless they know what they are doing (eg: are creating from scripts). If they persist, or this is your boss, lock the PDF with security protection.
This script may help you. Keep in mind the popular pdf preset smallest file size converts to RGB, so your color will change and l;ayers possibly flattentin if Illustrator editing capabilites is lost.
https://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1698047 -
RH11 404 - Page Not Found when linking to PDF file from search results using IE9 and IE10
I'm using RH11 (11.0.3.268) and I've included a number of PDF files as baggage files. The hyperlinks on the pages work fine and display the PDF files in a separate window, as expected. However, when searching for these same PDF files using the Search tab, I'm getting a 404 error with the filename. The description on the error shows the filename and says the "the requested resource is not available." This is occurring using IE9 and IE10. And, it only happens within the application, which packages the WebHelp with a war file.
I searched the forum and found where someone was having the same problem on Firefox, but was fine on IE. But, as mentioned, I'm finding it on IE.
Thoughts on how to fix this error?Is the WAR file extracted at the point when the search is done? If not, I would expect it to fail.
See www.grainge.org for RoboHelp and Authoring tips
@petergrainge -
How do I open to a specific page or destination in a pdf file using Buddy API Xtra?
Hello,
I'm working with a CD ROM catalog that utilizes the Buddy API Xtra to open PDF files when a link is clicked. The client would like to be able to open to a specific page within a pdf file.
I can open a pdf file using the Buddy API baOpenfile() function but I'm having trouble opening to a specific page when I add #page=4:
baOpenfile("@\pdfs\Powder Cores\Magnetics_Powder_Core_Catalog_2011.pdf#page=4","normal")
I've also tried working with the code below which seems to me like it should work... I didn't realize that the "open..." part of it was a function in Director.
on mouseUp me
pageNum = 4
theApp = baShortFileName(baFindApp("pdf"))
theDoc = baShortFileName("@\pdfs\Powder Cores\Magnetics_Powder_Core_Catalog_2011.pdf")
theArgs = "/s /A page=" & string(pageNum) & "&pagemode=bookmarks"
-- (translates to "/A page=4" in this example)
open theApp && theArgs && theDoc
end
Thoughts?
Thank you in advance!Thank you Dee! This works perfect!
It would be cool to know how to use bashell() for this.
The help files give the following examples:
Result = baShell( Operation, Filename, Args, WorkDir, State )
ok = baShell( "open", "c:\windows\notepad.exe", "myfile.txt" , "", "normal" )
ok = baShell( "edit", "myfile.htm" , "", "", "normal" )
So I tried:
on mouseUp me
-- Close the program group
tWindowList = baWindowList( "" , "pdf" , false )
if tWindowList <> [] and count(tWindowList) > 0 then baCloseWindow(tWindowList[1])
pageNum = 4
theApp = baFindApp("pdf")
theDoc = _movie.path & "pdfs\Powder Cores\Magentics Powder Core Catalog.pdf"
theArgs = "/A ""E&"page="&string(pageNum)&"=OpenActions""E
baShell( "open", theApp, theDoc , theArgs, "normal" )
end
It opens the pdf file without going to a specific page. Any thoughts as to why it wouldn't accept theArgs?
Thanks again! -
Printing web page to pdf file using Acrobat Standard 9
When I print a web page to a pdf file, the text in the file is mostly garbled. I have no problems in creating pdf files from MS office or other software. I have Windows 7 Home.
Any help will be appreciated.
ThanksI do have Internet Explorer 9 and I was able to print web pages correctly following your suggestions.
Thanks for your help.
Date: Sat, 12 Nov 2011 06:53:59 -0700
From: [email protected]
To: [email protected]
Subject: Printing web page to pdf file using Acrobat Standard 9
Re: Printing web page to pdf file using Acrobat Standard 9
created by Bill@VT in Acrobat Windows - View the full discussion
There were problems with IE9 on it's initial release and that may be what you are seeing if that is the browser (you did not indicate the browser and that may be a key). If you have a different browser you might try that one with the same pages to see if it browser related.
By saying garbled it sounds like the fonts did not make it or you have selected "Use Local Fonts" in Acrobat. Try checking the latter first. Then check if the fonts are embedded in the PDF by checking the document properties (ctrl-D). If they are not, go back to the browser and select the press or print job options before printing and see if they get embedded and if your problem is resolved.
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4021509#4021509
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4021509#4021509. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Acrobat Windows by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746. -
Open a PDF file in illustrator with multiple pages CS6
Hi all,
Maybe someone could tell me if this feature is already available...
I really need to use this feature... maybe someone has a Idea? i need to translate and edit a PDF file that was original designed by our factory... they had hired a company to make the documentation but the company did go bankrupt so we can't get the original files en need the edit the compressed PDF File...
I Hope someone could help me...
Greetz
Leroyhi,
16 PDF Files with 4 pages Each..
don’t know what kind of text it is…
about image quality… if there is a method to editing of the PDF .. then I could Replace the Images …
Van: Monika Gause [email protected]
Verzonden: woensdag 22 augustus 2012 13:31
Aan: AcidusW01
Onderwerp: Open a PDF file in illustrator with multiple pages CS6
Re: Open a PDF file in illustrator with multiple pages CS6
created by Monika Gause <http://forums.adobe.com/people/Monika+Gause> in Illustrator - View the full discussion <http://forums.adobe.com/message/4639138#4639138 -
Really having problems with organising documents in pages. For example, deleting pages deletes the whole section and I cannot insert a section break as its greyed out & sending an object to background deletes several pages and trying to insert a text box autmatically creates new pages- what the **** is going on??? Is this programme really this badly thought out? I thought everything apple was supposed to be intuitive!?!?!? Help.
You can not insert a section break into a textbox.
You appear to have a lot of objects with wrap set, that once you take them out of the flow of text (by sending them to the background) causes the text to reflow and contract into fewer pages. Pages is almost unique in the way it forms up pages in Word Processing mode only so long as there is text on them.
I suspect you probably have hammered away at returns, spaces and tabs as well to position things, which only works to add to the mess.
Download the Pages09_UserGuide.pdf available under the Help menu and swot up a bit on how it works.
You may find this a usueful resource as well:
http://www.freeforum101.com/iworktipsntrick/
Peter
PS There is quite a lot of programming in OSX that is far from "intuitive". Pages is easy at one level, when using the templates, otherwise it can be quite frustrating. -
I'm trying to get the count for each row to total count for each month
Something like this
Hardware | Jan
Monitors | 5
Processors | 137
Printers | 57
etc........
How can I write a query for this. I can get the Hardware column but don't know how to get the next column.If you can provide more data like sample input DML statements it would have been wonderful..
Assuming is , you need a pivot. Here is an article on basic Pivot..
http://sqlsaga.com/sql-server/how-to-use-pivot-to-transform-rows-into-columns-in-sql-server/
something like this may be..
DECLARE @Input TABLE
Hardware VARCHAR(20),
[Date] VARCHAR(20)
INSERT INTO @Input VALUES('Monitor', '01/01/2014'), ('CPU', '01/01/2014'), ('Monitor', '01/03/2014')
, ('ABC', '01/01/2014'),('Monitor', '02/01/2014')
;WITH CTE AS
SELECT Hardware, LEFT(DATENAME(M, [Date]),3) AS [MonthName] FROM @Input
SELECT *
FROM
SELECT Hardware, [MonthName], COUNT(Hardware) AS Count FROM CTE GROUP BY Hardware, [MonthName]) a
PIVOT (MAX([Count]) FOR [MonthName] IN ([Jan], [Feb])) pvt
Please mark as answer, if this has helped you solve the issue.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
I get two-sided option for normal printing, but
I can't get duplex print option for pdf files using Adobe ReaderXI 11.0.04, Mac 10.8.5 with HP Officejet Pro 8600. HP says it's an Adobe problem. I'm stuck.
Thanks in advance.
VOIt depends where the pdf is located. If in the Finder or in an attachment to
an email in Entourage, the message is ³You can¹t open the application
³Acrobat Reader 5.0² because PowerPC applications are no longer supported².
If an attachment in an email that has come via Safari, the message is
³Safari can¹t open the file because no available applications can open it².
In each case the menu bar is Finder or Entourage or Safari as the case may
be. -
How can I get the shutter count for my Canon 7D Mark II using Windows XP?
How can I get the shutter count for my Canon 7D Mark II using Windows XP? I've been looking lots of places and doing some file uploads, but I can't seem to find anything. I'm wary of downloading software I know nothing about. Any help is greatly appreciated.
Solved!
Go to Solution.Nevermind, just, sort of answered my own question. Doesn't work on XP, but using a Win 7 'puter I was able to use Shutter Count, which now works w/ the 7D Mark II.
-
How to scan more pages into one PDF file using hP inkjet 2515
Dear friend
How to scan more pages into one PDF file using hP inkjet 2515Dear friend
How to scan more pages into one PDF file using hP inkjet 2515
Maybe you are looking for
-
Major difficulties installing Windows 7/8.1
Firstly, I'd like to apologize for my not so perfect English, but nevertheless - here's my cry of help. Recently, I've had a "pleasure" of messing up my already installed Windows on my iMac (27-inch, Mid 2011) that has been installed for almost 2-3 y
-
Ipad won't start; trying to restore thru itunes, but get the message - can't restore because ipad is not set up. It was set up and has been in use for about a year. What do I do now?
-
Transferring apps from my macbook pro to new macbook air
my old macbook pro froze. i bought a new macbook air and need to transfer my applications. How do I do that?
-
Help with Flash smooth transitions
Can someone please tell me how I can make a Flash movie like this one here where it transitions smoothly from one image to another. I have been using Flash for a while at a basic level, but my attempts at such movies always seem to be jerky. When I c
-
Imovie 5.0.2 but idvd 4.0.1
Help! Recently upgraded to Leopard. I guess it updates imovie to version 5.0, but does not update idvd? Still have old idvd 4.0 which does not open in Leopard. Didn't know this when creating an imovie. What can I do to create a DVD with my imovie pro