Copy link to clipboard
Copied
SCRIPT TO IMPOSE AN INCOMING PDF
I need a script that uses a modified version of the sample script supplied with CS4 (called PlaceMultiPagePDF.jsx, or the Applescript equivalent). Instead of placing the pages sequentially:
1 –> 1
2 –> 2
3 –> 3...
the script would place the PDF pages in 2-Up Perfect Bound imposition order. The arrangement is outlined in the attached document. It would be very flexible to allow for any combination of signature lengths. As a simple example, for a 8-page booklet, the script would place the pages from the PDF in this order in InDesign:
1 –> 2
2 –> 3
3 –> 6
4 –> 7
5 –> 6
6 –> 5
7 –> 4
8 –> 1
I have written a Pidgin BASIC code that handles the page sequencing (see attached document), but I have to steer clear of actually scripting it -- my programming skills end at MS BASIC ca 1986 (which I still use occasionally on my 512k Fat Mac as I can't get anything out of modern BASIC). Why did they ever complicate things with Java and the like?
Anyway, I have manually stepped through my flowchart several times and haven't come across an error, so all that is required ("all" he says, in hope) is to interrupt the pages coming from the PDF, and instead of 1 -> 1, 2->2... the script steps in and says "Whoa there... you're not going to page 315, you're going to page 297. Would it be that simple? As simple as inserting a bit of renumbering code as per my flowchart?
I hope so.
If anyone is interested, please let me know.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I thought I'd have a look at the script to see what I could make of it. The last part is this:
1. function myPlacePDF(myDocument, myPage, myPDFFile){
2. var myPDFPage;
3. app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
4. var myCounter = 1;
5. var myBreak = false;
6. while(myBreak == false){
7. if(myCounter > 1){
8. myPage = myDocument.pages.add(LocationOptions.after, myPage);
}
9. app.pdfPlacePreferences.pageNumber = myCounter;
10. myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
Line 8: is that creating a new page?
Line 9: Is that selecting the next page from the PDF? i.e. if myCounter = 3, page 3 of the PDF is going to be placed.
Line 10: Is that the one actually doing the placing?
QUES
In Line 9, if instead of myCounter, an array was used with myCounter acting as a pointer -- Array (myCounter) -- and that array held the imposition transform, would that work?
For example, normally the pages would come in as:
PDF InDesign
1 -> 1
2 -> 2
3 -> 3
But the imposed pages might be (these are just made up):
PDF InDesign
5 -> 1
4 -> 2
17 -> 3
Array would therefore need to be set up as:
Array(1) = 5
Array (2) = 4
Array (3) = 17
And line 9 would be changed to:
app.pdfPlacePreferences.pageNumber = Array(myCounter);
Copy link to clipboard
Copied
This is turning into a one-person thread, but I may have thought up an easier solution.
Instead of using a script to impose the import of a PDF, I've just realised I could do the same thing when I export the file from InDesign to PDF -- meaning, if I type in a long series of numbers in the Print Range field in imposition order, the PDF will already be in imposed order when I use PlaceMultipagePDF to place the PDF back into InDesign.
Example: For an 8-page booklet, I would export in the following order: 8, 1, 2, 7, 6, 3, 4, 5, by entering those numbers in the Page Range field. Then use the script to import the file.
So, if the modification of the PlaceMultipagePDF script is unwieldly, maybe someone could implement the routine for generating the number sequence (see my attachment in a previous post). The output would need to be separated by commas and placed in a blank InDesign document, or put on the clipboard. The user could then just copy, or paste, the numbers to the Page Range field.
Copy link to clipboard
Copied
Sorry to interrupt your speaking to yourself , but if you have a script that generates the proper sequence, you might as well put that into the program you already have.
A few answers to a couple o'questions you raised:
myPage = myDocument.pages.add(LocationOptions.after, myPage);
is that creating a new page?
Yes. It's put right after the page referenced by myPage.
app.pdfPlacePreferences.pageNumber = myCounter;
Is that selecting the next page from the PDF? i.e. if myCounter = 3, page 3 of the PDF is going to be placed.
Yes. And probably no -- usually, indexes are counted starting at 0, so if myCounter is 3, it's page 4 you get. "Probably" because the OMV Help doesn't expand on this; I'd have ta try it.
myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
Is that the one actually doing the placing?
Sure.
In Line 9, if instead of myCounter, an array was used with myCounter acting as a pointer -- Array (myCounter) -- and that array held the imposition transform, would that work?
Absoludiddlietooty.
Here's one for you:
.. [76 pages] broken into 3 signatures: 24, 28, 24. ..
Is that a fact, as taken from years of experience, or are you guessing based on 2nd hand information on signature size? Neither 24 nor 28 are standard signature sizes. 24 just may be (and, typically, you'd be having some nonstandard page size -- square, for example) but I'm having a hard time imagining 28 pages.
... 2-Up Perfect Bound ...
To calculate that, I'd need to know the exact signature size -- I'm pretty sure it isn't one of 24 or 28. I'd also need to know if the binder prefers a partial (not completely filled) signature as the last or the last-but-one (the latter is preferred by the binders I know; a smaller last signature may not get glued properly), and if he prefers the smallest signature possible -- typically, 4 pages -- wrap around the very last full sig.
Apart from that, it's really easy. The proper order for a 16-up sig is
1 16 13 4
8 9 12 5
for the front (clean) print run, and
3 14 15 2
6 11 10 7
for the back print run. Top row inverts; bottom row is right-side up. Add 16 to each number per next sheet. If a sheet doesn't get filled entirely, pad to the next 4 pages and ask the binder how he handles these.
I may have unintentionally mirrored the entire sig -- I learned to do this with negatives. Other than that, you can write these numbers on a portrait A4 and fold it. Besides, your binder may use another folding sequence.
Copy link to clipboard
Copied
Some more information that would also be needed.
This is what the first front sheet of a complete signature for 16 pages looks like:
Notice the center lines, both horizontally and vertically. I put these in the exact center of the sheet, but actually, the press might need some extra slug at the bottom (that's where the printing plate is mounted into the press).
Also notice that sets of two pages touch eachother in what will be the back of the book (the fold comes here), and that there is some space left inbetween each set of two pages. These are necessary for the binder -- the edges will be cut on three sides, after folding and binding.
So you also need to know the exact sheet dimensions, as well as the plate slug (for printing) and whether the binder prefers the excess white space to be evenly distributed left/center/right and top/center/bottom, or he may have a preference for a certain distance.
Copy link to clipboard
Copied
Something I didn't mention from Jongwares's post. I want to keep this simple, so slugs, bleeds, crop marks are not involved. This is simply a way of using InDesign to get an imposed PDF without involving any other program. If a user wants slugs, larger paper size and so on, couldn't they alter the InDesign document after the imposed PDF is imported?
For my needs, the simpler the better.
Copy link to clipboard
Copied
Quoting Guy Burns <forums@adobe.com>:
Something I didn't mention from Jongwares's post. I want to keep
this simple, so slugs, bleeds, crop marks are not involved. This is
simply a way of using InDesign to get an imposed PDF without
involving any other program. If a user wants slugs, larger paper
size and so on, couldn't they alter the InDesign document after the
imposed PDF is imported?
For my needs, the simpler the better.
>
Copy link to clipboard
Copied
I have changed tack as per a previous post, and think it better if I control imposition on the way from InDesign to PDF, instead of from the PDF to InDesign. Thus, all I need is a number generator and I'm hoping someone can put that together for me. The output should be separated by commas, and dumped to the clipboard.
All the variables are integers, except HALFWAY which may be a fraction.
LIST OF PARAMETERS
The script should explicitly assign all elements of the "S" array the value "0", so that the user can easily locate and overwrite them. The zeroes have a second use: when the script detects a "0" it stops and outputs the numbers to the clipboard, separated by commas.
START = 1
S(1) = 0
S(2) = 0
S(3) = 0
.
.
S(30) = 0
LIST OF VARIABLES USED IN THE SCRIPT
BEGIN
END
HALFWAY
A, B, C, D
FLOWCHART
N = 1
BEGIN = START
END = START - 1 + 4*S(N)
LOOP:
A = END
B = BEGIN
C = BEGIN + 1
D = END - 1
HALFWAY = (BEGIN + END)/2
WHILE B < HALFWAY
Print A (then comma)
Print B (then comma)
Print C (then comma)
Print D (then comma)
A = A - 2
B = B + 2
C = C + 2
D = D - 2
WEND
N = N + 1
IF S(N) = 0: STOP
BEGIN = END + 1
END = 4*S(N) + END
GO TO LOOP
SAMPLE RUN
For inputs of:
START = 1
S(1) = 3
S(2) = 1
S(3) = 0
The output should be: 12, 1, 2, 11, 10, 3, 4, 9, 8, 5, 6, 7, 16, 13, 14, 15
Copy link to clipboard
Copied
var numPages = prompt ("Number of pages", "1000", "Enter number of pages");
if (numPages == null)
alert ("Daisy, Daisy ... Goodby, Dave ...");
else
{
if (numPages & 3)
{
alert ("What are you doing, Dave? My mind is going.");
} else
{
tempframe = app.activeDocument.textFrames.add();
tempframe.geometricBounds = [0,0,100,100];
result = "";
curr = 1;
while (curr < numPages)
{
if (result) result += ",";
result = result+numPages+","+curr+","+(curr+1)+","+(numPages-1);
curr += 2;
numPages -= 2;
}
tempframe.insertionPoints[-1].contents = result;
tempframe.texts[0].select();
app.copy();
tempframe.remove();
}
}
A few notes. This creates a booklet imposition number order. It needs an active InDesign document, because you cannot "put" something on the clipboard. You have to write it into a document, then select and copy it. Admittedly, perhaps VB can do this.
I have no idea at all what you mean with all those variables, and with your S[0] = 0 stuff ...
The output should be: 12, 1, 2, 11, 10, 3, 4, 9, 8, 5, 6, 7, 16, 13, 14, 15
That cannot be stapled, as in contiguous 2-up; it needs to be glued together (or was that your intention after all? I'm getting mighty confused here).
Copy link to clipboard
Copied
Quoting "[Jongware]" <forums@adobe.com>:
var numPages = prompt ("Number of pages", "1000", "Enter number of pages");
if (numPages == null)
alert ("Daisy, Daisy ... Goodby, Dave ...");
else
{
if (numPages & 3)
{
alert ("What are you doing, Dave? My mind is going.");
} else
{
tempframe = app.activeDocument.textFrames.add();
result = "";
curr = 1;
while (curr < numPages)
{
if (result) result += ",";
result = resultnumPages","curr","(curr1)","(numPages-1);
curr += 2;
numPages -= 2;
}
tempframe.insertionPoints[-1].contents = result;
tempframe.texts[0].select();
app.copy();
tempframe.remove();
}
}
>
A few notes. This creates a booklet imposition number order. It
needs an active InDesign document, because you cannot "put"
something on the clipboard. You have to write it into a document,
then select and copy it. Admittedly, perhaps VB can do this.
I have no idea at all what you mean with all those variables, and
with your S[0] = 0 stuff ...
>> The output should be: 12, 1, 2, 11, 10, 3, 4, 9, 8, 5, 6, 7, 16, 13, 14, 15
That cannot be stapled, as in contiguous 2-up; it needs to be glued
together (or was that your intention after all? I'm getting mighty
confused here).
>
Copy link to clipboard
Copied
S Hopkins wrote:
Quoting "[Jongware]" <forums@adobe.com>:
[...] I'm getting mighty confused here).
Sorry, Shirley, but your recent posts seem to have been sent by email and appear as the full previous message, with nothing new added by you. Perhaps switching off "Quote Entire Message" will help ...
[Jw]
Copy link to clipboard
Copied
Thanks for the script, Jongware, but it is not quite what I need.I think yours generates one huge saddle-stitch arrangement, whereas I want the ability to generate a group of smaller ones (effectively a variable-length perfect-bound arrangement), thus my listing of "numbers of sheets" in each signature as the input.
Someone has been kind enough to write an Applescript that does the job. I haven't fully tested it, but really, what is there to test? It seems to work for me. One problem: it can't handle InDesign page numbers other than plain numbers, but I can work around that if I need to. Imposition from InDesign here I come -- run the script, paste the output into Page Range of the Export dialog box, and stand back while the bytes fly.
If a script could be run from the open Export window (to allow setting up of the various options), this script (or a JS version) could be carried one step further, not that I'm wanting to at this stage. The start page and the various signature lengths could be entered; options set up in the Export window; then the script could:
1. Generate the imposed number sequence and place them into the Page Range field of the active document;
2. Export the PDF;
3. Call on PlaceMultipagePDF, set to automatically create a new InDesign document and place the PDF pages.
It would be a very flexible, simple way of obtaining variable-length, 2-Up imposition from InDesign.
SCRIPT TO IMPOSE VARIABLE-LENGTH 2-UP SIGNATURES
set start to 1 -- overwrite with your starting page number
set s to {8, 1, 0} -- overwrite with the number of pages in each signature; any number of signatures allowed; must have 0 at end to stop.
set n to 1
set begin to start
set _end to start - 1 + 4 * (item n of s)
set outputStr to ""
repeat
set a to _end
set b to begin
set c to begin + 1
set d to _end - 1
set halfway to (begin + _end) / 2
repeat while b < halfway
set outputStr to outputStr & a & ","
set outputStr to outputStr & b & ","
set outputStr to outputStr & c & ","
set outputStr to outputStr & d & ","
set a to a - 2
set b to b + 2
set c to c + 2
set d to d - 2
end repeat
set n to n + 1
if item n of s = 0 then exit repeat
set begin to _end + 1
set _end to _end + 4 * (item n of s)
end repeat
set the clipboard to outputStr
return outputStr
Copy link to clipboard
Copied
I forgot to mention: there is one very slight flaw in the script -- it generates an unnecessary comma at the end which I don't know how to get rid of via the script. I will just delete the comma manually -- or maybe the Page Range dialog box will ignore a final comma, so it won't be a problem.
Copy link to clipboard
Copied
Quoting Guy Burns <forums@adobe.com>:
I forgot to mention: there is one very slight flaw in the script --
it generates an unnecessary comma at the end which I don't know how
to get rid of via the script. I will just delete the comma manually
-- or maybe the Page Range dialog box will ignore a final comma,
so it won't be a problem.
>
Copy link to clipboard
Copied
Thought I would see how well my version of the PlaceMultipagePDF script would work for the imposition scenario.
I had to make some changes for this to work, but essentially the user needs to supply a string of numbers in a dialog to represent how the pages will be imposed (the numbers are separated with a comma). This looks as if it would work well.
The script assumes that the numbers supplied by the user match up with consecutive numbering for the pages in the document (beginning with page item 0). It would not take much to add an offset value to indicate the document offset for the first page to which the PDFs will be placed.
If you are interested, I will attach the script to a subsequent message as soon as it has been tested adequately.
Shirley Hopkins
Copy link to clipboard
Copied
Guy,
Want to help you out here. What is your press sheet size?
Rick
Copy link to clipboard
Copied
Whoa.. whoa.. let's back track so that I can confirm a few things.
1. I am doing the binding myself, so I use variable length signatures for two reasons. Plus there is a third reason due to a flaw in InDesign.
(a) So that images that spread across the centre line are printed on one sheet (where possible);
(b) so that there are a minimum number of blank pages at the end of the book; and
(c) to overcome the "text on a path problem". You cannot export "text on a path" on pages greater than ~70. A large InDesign file has to be broken up (see http://forums.adobe.com/thread/482470?tstart=0).
2. The example of 24, 28, 24 is actually taken from a book of mine that is right in front of me, and which I am reprinting. Each of these signatures has a large image that spreads over both pages of the central sheet, so the image is "whole". It's just the way I wanted to do it; and in fact, to some extent the book itself was designed around being able to print "unbroken" large images.
3. Another example from my books is: 32, 28, 28, 32; and yet another: (25 x 32) + 16.
4. I made a mistake in the description: the imposition is actually a series of 2-Up Saddle Stitched signatures, not Perfect Bound (which for 2-Up is simply a series of same-size saddle-stitched signatures anyway).
5. Thinking about it, I'm pretty sure all I need is a number generator that dumps numbers separated by commas into a place where I can access them -- Text Edit, InDesign, or the clipboard.
IMPOSING
I envisage these are the steps when I am ready to impose (nothing fancy, only 2-Up saddle stitch):
1. Work out the imposition layout. This must be completely flexible for my needs. The only limitation is that imposed by physics itself and the format of books: 2-sided paper, folded in half has four sides. So the signature-length must be divisible by four. Within that limitation, any possible combination is allowed. I may want a book like this: 4, 36, 24, 12, 32, 8, 4, 4,16, 28.
2. I open up the InDesign document ready to impose.
3. I open up the number generator script so that I can edit it. No interface is required -- signature lengths are overwritten in the script itself.
The script will appear as (my entries overwriting the "0"s are in brackets):
START = 0 [7]
SIG(1) = 0 [12]
SIG(2) = 0 [24]
.
.
SIG(30) = 0
Page number error routine.
Number generator routine.
Output routine, inserting commas between numbers. Stops when a signature length of zero is encountered. Sent to either clipboard, Text Edit or InDesign.
4. I then paste the number sequence into the Page Range field, and also paste them into an unused page in the book, so that I can use them in future without recourse to the script. For an 8-page booklet (2-Up saddle-stitch), the numbers would be: 8,1,2,7,6,3,4,5.
5. When I press Export, a single-page PDF is created with the pages in 2-Up saddle-stitch order. But this PDF is not yet ready for printing.
6. The final step is to import the PDF (already in imposed sequence) into InDesign using the PlaceMultipagePDF script. When facing pages is turned on, I have a 2-Up, imposed book with variable length signatures, ready to print.