Advanced transformations are possible by directly editing the ini files. To prevent unwanted overwrite it is highly recommended not to use an automatically generated ini file without renaming it. You can use it as a model, but rename it to be sure the program will not overwrite it each time you generate a PDF output, if the option «Save ini files» with PDF is active.
General principle
You can add three special sections :
Section | Explanation | Example |
---|---|---|
pages | Define here the pages to which some transformation will be applied | 1,2 = mytrans1 5 = mytrans2,mytrans3 2:6 =mytrans3 @8 = mytrans1 |
conditions | Python code which will select some source pages | odd = page_number % 2 == 0 => mytrans2 |
output_conditions | Python code which will select some output pages | odd = page_number % 2 == 0 => mytrans2 |
Then you can add other sections with the names you want, and define in them the transformations you want. In our example, you should have the sections mytrans1,mytrans2, mytrans3.
Procedure
Important recommendation: If you start from a generated ini file (
your_file.PDF.ini
), rename it before editing. If you don’t rename it, it will be overwritten each time you generate a new PDF. It should do no harm, but we cannot guarantee that you will never loose your modifications. It is much safer to rename it so that it is saved only when you explicitly asks (by the save project menu).
Several procedures are possible
- Copy and rename a generated ini file,
- Add the desired sections,
- Load this file and generate the PDF.
- Create a small ini file with only the necessary sections,
- Open a PDF file,
- open the ini file (with the open project menu),
- Generate the PDF.
The second procedure is interesting if your transformations must be applied to different files.
Modifying: Tweaking the transformations takes time. When you edit the ini file, you don’t need to close the program. Just reload the ini file and generate your PDF.
[pages]
- Multiple transformations separated by a comma are allowed.
- Source pages may be referenced:
- by their position on the sheet (row, column), example:
1,2
- or by the page number, example:
10
- if there are several source files, precise the file first:
2:10
(means page 10 of the second file)
- by their position on the sheet (row, column), example:
- Output pages are referenced by a
@
followed (without space) by the output page number. Example@ 8
[conditions]
This sections is more technical. The pages are chosen by a python code. Presently the only usable variable is page_number
.
Examples:
page_number % 2 == 0 | Selects even pages |
page_number % 2 == 1 | Selects odd pages |
page_number % 3 == 0 | Selects every third page |
page_number in (2,7,8,25) | Selects pages 2,7,8 and 25 |
page_number > 10 | Selects from page 10 and above |
page_number % 2 == 0 and page_number > 10 and page_number < 25 | Selects event pages between 11 and 24 |
Note on Python syntax:
- The code will be the clause of an if statement. It must return True for the pages you want. The full resulting code for the first example is:
if (page_number % 2 == 0):
…
The double=
is necessary, it is not an operator but a comparator. A single=
will raise an error, it is invalid inside an if statement. %
is the Python operator for modulo- For sophisticated formulas, parenthesis are recommended.
Syntax of the line
The syntax is a bit complicated, sorry.
- First part: a name which is just informational and not used by the program, followed by
=
- Second part: The python formula, followed by
=>
- Third part: the transformation(s).
Multiple transformations separated by a comma are allowed.
Example:
even = output_page_number % 2 == 0 => rotate180
Transformations:
Transformations are defined in sections which you create, giving them the name you want. The sections can contain the following lines:
htranslate | <value> (in mm) | a positive number shifts to the right, a negative number shifts to the left |
vtranslate | <value> (in mm) | a positive number shifts up, a negative numbre shifts down |
rotate | <value> (in degrees) | handles this problem: the program calculates the proper Htranslate and Vtranslate to insure a rotation centered on the center of the page. |
pdfrotate | <value> (in degrees) | original PDF rotation: the center is the lower left corner. This is tricky: if you rotate 90° or 180° or -90°, your page may no longer be visible ! You have to use Vtranslate and Hrotate to position it correctly. |
scale | <value> (in %) | |
matrix | <value> | This highly technical option allows you to enter here a transformation matrix. Use it only if you know what is a transformation matrix in PDF!! See the section on transformation matrices in the Adobe PDF reference guide. |
globalrotation | <value> (90, 180 or 270) | handles also the problem. Only three values are valid: 90, 180 and 270. |
Warning: “
Globalrotation
” parameter is incompatible with all others because it uses a totally different process. Hence it must be alone in its section. If there are other parameters in the section, they will be ignored.
Warning: “
Matrix
” this parameter is incompatible with all others because it will overwrite all other transformation. Hence it must be alone in its section. If there are other parameters in the section, they will be ignored.
Example 1
[pages]
1,1 = 125%, test1
[test1]
Htranslate=140
Vtranslate=45
Rotate=10
[125%]
Scale = 125
This example will apply the transformations defined in test1 and 125% to all pages situated in the first column of the first row.
Example 2
[pages]
3 = 90
5 = 180
[90]
Rotate = 90
[180]
Rotate = 180
This example will rotate the page 3 of 90° and the page 5 of 180°
Although it is valid to mix the two modes for page selection, you must be aware that they may be applied to the same page which may end in undesired result. Example:
[pages]
1,1 = 180
1 = 180
[180]
cRotate = 180
This will result in all left pages but the first one to be rotated 180°. The first one will be rotated twice (180 + 180).
Transformations defined by row, column are applied first, transformations defined for the page number are applied after.
Warning: The order of transformations may be significant. Try and see. There is some information on this last point in the Adobe PDF reference guide (see the section on transformation matrices). But note that if you want to control the order of transformations, you must use different sections because in a section, transformations are always treated in this order, despite the order of the lines: Rotate, Scale, Translate. Note also that you cannot use the same transformation twice in a section.