Print formats can be generated by using eDapters and eWorksheets.
Print formats are used to generate documents dynamically based on statutory templates(RTF files) according to an organization's needs. For instance: Generating Invoices, Sales Orders.. etc.
Print formats are generated as RTF files with dynamic values and then it will be converted to PDF though Triniti's Word/HTML/TEXT to PDF conversion service.
In order to create Print formats, below are the things needed.
Create an eWorksheet which is presented to the users where they can select the required records(Ex: Invoices) for which they want to generate print formats. This eWorksheet contains high-level information required to generate the Print Format. This worksheet must contain below statutory columns.
AD_CLIENT_ID - This column contains the AD_CLIENT_ID value form the base table
AD_ORG_ID - This column contains the AD_ORG_ID value form the base table
RECORD_ID - This is the column that contains a unique column id value. This value will be passed as the where condition value to the eDapter mentioned in #2. Ex: For C_INVOICE table C_INVOICE_ID is the unique value
PRINT_FORMAT_NAME - This is a Unique Print format value that would be different for each different Print Format. Based on this value, the configuration will be fetched from Registry.
AD_TABLE_ID - This should contain the value of AD_TABLE.AD_TABLE_ID where the AD_TABLE.NAME is matching with Transaction table. Ex: C_Invoice is the table name available in AD_TABLE for Invoices
RTF_SOURCE_LOCATION - This should contain the RTF Template file Path(This path should be available inside TrinitiApps28/ETK3 folder). Ex: file_store/Inbound/RTF_Templates/Triniti/Payment_Voucher.rtf
RTF_TARGET_LOCATION - This should be the path of the output file(This file will be created inside TrinitiApps28/ETK3 folder). Ex: file_store/Outbound/Output_Reports/Triniti/Payment_Voucher/voucher.rtf(Output file will be converted to .pdf once generated)
DOCUMENT_TYPE - This is useful when there are different print formats available for a single table. It will be stored in triniti_idempiere.AD_ATTACHMENT_DOCUMENTS once print format generated (Ex: C_Invoice table is used for Purchase Invoice and also for Commercial Invoice)
DOCLOCATION - If the print format is already generated for this record, it should be filled with the AD_ATTACHMENT.DOCLOCATION value. If DOCUMENT_TYPE is filled, then it should be filled from triniti_idempiere.AD_ATTACHMENT_DOCUMENTS
AD_ATTACHMENT_ID - If the print format is already generated for this record, it should be filled with the AD_ATTACHMENT.AD_ATTACHMENT_ID value. If DOCUMENT_TYPE is filled, then it should be filled from triniti_idempiere.AD_ATTACHMENT_DOCUMENTS
GENERATE_DOCUMENT - This is a boolean(checkbox). Print Formats will be generated only for the records for which this checkbox is checked.
Configure com.triniti.idempiere.customcontroller.GeneratePrintFormatCustomController as After Custom controller for this eWorksheet .
Create an eDapter which can provide the complete data to generate the Print Format. This supports fetching multiple levels of data(Ex: Invoice data and all its particulars as child records like lines and taxes).
Multiple levels of data can be fetched using the Child Select Groups
If there are any non-string variable with null values exists, Print Format generation will be failed.
So, all the bean variables should be Strings, and make necessary changes for conversions to String in the SQL configuration
If a String value contains a null value, it will be taken care of automatically to reset it to an empty which is not null.
Having non-string variables work fine as long as there are no null values, where the Developer should take care of it.
Setup the Print format configuration.
Go to iDempiere-eWorksheets -> Print Format Setups -> Print Format Details
Input Print format name(Same as PRINT_FORMAT_NAME provided in step #1, eDapter Name, eDapter R2O Class, eDapter Where Condition (These are details related to the eDapter created in step #2 and Save it.
Drill down to Print Format eDapter Classes worksheet and input all the eDapter class names of all levels(Parent and child bean names). Select Is Root checkbox for the Parent class. The Parent/ Root class will be header information and children will be arrays(Ex: Multiple lines in an invoice or Multiple taxes like CGST & SGST)
Configuring RTF template - Below are steps to create the RTF Template
Create XML File
Setup the attached eclipse project in the local Eclipse workbench. This project has only one Java class
Change the printFormatName in the class to the PRINT_FORMAT_NAME given in step #1.
Execute the class, it will create a .fields.xml file in templates/output folder
Create RTF Template
Open RTFTemplate.dot file which is available in the templates/input folder. It will open a new Word Document.
Go to Add-ins -> RTF Template -> Settings. It will open a dialog which asks form the folder path of .fields.xml files.
Browse/ Paste the appropriate path in which the .fields.xml file is available and Save & Close it.
Create the Template(Ex: Invoice Template) and use the Fields for the dynamic values by inserting them using Add-ins -> RTF Templates -> Available Fields -> Choose an appropriate field and Insert Field.
Finally, save this word document as RTF file with the name given as part RTF_SOURCE_LOCATION in the above step.
Upload RTF Template into the RTF_SOURCE_LOCATION in the above step using eDapter ToolKit -> Functions -> Remote Explorer.
Open the eWorksheet created in Step #1 and choose the required record, check them for document generation and submit.
It will create the output RTF from the Input RTF and configured eDapter beans.
Then it will be converted to PDF using Triniti RTF to PDF conversion service, and the pdf file will be linked to eWorksheet record.
Commonly arise issues:
----------------------------------
It shows a print format generated successfully. But not link to view Print format in the eWorksheet
One of the Bean variables could be null with non String data type. Change it to String. Or make sure to have a non-null value.
Though there are no exceptions in the logs, and inserted successfully. AD_ATTACHMENT_ID & DOCLOCATION are not filled properly in the eWorksheet from exact sources.
Regeneration of an existing print format document fails, when AD_ATTACHMENT_ID is not filled properly in the eWorksheet from exact sources.