ONYX - 9.0 - Utilisation

Other processes

De MappingDoc
Révision datée du 3 janvier 2025 à 10:17 par Jdieu (discussion | contributions) (Page créée avec « Example : map_xps -infile:/tmp/invoice.xps -outfile:/tmp/invoice_90.xps -rotation:90 »)
Autres langues :
English • ‎français

Log management

The -logfile:XXX switch allows you to redirect all messages from a map_xps command into a text file:

map_xps -infile:/tmp/invoice.xps -toPDF -outfile:/tmp/invoice_[[InvoiceID]].pdf -logfile:/var/logs/mylog.log


List of resources

The -listResource switch allows you to display on the screen (standard output) the resources (fonts and images) embedded in an XPS document:

map_xps -infile:/tmp/invoice.xps -listResource


Data extraction in XML

The principle is to create an M-Designer compatible XML file into which all the text data of the XPS document is exported. Each text box in the XPS file becomes an XML field uniquely named by its X and Y positions expressed in points for a resolution of 72 dpi.


Very little used as such, this XML output will find its interest in the additional calculations carried out for the addition of OMR codes.

Example:

map_xps -infile:/tmp/invoice.xps -toXMLDRAW -outfile:/tmp/result/invoice_data.xml


XML data extract:

<?xml version="1.0encoding="UTF-16standalone="yes?>
<doc>
<page name="NORMAL">
<field name="x289y112">Customer number: 10638</field>
<field name="x289y87">Invoice No. 10000 of 11/22/2008</field>
…
</page>
</doc>


Dynamic field replacement

The principle is to use dynamic replacement fields depending on the execution context in an XPS document. To do this, it is possible to define fields awaiting assignment in an XPS file. These fields will then be replaced with a value at run time.

For example, one use may be to print the edition date on a document but this date does not correspond to the exact moment of composition of the document but rather to that of sending the document to the destination printer. At the time of composition, in the M-Designer document model, you must then create a field awaiting replacement in the form [[MY_DATE]] (text box). Once the XPS document is composed, the value of this MA_DATE field will be dynamically replaced by the command line switch -replaceEnv. The replacement value will be found in the system environment. The whole challenge therefore consists of registering a MA_DATE variable in the environment and giving it a value.


Several ways to do this:


- Before composition, it is passed as a parameter by the application sending the data file to be composed in ONYX Server and will therefore be automatically managed in the engine as an environment variable attached to the processing.

Example : argument-o:MA_DATE=20150219 de la commande map_lpr


- During composition processing, it is defined in the execution workflow as a parameter and thus automatically managed in the engine as an environment variable attached to the processing:


OX S Dyn Champ.png


- After composition, it can take the value of an index positioned in the XPS document previously exported into the environment by the -environment argument.

Example: at the end of the composition, an invoice.xps document is obtained containing the index MA_DATE. The following command exports the index values ​​into the environment and then uses the environment to dynamically replace the [[MY_DATE]] field:

map_xps -infile:/tmp/invoice.xps -toPDF -outfile:/tmp/invoice.pdf -environment:MY_DATE -replaceEnv


Noticed : All environment variables specific to the Windows or Linux system (DATE, TIME, COMPUTERNAME, etc.) and environment variables specific to ONYX Server (MAP_FILE, MAP_USER, MAP_TITLE, etc.) are natively accessible by this argument -replaceEnv.


Image conversion

When converting XPS documents to image, additional switches may occur for dimensions and color management:


-sizeX:NN: specifies the desired width of the image, in pixels.

-sizeY:NN: specifies the desired height of the image, in pixels.


When only one of these two parameters is entered, the dimensions of the output image are recalculated while maintaining the original proportions. When both parameters are specified then the original proportions are no longer taken into account and the image may possibly be distorted.


-bpp:NN: specifies the number of bits per pixel for color rendering.


Possible values:


1 bpp => two colors (so black and white)


4 bpp => rendered in 16 colors


8 bpp => rendered in 256 colors


16 bpp => rendered in 65,536 colors


32 bpp => rendered in 16.6 million colors


Paper format

Three specific toggles allow you to change the page dimensions of an XPS document:


-paper:XXX : allows you to change the size of the paper (of the page) without affecting the content (be careful of potential data loss).


-scale:NN : allows you to change the size of the content without touching the paper.

-changeformat:XXX : allows you to change the format of the document by modifying the size of the paper and adapting the content while preserving the proportions.

