Document Generator
Architecturally REST API mostly corresponds to the module PHP API. The set of REST methods covers all module functionality.
Presently there are two scopes to handle document generator:
- Methods crm.documentgenerator.*. Results for these two methods are displayed in CRM interface;
- Methods documentgenerator.*. Result for these methods is available only at the REST level.
Data from one scope cannot be accessed from another:
- CRM document cannot be created with REST template;
- CRM data cannot be used when handling methods documentgenerator.*.
- IMAGE - images
- STAMP - stamps and signatures
- DATE - dates
- NAME - names
Money and Address field types are implemented inside the CRM module. That is why they cannot be used in the REST of this module. If the required data is still must be printed - it must be passed as already generated.
The option to use arrays to be inserted into table and recurrent blocks is available.
Scope methods parameter differences
Methods are identical from the "inside". In actuality, after the crm.documentgenerator.* methods' parameters are preprocessed, such methods are calling the documentgenerator.* methods. There are some differences, however:
- Instead of provider names, CRM entity type ID (parameter
entityTypeId
) must be passed on input of the crm.documentgenerator.* methods; - Instead of value parameter, CRM entity ID (parameter
entityId
) must be passed on input of crm.documentgenerator.* methods
Templates
All templates and documents, created via this API are associated to the REST module. The scope documentgenerator
cannot be used to request templates and documents of other modules. That is why, moduleId
rest
will always be available in template data. Even if another module is indicated in add
or update
, it will not be modified.
Only two providers are available for REST:
Bitrix\DocumentGenerator\DataProvider\Rest
- must be always be specified as the provider for templateBitrix\DocumentGenerator\DataProvider\HashDataProvider
- used for data transfer to tables / recurrent blocks
Binding templates to user by the REST methods themselves is not considered. But it can be used on the side of the app.
Numerators
For numerators to operate, the documentgenerator.numerator.* methods are available, described here. Access to all numerators for documents can be gained via this scope. Numerators, working in CRM can be accessed as well. However, there is no option to delete or update the numerator via REST.
List of regions
Each template is associated with a specific country. List of countries is available and presently consists of the following countries:
ru - Russia
by - Belarus
kz - Kazakhstan
ua - Ukraine
br - Brazil
mx - Mexico
de - Germany
uk - United Kingdom
pl - Poland
User-defined regions can be added starting from documentgenerator version 18.6.1. See a separate section for details.
Resume
What features can be used?
- Create documents based on templates in the .docx file format;
- Lists with arbitrary number of elements can be inserted into a template via tables or repeated blocks;
- Images, including from blocks can be inserted into a template;
- Insert fields as html with partially saved formatting;
- Create documents, send them and track views without user participation (via automation rules).
What cannot be done?
- Inserting multiple value of "file" field type;
- Inserting tables and images from html;
- Inserting vector images;
- Formatting is not fully saved when passing.