Configuring Doc2Any in LogicalDOC with Microsoft Office: Difference between revisions
| Line 112: | Line 112: | ||
--- | --- | ||
== Important Note – LogicalDOC-Provided Service | == Important Note – LogicalDOC-Provided Service Scripts == | ||
The following files are '''not part of the standard Doc2Any distribution''' and are ''' | The following files are '''not part of the standard Doc2Any distribution''' and are '''provided by LogicalDOC''' to enable Microsoft Office–based document conversion: | ||
* <code>docPrint_Service.xml</code> | * <code>docPrint_Service.xml</code> | ||
| Line 120: | Line 120: | ||
* <code>register-docPrint_ServiceXML.bat</code> | * <code>register-docPrint_ServiceXML.bat</code> | ||
For convenience and consistency, these files are distributed together in a single archive. | |||
--- | |||
=== Download === | |||
* [[Media:logicaldoc-doc2any-office-service-scripts.zip|Download logicaldoc-doc2any-office-service-scripts.zip]] | |||
--- | --- | ||
=== Installation | === Installation Instructions === | ||
1. Download the ZIP archive from the link above | |||
2. Extract its contents into the following directory: | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| Line 134: | Line 139: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
After extraction, the folder must contain: | |||
-- | <syntaxhighlight lang="text"> | ||
docPrint_Service.xml | |||
register-docPrint_Service.bat | |||
register-docPrint_ServiceXML.bat | |||
</syntaxhighlight> | |||
Do not rename the files or change their relative location. | |||
--- | --- | ||
=== | === Purpose of the Archive === | ||
The scripts contained in this archive: | |||
* define the Windows Scheduled Task used by Doc2Any | |||
* allow Microsoft Office to run in a supported background context | |||
* implement the execution model required by LogicalDOC when | |||
<code>runViaService=true</code> is enabled | |||
This separation allows LogicalDOC to: | |||
* | * control integration behavior | ||
* | * maintain compatibility across Doc2Any versions | ||
* update Office automation logic independently | |||
--- | --- | ||
=== | === Important === | ||
These files must be installed '''before''' registering the <code>docPrint_Service</code> scheduled task. | |||
== Step 3 – Edit the Service Registration Script (Mandatory) == | == Step 3 – Edit the Service Registration Script (Mandatory) == | ||
Latest revision as of 09:25, 28 January 2026
Configuring Doc2Any in LogicalDOC to Use Local Microsoft Office for High-Fidelity PDF Conversion
Overview
LogicalDOC supports Doc2Any as an external document conversion engine for previews and PDF generation. Doc2Any is not bundled or shipped with LogicalDOC: LogicalDOC declares compatibility with it and can invoke it as an external converter once properly installed and configured.
Doc2Any supports a wide range of document formats and, when configured to use a locally installed Microsoft Office instance, provides the highest fidelity PDF output and Word document previews, especially for complex layouts.
To use Doc2Any with LogicalDOC:
- Doc2Any must be downloaded separately from the manufacturer’s website
- The converter must be installed locally on the LogicalDOC server
- LogicalDOC must be configured to invoke Doc2Any as an external tool
In this guide, for consistency, the Doc2Any package (typically distributed as a .zip archive) is assumed to be extracted to:
C:\LogicalDOC\doc2any_cmd
---
Prerequisites
Before starting, ensure the following requirements are met:
- LogicalDOC installed on Windows
- Doc2Any downloaded and installed separately
- Extracted to
C:\LogicalDOC\doc2any_cmd
- Extracted to
- Microsoft Office (Word) installed locally on the same machine
- A Windows user account:
- Associated with a valid Microsoft Office license
- Logged in at least once (profile initialized)
- Administrative access to:
- LogicalDOC Administration panel
- Windows Command Prompt (Run as Administrator)
- Windows Task Scheduler
---
Step 1 – Configure Doc2Any in LogicalDOC
Navigate to:
Administration → Import and Export → Format Converters
In the Associations section, verify or create the following mapping:
- Input:
docx - Output:
pdf - Converter:
DocToAnyConverter

DocToAnyConverter Parameters
Select DocToAnyConverter and configure the parameters as follows:
| Parameter | Value |
|---|---|
| path | C:\LogicalDOC\doc2any_cmd\doc2any.exe
|
| licenseKey | Your Doc2Any license key |
| useOffice | true
|
| usePrinter | false
|
| runViaService | true
|
Notes:
useOffice=trueforces Doc2Any to use Microsoft Word instead of LibreOfficerunViaService=trueenables execution via a background serviceusePrinter=falseavoids dependency on printer drivers
---
Step 2 – Whitelist Executables (allowed-commands.txt)
LogicalDOC restricts execution of external programs for security reasons. All Doc2Any-related executables must be explicitly whitelisted.
Edit the file:
<LogicalDOC installation directory>\conf\allowed-commands.txt
Add or verify the following entries (adjust paths if needed):
C:\LogicalDOC\doc2any_cmd\doc2any.exe
C:\LogicalDOC\ghostscript\bin\gs.exe
C:\LogicalDOC\imagemagick\convert.exe
C:\Program Files\Eclipse Adoptium\jdk-21.0.4.7-hotspot\bin\keytool.exe
C:\LogicalDOC\openssl\bin\openssl.exe
C:\LogicalDOC\clamav\clamscan.exe

---
Important Note – LogicalDOC-Provided Service Scripts
The following files are not part of the standard Doc2Any distribution and are provided by LogicalDOC to enable Microsoft Office–based document conversion:
docPrint_Service.xmlregister-docPrint_Service.batregister-docPrint_ServiceXML.bat
For convenience and consistency, these files are distributed together in a single archive.
---
Download
---
Installation Instructions
1. Download the ZIP archive from the link above 2. Extract its contents into the following directory:
C:\LogicalDOC\doc2any_cmd\doc2any_service
After extraction, the folder must contain:
docPrint_Service.xml
register-docPrint_Service.bat
register-docPrint_ServiceXML.bat
Do not rename the files or change their relative location.
---
Purpose of the Archive
The scripts contained in this archive:
- define the Windows Scheduled Task used by Doc2Any
- allow Microsoft Office to run in a supported background context
- implement the execution model required by LogicalDOC when
runViaService=true is enabled
This separation allows LogicalDOC to:
- control integration behavior
- maintain compatibility across Doc2Any versions
- update Office automation logic independently
---
Important
These files must be installed before registering the docPrint_Service scheduled task.
Step 3 – Edit the Service Registration Script (Mandatory)
Microsoft Office automation must run under a real Windows user account associated with the Office license.
Before registering the service, edit:
C:\LogicalDOC\doc2any_cmd\doc2any_service\register-docPrint_ServiceXML.bat
Locate the placeholder string:
runasuser
Replace it with the exact username of the Windows account to which Microsoft Office is licensed.
Example
If Office is licensed to the user docprint, replace:
runasuser
with:
docprint
Important:
- The user must already exist
- The user must have logged in at least once
- Microsoft Office must be activated for this user
---
Step 4 – Register the DocPrint Background Service
Doc2Any uses a Windows Scheduled Task (not a classic Windows service) to run Microsoft Office reliably in background mode.
Open an Elevated Command Prompt

---
Run the Registration Script
cd C:\LogicalDOC\doc2any_cmd\doc2any_service
register-docPrint_ServiceXML.bat
During execution:
- You will be prompted for the password of the specified Windows user
- The scheduled task docPrint_Service will be created
---
Step 5 – Verify the Task Scheduler Configuration
Open Task Scheduler and locate:
Task Scheduler Library → docPrint_Service

General Tab
- Run whether user is logged on or not
- Run with highest privileges
---
Triggers Tab
- Trigger: At system startup
---
Settings Tab (Critical)

Configure:
- Allow task to be run on demand
- Do not stop the task if it runs longer than a set time
- Do not restart the task on failure
- Force stop only if explicitly requested
- If the task is already running, do not start a new instance
These settings prevent:
- Premature termination of long conversions
- Multiple Office instances
- PDF generation failures
---
Step 6 – Restart and Test
- Restart the LogicalDOC service
- Upload a DOCX document with complex formatting
- Open the preview
- Download the generated PDF
If correctly configured:
- PDF output matches Microsoft Word exactly
- Previews are stable
- No conversion errors appear in logs
---
Why a Scheduled Task Is Used
Microsoft Office applications are not designed to run as Windows services.
Using a Scheduled Task provides:
- Proper user context
- Access to Office COM components
- Stable automation
- Compliance with Microsoft support guidelines
---
Conclusion
By installing Doc2Any externally, configuring LogicalDOC to invoke it correctly, and running Microsoft Office through a dedicated Windows background task, LogicalDOC can deliver:
- High-fidelity PDF conversions
- Accurate Word previews
- Reliable production-grade behavior
This configuration is strongly recommended for enterprise environments where document accuracy is critical.