XDocReport Documentation

repository·master·Indexed 23 days ago

https://github.com/opensagres/xdocreport

XDocReport is a Java-based reporting engine that merges XML documents (.docx, .odt) with Java data models to generate reports and convert them into formats such as PDF and XHTML. It includes a Java API, a command-line interface (CLI) for document processing, and remoting tools for interacting with JAXRS and JAXWS services.

Tokens
2K
Snippets
0
Records
11
Agent score
79%

What's inside XDocReport

  1. What is XDocReport

    master
    XDocReport (XML Document reporting) is a Java API designed to merge XML-based documents with Java models. It supports documents created with MS Office (.docx) or OpenOffice/LibreOffice (.odt). The tool allows you to generate reports and convert them into various formats such as PDF or XHTML.
  2. Understand XDocReport Licensing and iText Compatibility

    master

    XDocReport has a split licensing model depending on which modules you use:

    • XDocReport Core: Licensed under the MIT License, allowing for easy redistribution and modification.
    • iText-based PDF Converter: The iText-based converter uses iText 2.1.7, which is licensed under the LGPL license.

    Important: If you use and redistribute XDocReport with the iText-based PDF converter, your project must comply with the LGPL license rather than the MIT license. This is why the official XDocReport samples are licensed under LGPL.

  3. Access XDocReport Demos and REST Services

    master

    You can interact with XDocReport through several online web applications to test report generation and conversion capabilities:

    Source code for these demos is available at https://github.com/opensagres/xdocreport.samples.

  4. Reference the XDocReport-Repository Tools CLI arguments

    master

    The following positional arguments are accepted by the xdrtools-rep.bat script in this exact order:

    ArgumentDescription
    BASE_ADDRESSThe base address for the service
    USERThe username
    PASSWORDThe password
    SERVICE_TYPEThe type of service
    SERVICE_NAMEThe name of the service
    OUTOutput file path
    ERRError log/file path
    RESOURCESResources path/identifier
    CHUNKChunk size or configuration
    TIMEOUTTimeout value

    Note: Because these are passed as positional parameters in a batch script, ensure you provide all required values in the correct sequence.

  5. Reference: XDocReport Remoting Service Names

    master

    The following service names are supported by the CLI to determine the operation type:

    • name: Retrieves the repository name.
    • root: Retrieves the root resource structure (output as XML).
    • download: Downloads a specific resource.
    • upload: Uploads a resource from a local file.
    • uploadLarge: (JAXRS only) Uploads a large file using streaming.
    • downloadLarge: (JAXRS only) Downloads a large file using streaming.
  6. Use the xdrtools-rep.sh CLI for XDocReport Remoting

    master

    The xdrtools-rep.sh shell script is a CLI entrypoint used to launch the XDocReport Remoting tools. It wraps a Java execution that invokes fr.opensagres.xdocreport.document.tools.remoting.resources.Main.

    To use this tool, you must provide arguments in a specific positional order. Note that the script is designed such that if you provide more than the expected number of arguments for certain positions, it will trigger an error.

    Positional Arguments

    PositionArgument NameDescription
    1BASE_ADDRESSThe base address for the service
    2USERThe user for authentication
    3PASSWORDThe password for authentication
    4SERVICE_TYPEThe type of service being accessed
    5SERVICE_NAMEThe name of the service
    6OUTOutput file path
    7ERRError log file path
    8RESOURCESPath to resources
    9CHUNKChunking configuration
    10TIMEOUTTimeout value

    Underlying Java Flags

    The script maps these positional arguments to the following Java command-line flags:

    • -baseAddress
    • -user
    • -password
    • -serviceType
    • -serviceName
    • -out
    • -err
    • -resources
    • -chunk
    • -timeout
  7. Use the XDocReport CLI via xdrtools.sh

    master

    The xdrtools.sh script is a shell wrapper for the fr.opensagres.xdocreport.document.tools.Main Java class. It allows you to run XDocReport tools from the command line by providing input files, output destinations, and configuration parameters.

    Note: The script expects arguments in a specific order. If you provide more than the expected number of arguments, it will fail with an error.

    Arguments

    • -in: The input file path.
    • -out: The output file path.
    • -dataDir: The directory containing data files.
    • -metadataFile: The path to the metadata file.
    • -err: The error file/log path.
  8. Use the XDocReport CLI via xdrtools.bat

    master

    The xdrtools.bat script is a Windows batch entrypoint for running XDocReport command-line tools. It requires five positional arguments to execute the fr.opensagres.xdocreport.document.tools.Main class.

    Arguments:

    1. IN: Input file path
    2. OUT: Output file path
    3. METADATA_FILE: Path to the metadata file
    4. DATA_DIR: Directory containing data files
    5. ERR: Error file path/identifier

    Usage Example:

    xdrtools.bat input.docx output.pdf metadata.xml ./data error.log
  9. Use the XDocReport Remoting CLI

    master

    The Main class provides a command-line interface for interacting with XDocReport remoting resources. It supports both JAXRS and JAXWS service types and allows for common operations such as uploading/downloading resources, retrieving the repository name, and inspecting the root resource structure.

    CLI Arguments

    ArgumentDescription
    -baseAddressThe base URL of the remoting service.
    -serviceTypeThe protocol type: JAXWS or JAXRS (defaults to JAXRS if not specified).
    -serviceNameThe specific operation to perform (e.g., upload, download, root, name, uploadLarge, downloadLarge).
    -resourcesThe resource ID(s) to operate on.
    -outThe output file path for the result.
    -userUsername for authentication (Note: the code uses -password for both user and password in some logic, but -user is the intended semantic for the context).
    -passwordPassword for authentication.
    -timeoutConnection timeout in milliseconds.
    -chunkBoolean flag to enable/disable chunking.
    -errPath to a file where error stack traces should be written.
  10. Use the XDocReport CLI tool

    master

    The fr.opensagres.xdocreport.document.tools.Main class provides a command-line interface for processing documents using XDocReport. It allows you to specify an input file, an output destination, a template engine, metadata files, and a directory containing data providers.

    CLI Arguments

    FlagDescription
    -inThe path to the input file.
    -outThe path to the output file.
    -errThe path to a file where error stack traces should be written. If the file exists, it is deleted before writing.
    -engineThe type of template engine to use.
    -metadataFilePath to an XML metadata file. If provided, this file determines the templateEngineKind.
    -dataDirA directory containing data files (e.g., JSON, XML). The tool will scan this directory and create IDataProvider instances for each supported file extension. If no providers are found but a metadata file is present, the tool attempts to generate a default.json in this directory.

    Usage Example

    java fr.opensagres.xdocreport.document.tools.Main -in input.docx -out output.pdf -engine freemarker -dataDir ./data
  11. Use the XDocReport-Repository Tools CLI via Windows Batch Script

    master

    The xdrtools-rep.bat script is a Windows command-line entrypoint for running the XDocReport-Repository Tools. It executes the fr.opensagres.xdocreport.document.tools.remoting.resources.Main class with a set of positional arguments.

    To use the tool, you must provide arguments in the specific order defined by the script. The script automatically builds the classpath by scanning the ../lib directory for all available .jar files.