Configuring Doc2Any in LogicalDOC with Microsoft Office

From LogicalDOC Community Wiki
Revision as of 08:25, 28 January 2026 by Blucecio (talk | contribs) (first rev)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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
  • 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
LogicalDOC – Doc2Any format converter configuration

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=true forces Doc2Any to use Microsoft Word instead of LibreOffice
  • runViaService=true enables execution via a background service
  • usePrinter=false avoids 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
allowed-commands.txt with Doc2Any executables

---

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

Command Prompt – Run as Administrator

---

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
docPrint_Service in Windows Task Scheduler

General Tab

  • Run whether user is logged on or not
  • Run with highest privileges

---

Triggers Tab

  • Trigger: At system startup

---

Settings Tab (Critical)

Task settings preventing forced termination

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

  1. Restart the LogicalDOC service
  2. Upload a DOCX document with complex formatting
  3. Open the preview
  4. 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.