For scaling of page content, the value is expressed as a percentage, from 1 to infinity. As the paper size is not impacted, be careful of potential data loss with values ​​greater than 100. In combination with scaling, the -center switch can be used to center the result in the middle of page.


To modify the size of the pages, with or without adaptation of the content, the values ​​of the -changeformat and -paper switches express a paper format either to the ISO standard or to a custom one.

Possible ISO standard values: A2, A3, A3 Extra, A4, A4 Plus, A4 Extra, A5, A5 Extra, A6, B4, B5, B5 Extra, B6, Envelope #9, Envelope #10 , Envelope #11, Envelope #12, Envelope #14, Envelope B4, Envelope B5, Envelope B6, Envelope C3, Envelope C4, Envelope C5, Envelope C6, Envelope C65, Envelope DL, Envelope Invite, Envelope Monarch, Envelope, Executive, Folio, German Legal Fanfold, German Std Fanfold, Japanese Postcard, Japanese Double Postcard, Ledger, Legal, Legal Extra, Letter , Letter Extra, Letter Plus, Letter Small, Note,PRC 16K, PRC 32K, PRC 32K(Big), PRC Envelope #1, PRC Envelope #2, PRC Envelope #3, PRC Envelope #4, PRC Envelope #5, PRC Envelope #6, PRC Envelope #7, PRC Envelope #8, PRC Envelope #9, PRC Envelope #10, Quarto, Statement, SuperA, SuperB, Tabloid, Tabloid Extra, US Std Fanfold.


Syntax for custom size : -changeformat:xx.xx,xx.xx[,cm|in|mm]


⇒ two decimal values ​​corresponding respectively to width and height


⇒ the decimal separator is ‘.’


⇒ the value separator is ‘,’ or ‘;’


⇒ the unit is optional: cm (default), mm or in (for inch)

Examples :

map_xps -infile:/tmp/invoice.xps -scale:50 [-center] -outfile:/tmp/invoice_out.xps
map_xps -infile:/tmp/invoice.xps -changeformat:A4 -outfile:/tmp/invoice_out.xps
map_xps -infile:/tmp/invoice.xps -changeformat:21,29.7,cm -outfile: :/tmp/invoice_out.xps

Rotation

To rotate documents, the -rotation:NN switch is used. The angle of rotation is expressed in degrees knowing that the direction of rotation, by default, being the trigonometric direction (= counterclockwise). In principle, all angles are supported but only right angles respect the consistency of the dimensions of the original page which means that the supported values ​​are as follows: -90 (rotation of 90° clockwise), 90 , 180, 270.


Note:


The values ​​-180 and -270 are not supported (blank page output), so 180 and 90 should be used respectively.


Example :

map_xps -infile:/tmp/invoice.xps -outfile:/tmp/invoice_90.xps -rotation:90

Fusion d'un fond de page sur un document existant

Le principe est que, sur un document XPS existant, il est possible de rajouter un autre document en tant que fond de page ou calque (exemple : ajouter un logo sur une facture existante n’en comportant pas). Le commutateur utilisé est -merge:XXX dont la valeur est le nom complet du fichier XPS externe à ajouter comme calque. L’argument optionnel -mergemode:XXX permet de piloter la manière dont est rajouté ce calque :

- REPEATALL : toutes les pages sont fusionnées en répétant le calque jusqu’à la fin du fichier d’entrée. C’est le fonctionnement 
par défaut.

Exemple :

  • En entrée => fichier de cinq pages (identifiées par 1, 2, 3, 4, 5) et un calque de deux pages (identifiées par a, b)
  • En sortie => un fichier de cinq pages identifiées 1a, 2b, 3a, 4b, 5a
- REPEATFULL : toutes les pages sont fusionnées en répétant le calque tant qu’il peut être inséré entièrement.

Exemple : avec les mêmes entrées que précédemment, le fichier en sortie compte cinq pages identifiées 1a, 2b, 3a, 4b, 5 (la dernière page n’étant donc pas modifiée).

-ONCE : le calque n’est inséré qu’une seule fois sur la ou les premières pages du fichier d’entrée.

Exemple : avec les mêmes entrées que précédemment, le fichier en sortie compte cinq pages identifiées 1a, 2b, 3, 4, 5.

Exemple :map_xps -infile:/tmp/invoice.xps -merge:/tmp/logo.xps -mergemode:REPEATALL -outfile:/tmp/invoice_final.xps