cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Member
New Member

Fusion of pages

Hi everybody,

I have a colour PDF file in which I want to convert some pages in black and white. I tried splitting in two parts (one way colour to keep, the other way colour to convert) and after I tried to gather by "fusion" but the order of pages is not kept. Is there anyway to manage that ?

Thanks

0 Kudos
8 Replies
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Fusion of pages

What are the settings that you are using for the Split node? This may be of some assistance: https://forum.support.xerox.com/t5/FreeFlow-Core/Low-Res-proof-Pages-1-2-in-colour-rest-in-black-and...

 

0 Kudos
Highlighted
New Member
New Member

Re: Fusion of pages

I split with by page series. In one way the pages I want to keep in colour (i.e. 1;2-4;3;6;7-12) and in a second way all other pages I want to convert. It works good. But at the end , I want to get my whole pdf file back in the same order I had it in the begining. Hope I'm clear. When I use the "Fusion" tool, I find my converted pages after all the colour pages... 

0 Kudos
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Fusion of pages

I have a solution -- not the most eligant. Workflow setup is to use starts with a Split node. The top Split path contains the entire document.

The lower split paths contain single pages (won't work for a range) designated by a MAX variable. These pages are monochromatized and then saved. One needs to build the number of lower split paths to equal the maximum pages that will ever need to be monochromatized.

The top split path has a Collect node which waits for a minute to allow the lower split paths to complete. Then a series of insert and delete nodes are used. The insert node takes a saved monochromatized page/job and inserts it into the job file after the page number designated by the MAX variable. The delete node then eliminates the extra page (in color) designated by the MAX variable. The number of insert/delete node pairs needs to match the maximum number of pages that will ever be monochromatized.

If the number of pages that need to be monochromatized is less than the maximum number, just repeat the last page number in the csv for remaining entries. The outcome is the last monochromatized page will be inserted multiple times but only appear once in the resultant pdf. See csv example below where page 2 will be processed twice. 

cs.pngcs1.pngcs2.pngcs3.pngcs4.pngcs5.pngcs6.pngcs7.png

Highlighted
New Member
New Member

Re: Fusion of pages

Hi DavidU54339-XRX,

thank you for your post. Indeed, it's a solution. But I have many documents to proceed with (about 20), and the quantity of pages to convert can be from 2 to 60, and they are nnot necessarily at the same place. So, I'll have to change the flow with each document and it would take too many time creating a new flow for each. By the way, I managed converting colour directly in Adobe, select pages or range of pages. But it would be so nice to have  WF solving my problem.

In any case, thank you very much taking time to propose this solution.

 

0 Kudos
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Fusion of pages

I don't know what would be your preferable way of telling the system what pages should be color or grayscale, but here is an idea.

Assume you have a manifest like this:

file;colorpages
C:/files/doc1.pdf;[0,2,4]
C:/files/doc2.pdf;[1,4,5,7]

where the first column is the pdf to use and the second one what pages should be color.

When you map this on the hot folder for a workflow, in the MAX Setup use the pdf as column A and map column B as a custom field. Here I called it pagerange. This will give you the variable $FFpagerange$ that will be used later.

colormerge5.PNG

A workflow like this:

colormerge1.PNG

First Save component saves the job to C:\Out\ with the job name.

colormerge2.PNG

Then a Manage Color component that converts to grayscale. Could be done with a Preflight also.

Then a second Save component to C:\Out\ with the job name but with the addition _gray.

colormerge3.PNG

Now you have both the original pdf and the grayscale version of it in C:\Out\. Now a new pdf will be created that uses both those files and the variable $FFpagerange$ to determine if a color page or a grayscale page should be added to the new pdf. This will be taken care of by the last component which is an External Process that uses a batch file with the parameters:

 "$FFin$" "$FFout$" "$FFwfJob.jobName$" "$FFpagerange$"

colormerge4.PNG

The batch file looks like this:

"C:\Program Files\Python38\python.exe" "C:\Xerox\FreeFlow\Core\00000000-0000-0000-0000-000000000000\Data\Scripts\mergecolorandgray.py" %1 %2 %3 %4

The batch file calls a Python script that looks like this:

import sys
import os
import ast
from PyPDF2 import PdfFileWriter, PdfFileReader
colorpages = ast.literal_eval(sys.argv[4])
infile_color = PdfFileReader('C:/Out/' + sys.argv[3] + '.pdf', 'rb')
infile_gray = PdfFileReader('C:/Out/' + sys.argv[3] + '_gray.pdf', 'rb')
output = PdfFileWriter()

for i in range(infile_color.getNumPages()):
if i in colorpages:
p = infile_color.getPage(i)
output.addPage(p)
else:
p = infile_gray.getPage(i)
output.addPage(p)

with open(sys.argv[2] + '\\' + os.path.basename(sys.argv[1]), 'wb') as f:
output.write(f)

os.remove('C:/Out/' + sys.argv[3] + '.pdf')
os.remove('C:/Out/' + sys.argv[3] + '_gray.pdf')

What happens is that the Python script reads both saved pdf files. It then checks if the page is in $FFpagerange$. If it is, then a page from the original pdf is added and if not then a grayscale page is added. (Page counting starts with 0. If you would like to input page numbers that you are used to then the script has to modified.)

Both scripts have to be placed in the FreeFlow Core scripts folder. I have my scripts folder on C:\. If you have your scripts folder somewhere else then you need to change the drive letter/path in the batch file.

Also, this requires Python https://www.python.org/downloads/ to be installed on your FreeFlow Core server. After Python is installed you need to install PyPDF2. From command line as admin run:

pip install PyPDF2

Depending on where Python is installed you might need to change the path to python.exe in the batch file.

All done.

I have also attached both scripts.

If you dont' want to use a manifest for this, then you could for instance use a pdf keyword (or some other variable that could be included in the pdf itself) with the information of what pages should be in color.

colormerge6.PNG

You then need to replace "$FFpagerange$" with the variable "$FFwfdoc.Keywords$" in the External Process component.

/Stefan

 

 

 

0 Kudos
Highlighted
New Member
New Member

Re: Fusion of pages

Hi Stefan,

many thanks for your answer. I'll leave for few weeks next days, so I'll test your solution when I'll be back.

Thank you for your time.

 

0 Kudos
Highlighted
New Member
New Member

Re: Fusion of pages


Hi Stefan,

I worked on your solution. I have installed python, PyPDF2 (hope I did it good).  And nothing worked so I have some questions ( you must have to know that I'm really not a WF expert!!!):

1 - How can I know if python and PyPDF2 are working good ?

2 - Just to be sure : the "mergecolorandgray.py.bat" is the batch you called "the batch file looks like this" ?

3 - I have a misunderstanding with the manifest. What it a manifest : a txt file ? an excel file ? or what else ?

4 - How this manifest is created ? Do I have to create a special file ? If yes, where do I have to put it ?

After that, what is the procedure ? What file do we have to put in the flow ? And after proceeding, where can I find the final file ?

Thanks for your support.

Jerome 

0 Kudos
Highlighted
FreeFlow Production Workflow Moderator
FreeFlow Production Workflow Moderator

Re: Fusion of pages

You need to make sure the contents of the scripts I sent points to the correct locations. Find the latest 64-bit Windows installer for Python and when it is run select Customize installation. Then check the Add Python 3.x to PATH setting. In the Customize Installation location type C:\Program Files\Python38. This will install Python where the batch file points to python38.exe. Then from a command prompt as admin run:

pip install PyPDF2

Batch file mergecolorandgray.py.bat contains this:

"C:\Program Files\Python38\python.exe" "C:\Xerox\FreeFlow\Core\00000000-0000-0000-0000-000000000000\Data\Scripts\mergecolorandgray.py" %1 %2 %3 %4

and this is the script that runs in the External Process.

The batch file then calls the python script mergecolorandgray.py which assumes there is a folder C:\Out for temporary files. You could change it to C:\Temp if you like in the python script.

The manifest is a csv file that you need to create somehow. You submit the manifest to a hot folder but you need to do the MAX Setup on the hot folder to tell the system what each column in the manifest represents.

As an alternative to a manifest you could add a keyword to a pdf ([2,5,8] etc to tell the system what pages should not be grayscale) and then submit the pdf to a hotfolder or by any other supported method.

In the example I sent, the last stage is the External Process. After this stage you can add whatever component you need to get the file where you want - Print, Save etc.

I have attached a slightly modified script so that the pages can be entered in a way that makes sense (In the first one I sent page 1 is represented by 0, page 2 is represented by 1 and so on).

If you encounter any issues then please check the stderr.log and stdout.log files in the External Process Status folder in the FreeFlow Core Scripts folder.

Stefan

 

 

0 Kudos