Reorder pages in a pdf

Post Reply
LasseThid
Advanced member
Posts: 353
Joined: Tue Mar 03, 2015 2:30 pm
Location: Molndal, Sweden

Reorder pages in a pdf

Post by LasseThid »

I'm working on a flow which will output a pdf for a perfect bound brochure via SmartStream.
However, in the incoming pdf file the cover is the first two pages and the last two pages and in order for the imposition to be correct I need to have the pages for the cover as the first four pages in the pdf.
Is there a way of extracting the last page(s) and place it(them) as page 3 (and 4) in the pdf?
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
3f8h.net
Member
Posts: 26
Joined: Tue Mar 13, 2012 4:14 pm

Re: Reorder pages in a pdf

Post by 3f8h.net »

Hello Lasse,

You also can use a "Split PDF" with [Index_], rename the pages you want to reorder and finally "Merge PDF" again.

I´d use callas pdfToolbox for this.
The pdfToolbox is a bit more clever, because it lets you easily strip e.g. the last two page in reverse order.
--
Sebastian Nafroth +++ 3f8h.net / electronic publishing

3f8h.net offers professional services and products for the graphic arts
industry.

contact details: http://www.3f8h.net/kontakt
LasseThid
Advanced member
Posts: 353
Joined: Tue Mar 03, 2015 2:30 pm
Location: Molndal, Sweden

Re: Reorder pages in a pdf

Post by LasseThid »

OK, I have now got the flow working the way I want, but I get an error when the flow completes.

The flow looks like this:

Image

If I drop a 36 page pdf-file and an xml-file into the In folder I will see the resulting file briefly in the Out folder before it's moved to the Problem jobs folder. If I look at the resulting pdf-file located in the Problem jobs folder it contains all 36 pages with the page order I'm looking for, i.e. 1, 2, 35, 36, 3 - 34. Looking at the messages I get the following error:

20/5/2016 20:30:17 Error Assemble job New flow Assemble job 00274 697_Vit_A4L.PDF Dynamic property 'jobIdentifier' has invalid value ''
20/5/2016 20:30:17 Error Assemble job New flow Assemble job 00274 697_Vit_A4L.PDF Job '_00274_697_Vit_A4L.PDF' was moved from folder '/Users/switchdeveloper/Library/Application Support/Enfocus/Switch Server/backing/New flow/automanaged/All Pages Except For Last Page' to the problem jobs folder. Reason: see previous log message(s)

If I Hold the connection between All Pages Except For The Last Page and Assemble job and drop the pdf-file and the xml-file into the In folder and then stop the flow once all 18 fildes are in the All Pages Except For The Last Page folder and then check the properties for Assemble Job - Job Identifier the Sample value shows the correct value. Also the resulting file that is sent to the Problem jobs folder has the correct file name.

Any ideas as to what might cause the file to end up in the Problem jobs folder?

Thanks in advance
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Reorder pages in a pdf

Post by gabrielp »

LasseThid wrote:Dynamic property 'jobIdentifier' has invalid value ''
That's why it's going to problem jobs. Look at the "Job Identifier" value under "Scheme" in the Assemble. Any idea why that is null in this case?
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
LasseThid
Advanced member
Posts: 353
Joined: Tue Mar 03, 2015 2:30 pm
Location: Molndal, Sweden

Re: Reorder pages in a pdf

Post by LasseThid »

Sorry for the sloppy description in the last paragraph. I wrote "the properties for Assemble Job - Job Identifier the Sample value shows the correct value", but the correct phrasing should be "the properties for "Job Identifier" under "Scheme" in Assemble Job the Sample value shows the correct value".

The Job Identifier has the property Single-line text with variables defined and the definition is set to [Metadata: Text: Path="/order/product/filename", Dataset="XML", Model="XML", Before=".pdf"] and the Sample value shows the correct value.
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Reorder pages in a pdf

Post by gabrielp »

You put your hold right before the assemble? Add a problem jobs email and add your 'Metadata: Text: Path="/order/product/filename"' variable to the email so you can confirm the failure doesn't have a null value when it fails out of the Assemble.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
LasseThid
Advanced member
Posts: 353
Joined: Tue Mar 03, 2015 2:30 pm
Location: Molndal, Sweden

Re: Reorder pages in a pdf

Post by LasseThid »

The problem jobs email gives the correct file name. :cry:

I noticed this text in messages:
23/5/2016 15:40:56 Error Assemble job New flow Assemble job 002B5 697_Vit_A4L.PDF Dynamic property 'jobIdentifier' has invalid value ''
23/5/2016 15:40:56 Info Folder New flow Dismantled Job 002B5 697_Vit_A4L.PDF Moved job to folder 'All Pages'
23/5/2016 15:40:56 Info Control New flow Dismantled Job Added unique name prefix, new name is '_002B5_697_Vit_A4L.PDF'
23/5/2016 15:40:43 Info Merge PDF New flow Merge PDF 002AP 697_Vit_A4L Job _002AP_697_Vit_A4L.PDF was placed in folder Out

