Commands
Commands are instructions which are executed sequentially after reaching predefined intermediate results or events. Commands can be partially available only at the server or client call. A basic distinction is made between two command levels:
DocumentCommands Document commands are executed per document, directly after creation of the respective document.
BatchCommands Batch commands are executed at the highest level, after all document commands of the individual entries have been executed.
Availability of all commands
Command | Description | Document | Batch | Client | Server |
---|---|---|---|---|---|
DefaultProcess | Starts the default process registered in Windows for the file type | ✓ | ✓ | ✓ |
|
ConvertToDocument | Converts Office templates (.dotx, etc.) to Office documents (.docx, etc.) | ✓ | ✓ | ✓ | ✓ |
ConvertToPdf | Converts templates or documents (.dotx/.docx) to PDF (.pdf) | ✓ | ✓ | ✓ | ✓* |
Sends the document to the default printer | ✓ | ✓ | ✓ |
| |
SaveAs | Saves the document to the specified destination in the specified format | ✓ | ✓ | ✓ | ✓* |
UpdateFieldsOnOpen | Updates fields and the table of contents in the document | ✓ | ✓ | ✓ | ✓ |
Merge | Connects multiple Office documents into one |
| ✓ | ✓ | ✓ |
CreateConnectorResult | Creates a primedocs connector result file | ✓ |
| ✓ |
|
BindCustomXML | Binds all custom controls with the respective data | ✓ | ✓ | ✓ | ✓ |
InvokeProcess | Calls a specific program registered in the primedocs dashboard | ✓ | ✓ | ✓ |
|
*with certain restrictions
DefaultProcess
This command starts the DefaultProcess registered in Windows for the generated file type. This call works only via the client. Possible parameter:
Start: True/False, if False the process will not be started.
<Command Name="DefaultProcess">
<Parameters>
<Add key="Start">true</Add>
</Parameters>
</Command>
ConvertToDocument
This command applies only to Word documents. primedocs manages and generates Word templates (.dotx). To get a Word document (.docx) after generating the document, this command is needed. If this specification is missing and the result is saved as a .docx file, Word displays an error message..
<Command Name="ConvertToDocument" />
ConvertToPdf
Verfügbarkeit: primedocs Server & primedocs Client
This command is only valid for Word Office documents. primedocs converts the document directly into a PDF.
<Command Name="ConvertToPdf" />
Not all Open XML or Microsoft Word features are supported for PDF conversion via this command. As an alternative there is the possibility to use the installed Microsoft Office for the PDF conversion via the SaveAs command in the client.
NOTE
If custom fonts are used in the document, these fonts must also be installed on the server.
The document is sent to the default printer:
<Command Name="Print" />
SaveAs
CAUTION
On the server, this command cannot be used to convert a Word document to a PDF! Use ConvertToPdf for this purpose.
Saves the document at the specified destination. The new file location is taken into account for all following commands (e.g. in DefaultProcess).
Possible parameters:
Filename: Absolute path with file extension
Overwrite: True/False; specifies whether an existing file should be overwritten.
CreateFolder: True/False; specifies whether to create folders specified in the filename.
AllowUpdateDocumentPart: True/False; if True, the primedocs Document Part will be marked as "SavedDocument" instead of "NewDocument".
CopyOnly: True/False; if set, the document will be saved as a copy in its current state. In the client use case the file is nevertheless e.g. still treated as "Template (.dotx)" and created in the Temp folder and Microsoft Word is opened from this file.
<Command Name="SaveAs">
<Parameters>
<Add key="Filename">\\MyServer\share\organization\...\documentxyz.dotx</Add>
<Add key="Overwrite">true</Add>
<Add key="CreateFolder">true</Add>
<Add key="CopyOnly">false</Add>
<Add key="AllowUpdateDocumentPart">false</Add>
</Parameters>
</Command>
NOTE
In previous versions, the Type
parameter could be specified additionally. This is no longer needed, since a type conversion is implicitly derived via the file extension of the target file.
UpdateFieldsOnOpen
This command applies only to Word documents and stores the information in the document that Office should update the fields, (e.g. tables of contents or links) when opening. Normally, when the document is opened, the user is directly asked if the fields should be updated:
<Command Name="UpdateFieldsOnOpen" />
Alternatively, primedocs can be instructed to update the fields independently via the primedocs ribbon without prompting when opening:
<Command Name="UpdateFieldsOnOpen">
<Parameters>
<Add key="Type">primedocs</Add>
</Parameters>
</Command>
NOTE
It is recommended to use the command together with ConvertToDocument (or for PDF output with ConvertToPdf, since Word also does not display the table of contents correctly when opening a ".dotx" file.
Merge
The merge command applies only to Word documents and can be used to merge multiple documents. The merged document can then be reused as a single document. The command is only available as a BatchCommand.
<Command Name="Merge">
<Parameters>
<Add key="PageNumberStart">10</Add>
</Parameters>
</Command>
The result of the merge command is always a Word document (.docx).
CreateConnectorResult
This command creates a file in XML format with a summary after the entire document creation process is completed.
<Command Name="CreateConnectorResult" />
The contents of the file will look something like this if successful:
<?xml version="1.0" encoding="utf-8"?>
<OneOffixxConnectResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Result>Success</Result>
<Details>
<InputFile>O:\Templates\Template_ShortMessage.oocx</InputFile>
<Input><![CDATA[
<OneOffixxConnectBatch>
...
</OneOffixxConnectBatch>
]]></Connect>
</Details>
</OneOffixxConnectResult>
In case of an error, the file also contains an error message including a stack trace from primedocs (if possible):
<?xml version="1.0" encoding="utf-8"?>
<OneOffixxConnectResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Result>Error</Result>
<Message>System.UnauthorizedAccessException: Access to the path "c:\temp" was denied.
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, ...)
bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
bei primedocs.Core.Connect.Commands.SaveAs.Execute()
...
</Message>
<Details>
<InputFile>O:\Templates\Template_ShortMessage.oocx</InputFile>
<Input><![CDATA[
<OneOffixxConnectBatch>
...
</OneOffixxConnectBatch>
]]></Connect>
</Details>
</OneOffixxConnectResult>
BindCustomXML
This command is only valid for Word documents. primedocs stores all data as so-called "CustomXML data" in the document and Office loads this data when opening the document and writes the values into the respective ContentControls.
<Command Name="BindCustomXML" />
NOTE
There are isolated cases in which Office respectively the Open XML client does not load the correct values or the fields remain empty because, for example, an older version of Office is used or because the Open XML client has not implemented this functionality.
In such cases, the BindCustomXML command can help, because primedocs not only stores the data in the CustomXML already during document generation, but because it simultaneously updates the data in the ContentControls.
InvokeProcess
In the dashboard the allowed applications have to be whitelisted first. The configuration for this can be found in Settings → Connect Settings → InvokeProcess – Configuration and looks roughly as follows:
<CommandConfig>
<Process name="OurSystemNotepad" executablePath="%systemroot%/notepad.exe" />
<Process name="..." executablePath="..." />
</CommandConfig>
The call in the connect file must match the name of an application previously shared in the dashboard. The call can optionally contain arguments and looks like this:
<Command Name="InvokeProcess">
<Parameters>
<Add key="Name">OurSystemNotepad</Add>
<Add key="Arguments">/w test.txt</Add>
</Parameters>
</Command>
PrimeSoft AG, Bahnhofstrasse 4, 8360 Eschlikon, Switzerland