Skip to content

LucaF-Code/TwinCAT_To_PDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TwinCAT_To_PDF

Automatically generates a clean, structured PDF from TwinCAT PLC source files (.TcPOU, .TcDUT, .TcGVL, .TcIO), with table of contents and syntax highlighting.

πŸ“œ Description

TwinCAT_To_PDF is a Python script designed to extract code from XML-based TwinCAT project files and generate a human-readable PDF document. It supports:

  • Full code extraction: declarations, implementations, methods, and properties.
  • Hierarchical structure with automatic section numbering.
  • Table of contents for easy navigation.
  • Syntax highlighting for better readability.

This tool is especially useful for documentation, archiving, or code reviews where a printable or shareable version of the PLC logic is required.

⚠️ Note: This tool only supports Structured Text (ST). Other TwinCAT languages like LD, FBD, or SFC are not supported.

πŸ—‚οΈ Supported File Types

  • .TcPOU – Function Blocks, Functions, Programs
  • .TcDUT – Data Types
  • .TcGVL – Global Variable Lists
  • .TcIO – IO Configurations

βœ… Features

  • Extracts structured TwinCAT code from XML files
  • Formats code with consistent indentation
  • Highlights keywords and comments
  • Automatically generates a PDF with:
    • Custom title page
    • Table of contents
    • Section headers based on file names
    • Page numbers and footer info

πŸš€ Getting Started

To generate a PDF from the XML files of your TwinCAT project, run the following command:

python /path/to/your/TwinCAT_To_PDF.py /path/to/your/TwinCAT_project /path/to/your/TwinCAT_project/output_document.pdf

Prerequisites

  • Python 3.10+

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages