Print

MergeFilesToPDF

This function merges files from given fields to one pdf file and put it in given field with given name. Source files can be PDF files or Office files that can be converted to PDF (Word, Excel).

Syntax

MergeFilesToPDF(destinationField, destinationFileName, sourceField1, sourceField2,... );
MergeFilesToPDF(destinationField, destinationFileName, "all_attachments");
MergeFilesToPDF(destinationField, destinationFileName, fileList);

Function arguments

  • destinationField – (String) Name of the field in which merged document will be placed, field have to be of Document type;
  • destinationFileName – (String) Name of the merged file;
  • sourceField1 – (String) Name or value of the document field with first file to be merged. To merge files from table name have to be pass in tableName>fieldName format. If this parameter is set to „all_attachments” then following parameters are ignored;
  • sourceField2, sourceField3… – (String) [Optional] Name or value of the document fields with second and further files to be merged;
  • filesList – (FileList) [Optional] Variable of type FileList.

Return value

This function returns Decimal.
Returns true if merge was succesfull, otherwise returns false.

Examples

Example 1

This will merge files from Aggrement_draft and Aggrement_appendix fields to one pdf attachment and put it into Aggrement field with name Aggrement_final.pdf.

if (MergeFilesToPDF("Aggrement","Aggrement_final.pdf",[Aggrement_draft], [Aggrement_appendix])) { }

Example 2

This will merge files from Document field in Files table to one pdf attachment and put it into Aggrement field with name Aggrement_final.pdf.

if (ConvertFileToPDF("Aggrement","Aggrement_final.pdf","Files>Document")) { }

Example 3

This will merge all files from attachments located in right panel and put it into Agreement field with name Agreement_final.pdf. In this case order of documents is based on order set in right panel.

if (MergeFilesToPDF("Agreement","Agreement_final.pdf","all_attachments")) { }

Example 4

This will add files from File field in table Table to FileList variable and merge them into single file named merged.pdf and saved in the „Merged file” field.

files=CreateObject("FileList");
foreachrow("Table")
{
  AddFileToList(files, [File])
}
MergeFilesToPDF("Merged file", "merged.pdf",files)

 

Czy artykuł był pomocny?
5 na 5 gwiazdek

1 rating

5 Stars 100%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
How Can We Improve This Article?