Page 1 of 2 1 2 >
Topic Options
#50466 - 12/22/14 12:34 PM Inserting PDF Page Range
ontheroaderic Offline
OL Newbie

Registered: 03/04/10
Posts: 13
Loc: Lafayette, CO USA
Working on a large number of product tags and I want to break the document into manage chunks for the cutter. I have a PDF with 2340 pages. I want to structure my PSM doc as follows:
Layout 1 - Divider
Layout 2 - Pages 1-300 of PDF
Layout 3 - Divider
Layout 4 - Divider
Layout 5 - Pages 301-600 of PDF

Is there a way to do this? Seems like I could add an expression to the PAGE NUMBER property of that object, but I haven't figured out what. I could also divide the PDF into 300 page chunks, but I'd still have the same issue of wanting PSM to print all 300 pages of the PDF and then the next layout. I could probably accomplish by making a PSM document with a layout for every page in the PDF but that's no fun.

Top
#50473 - 12/23/14 10:10 AM Re: Inserting PDF Page Range [Re: ontheroaderic]
JFLAIR
Unregistered


ontheroaderic,

I'm not sure I understand exactly what you want to achieve.

Could you please detail more? You mentioned that your PDF has 2340 pages, yet in your layouts you stop at page no 600.

Do you need all 600 or 2340 pages per record?

Regards,

Top
#50474 - 12/23/14 10:13 AM Re: Inserting PDF Page Range [Re: ontheroaderic]
ontheroaderic Offline
OL Newbie

Registered: 03/04/10
Posts: 13
Loc: Lafayette, CO USA
Sorry, should have added "and so on" there at the end . . . I want the pattern to repeat until all 2340 pages have been printed and have divider sheets every 300 pages.


Edited by ontheroaderic (12/23/14 10:13 AM)

Top
#50477 - 12/23/14 12:12 PM Re: Inserting PDF Page Range [Re: ontheroaderic]
JFLAIR
Unregistered


ontheroaderic,

Since it seems you are not running any data file with it, then I would suggest this:

  • In Preferences, under Program, set the Items without database with the number of pages your PDF contains(2340).

  • Set the first layout to be your PDF.

  • Edit Expression Page Number. Use this number function:
    Code:
    RECORD_NR()


  • Set your second layout as a blank page or with a text object. This will be your divider, unless you have a specific page you want to display.

  • In the second layout's properties, set the action expression like this:
    Code:
    IF(MOD(RECORD_NR(),300)=0,Print,Skip)


By doing so, it will print your first 300 then a blank page, then another 300 followed by another blank page.

Hope this helps.
Regards,
JF

Top
#57997 - 05/16/21 08:04 AM Re: Inserting PDF Page Range [Re: Anonymous]
Shift Offline
OL Newbie

Registered: 03/27/18
Posts: 5
Is it possible to do this while linked to a database?

I have a folder full of PDF's that can be between 1 to 250 pages.

I have to add certain fields onto page 1, but pages 2 onward are always static.

My data includes the fields I need to add, plus the file name and total page count.

Or would the only way of doing this be to create 250 sperate print/skip layouts?


Edited by Shift (05/16/21 08:07 AM)
Edit Reason: spelling

Top
#58036 - 06/10/21 12:09 PM Re: Inserting PDF Page Range [Re: Shift]
sellis Offline
OL Newbie

Registered: 07/11/07
Posts: 20
Set the items without database to 2340 as per PDF page count. this can be fount in the menu Edit -> Preferences, Program settings.

create All layers and from the Layout/Edit condition Menu...

Layer 1 - Divider - expression = IF(RECORD_NR() =1,Print,Skip)
Layer 2 - Pages 0001 - 0300 - expression = IF(RECORD_NR() >= 1 AND RECORD_NR()<= 300, Print,Skip)
Layer 3 - Divider - expression = IF(RECORD_NR() =300,Print,Skip)
Layer 4 - Divider - expression = IF(RECORD_NR() =300,Print,Skip)
Layer 5 - Pages 0301 - 0600 - expression = IF(RECORD_NR() >= 301 AND RECORD_NR()<= 600, Print,Skip)
Layer 6 - Divider - expression = IF(RECORD_NR() =600,Print,Skip)
Layer 7 - Divider - expression = IF(RECORD_NR() =600,Print,Skip)
Layer 8 - Pages 0601 - 0900 - expression = IF(RECORD_NR() >= 601 AND RECORD_NR()<= 900, Print,Skip)
... Continue until all pages accounted for.