Could the bold part be a hint?
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Reorder pages in a pdf

Post by gabrielp »

Seems that you could be correct. It appears that job dismantler is creating a new job ticket. That's fine, but it needs to copy over the metadata dataset you've collected. The key is, by the time the job is getting to the Assemble, it has lost the "Metadata: Text" metadata you're looking for. You can confirm this by putting a hold before the assemble and checking for that metadata or by putting the variable in the problem job email and confirming the value you're expecting is null or empty ('').

I haven't tested much with Job dismantler, but perhaps trying with Ungroup job or something else would maintain the metadata.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
LasseThid
Advanced member
Posts: 353
Joined: Tue Mar 03, 2015 2:30 pm
Location: Molndal, Sweden

Re: Reorder pages in a pdf

Post by LasseThid »

If I put a hold in front of the Assemble job and click Assemble job and look at the properties for Scheme - Job Identifier the Sample value it is correct, 697_Vit_A4L in this case, which is what's bugging me to insanity...

Image
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Reorder pages in a pdf

Post by gabrielp »

Strange that the PDF which is failing out does not have a _01, _02, etc... Is it possible that another file is somehow getting there? Like the original perhaps?
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
LasseThid
Advanced member
Posts: 353
Joined: Tue Mar 03, 2015 2:30 pm
Location: Molndal, Sweden

Re: Reorder pages in a pdf

Post by LasseThid »

The original file name is 697_Vit_A4L, this file I split in to two page files and the segments are given the _01, _03, _05 and so on suffix (most likely because each file contains two pages).
The _01 file contains page 1 and 2, the _03 file contains page 3 and 4 and so on.
I then calculate which file contains the last two pages via information found in the xml-file and rename that file to _02.
The Assemble job then creates a folder based on information found in the xml-file and also collects the correct number of files before sending the folder onwards to the Merge PDF to create a single pdf, using the file name found in the xml-file, from all segments using the suffix to put them together in the correct order.

I changed the Job folder name properties and added _temp to the job folder name and I then sent the files to the flow again and this time the pdf was given the name 697_Vit_A4L_temp.pdf, but still the flow crashes with the same error.
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Reorder pages in a pdf

Post by gabrielp »

Could you zip the flow and the file you're trying to split (the PDF) and send to me via a PM?
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
LasseThid
Advanced member
Posts: 353
Joined: Tue Mar 03, 2015 2:30 pm
Location: Molndal, Sweden

Re: Reorder pages in a pdf

Post by LasseThid »

You have a PM... :lol:
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
msierra
Member
Posts: 22
Joined: Thu Nov 27, 2014 1:38 pm

Re: Reorder pages in a pdf

Post by msierra »

We recently built a similar workflow with exception of xml.

Input file is a multi-page pdf containing 5 pages. These 5 pages will replace 5 pages from a static file e.g. from static file pages 5, 101-104 are replaced by the 5 pages from the input file. Pages from the Input file are in expected order.

User drops a file into input. The first element after Input folder is a Rename job which is simply used to set private data key for Remember original name. Files are then routed along different connection lines via specific colorant contained in PDF. For each connecting line we use a Set hierarchy path to add path to a static multi-page PDF file that is related to dropped file. This path is used later in flow to inject static file into flow. Then a folder that is used to set a Job Status. Job Status is used later in flow for other purposes. Dropped file is then used to 1. Inject the static file using the path set earlier and then routes another direction to be split into single page PDF files using _zz[Index]. Added zz as we were running into some odd behavior when renaming.

The dropped file then passes through an Ungroup element, which does not remove any metadata from job ticket. The single files are passed through a Rename element (search and replace) changing the index number from 1-5 to 005, 101-104. Replace is scripted. They are then moved to a folder preceding an Assemble job element.

The dropped file triggers the injection of the static file (using the path from the hierarchy set earlier in flow) into the flow picking up the trigger file name. The static file is then split into single pages and then passes through an Ungroup element. Pages containing 005, 101-104 are then routed to Recycle bin and the remaining files are sent to same folder preceding the Assemble job element as indicated above.

Assemble job scheme is set to Custom. Job identifier is set to the private key value of the incoming job that is set earlier in the flow. Number of files is scripted. Job folder name also uses private key value from job.

When the expected file count is reached for the identified job the files are assembled into job folder and moved on to Merge PDF element. It really works well.

Certain properties are scripted as this flow supports different versions.
Post Reply