Tweak the “ini” file – Advanced transformations

Tweak the “ini” file – Advanced transformations

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 :

SectionExplanationExample
pagesDefine here the pages to which some transformation will be applied1,2 = mytrans1 5 = mytrans2,mytrans3 2:6 =mytrans3 @8 = mytrans1
conditionsPython code which will select some source pagesodd = page_number % 2 == 0 => mytrans2
output_conditionsPython code which will select some output pagesodd = 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

    1. Copy and rename a generated ini file,
    2. Add the desired sections,
    3. Load this file and generate the PDF.
    1. Create a small ini file with only the necessary sections,
    2. Open a PDF file,
    3. open the ini file (with the open project menu),
    4. 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)
  • 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 == 0Selects even pages
page_number % 2 == 1Selects odd pages
page_number % 3 == 0Selects every third page
page_number in (2,7,8,25)Selects pages 2,7,8 and 25
page_number > 10Selects from page 10 and above
page_number % 2 == 0 and page_number > 10 and page_number < 25Selects 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.

dysmas

Comments are closed.