On all the Layout's with 'pages xxxx-xxxx', you'll need to edit the page number expression, by right clicking on PDF in main view, selecting Edit Expression -> property 'Page Number' and setting the page number to RECORD_NR().

Once this has been setup, you can utilise over and over again just replacing each layout with the new PDF and altering the items without database to the final page quantity.

hope that helps.

Cheers

Top
#58059 - 06/16/21 06:25 AM Re: Inserting PDF Page Range [Re: sellis]
Shift Offline
OL Newbie

Registered: 03/27/18
Posts: 5
This works when the job is not linked to any data, is it possible to do this when linked to a database?

I have a job that has multiple PDF's of varying pages, but I only need to place personalisation on page 1.

Data example:

Filename Pages Title Surname
Doc1.pdf 200 Mr Sample
Doc2.pdf 121 Mr Sample2
Doc3.pdf 235 Mr Sample3
Doc4.pdf 86 Mr Sample4
Doc5.pdf 111 Mr Sample5

I have the filename and page count (as well as the fields I need for personalisation).

At the moment I have a document with over 300 layouts to achieve this.

If it is possible to do this with 2 layouts while linked to data (Layout 1 have the personalisation and layout 2 printing the rest of the pages, then moving onto the next record and doing the same) it would be a much simpler and safer solution to what I currently have.

Top
#58066 - 06/19/21 08:49 AM Re: Inserting PDF Page Range [Re: ontheroaderic]
Sander vd Berg Offline
OL Expert

Registered: 06/10/08
Posts: 207
Loc: Objectif Lune NL
With two layouts:

I assume the second layout has an image with the Page Number expression set to "PAGE_NR() - 1". Select that layout and set the Number of Copies expression to "VAL([Pages])".

That should be all you need to do. The "PAGE_NR() - 1" expression is reevaluated for each layout copy.

Top
#58069 - 06/22/21 11:58 AM Re: Inserting PDF Page Range [Re: ontheroaderic]
Sander vd Berg Offline
OL Expert

Registered: 06/10/08
Posts: 207
Loc: Objectif Lune NL
Sorry for replying to my own post. I received an email for a reply but the thread still hasn't been updated.

Thanks for pointing out what the issue is, I understand now. The expression for the image is actually the tricky part, the expression I gave only works for the first record. What you need is a running total that you can subtract from "PAGE_NR() - 1".

There are two solutions that come to mind (without altering the data):

1. Use a custom SQL query

This only works if your data has an order column. If it has an ID field that starts at 1 and increments every record you can do:

Database > Select Table > Custom (double-click)
Code:
SELECT (SELECT SUM(Pages) FROM [Test.csv] as A WHERE A.ID < B.ID) AS RunningTotal, * FROM [Test.csv] AS B


Note that the filename of the data file needs to be hardcoded (without a path). The query above assumes the filename is Test.csv.

2. Create a custom macro

Create a folder called "Macro" in the PSM installation folder (this requires admin rights) with a file (any name) with extension ".js" and the following content:

Code:
function psmGetFunctionDescriptor(index) {
    return index == 0 ? "NUMBER NUMBER RUNNING_TOTAL(NUMBER{Record},NUMBER{Pages})" : "";
}

var total = 0;

function psmRUNNING_TOTAL(record, pages) {
	if (record == 1) total = 0;
	var previous = total;
	total += pages;
	return previous;
}


You should then have access to a RUNNING_TOTAL function that you can call passing RECORD_NR() and VAL([Pages]). This only works if you are creating output starting with record 1, since that is the "reset" trigger of the running total.

Top
#58070 - 06/22/21 12:41 PM Re: Inserting PDF Page Range [Re: ontheroaderic]
Sander vd Berg Offline
OL Expert

Registered: 06/10/08
Posts: 207
Loc: Objectif Lune NL
Ugh.. I'm really overthinking this.

PAGE_NR has an optional boolean argument that determines if it should reset after each record. So just forget my previous comment and instead of "PAGE_NR() - 1" do "PAGE_NR(True) - 1".

Top
Page 1 of 2 1 2 >