Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions gh_pages/assets/pdf-template/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}

% Packages
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

% Font setup for XeLaTeX/LuaLaTeX vs pdfLaTeX
\ifxetex
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\else
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\fi
\fi

\usepackage{microtype}
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
\usepackage{hyperref}
Expand Down Expand Up @@ -109,6 +121,10 @@
$highlighting-macros$
$endif$

% Define tightlist command for pandoc lists
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

% Document metadata
$if(title)$
\title{$title$}
Expand Down
Binary file added gh_pages/assets/pdf/complete-documentation.pdf
Binary file not shown.
Binary file added gh_pages/assets/pdf/getting-started.pdf
Binary file not shown.
Binary file added gh_pages/assets/pdf/hmi-usage.pdf
Binary file not shown.
Binary file added gh_pages/assets/pdf/plc-usage.pdf
Binary file not shown.
Binary file added gh_pages/assets/pdf/service-config.pdf
Binary file not shown.
33 changes: 29 additions & 4 deletions tcpkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,43 @@ tcpkg/
│ ├── BUILD_INSTRUCTIONS.md
│ └── QUICK_REFERENCE.txt
├── Build.ps1 # Convenience wrapper (run from here)
└── Build.bat # Convenience wrapper (double-click)
├── Build.bat # Convenience wrapper (double-click)
└── convert_to_pdf.py # Generate documentation PDFs (Python)
```

## Quick Start

### Option 1: PowerShell (Recommended)
### Build TwinCAT Packages

#### Option 1: PowerShell (Recommended)
```powershell
.\Build.ps1 -CleanBuild
```

### Option 2: Batch File
#### Option 2: Batch File
Double-click `Build.bat`

### Option 3: From Scripts Directory
#### Option 3: From Scripts Directory
```powershell
cd scripts
.\Build-TcPackages.ps1 -CleanBuild
```

### Generate Documentation PDFs

To generate PDF documentation from the markdown files:

```bash
python convert_to_pdf.py
```

This script:
- Automatically installs required Python packages (markdown, weasyprint)
- Converts all markdown files from `gh_pages\_docs\` to PDFs
- Outputs individual PDFs to `packages\EventvideoPlayback.Documentation\bin\`
- Creates a combined `complete-documentation.pdf` with all documentation
- No external dependencies needed (no LaTeX or pandoc required!)

## Adding New Packages

To add a new package to the build:
Expand Down Expand Up @@ -75,10 +93,17 @@ For complete documentation, see:

## Requirements

### For Building TwinCAT Packages
- TwinCAT tcpkg tool (installed with TwinCAT XAE)
- PowerShell 5.1 or higher
- Windows 10/11

### For PDF Generation (Optional)
- Python 3.6+
- Python packages (automatically installed by script):
- `markdown` - Markdown parser
- `xhtml2pdf` - HTML to PDF converter (pure Python, no external dependencies)

## Support

For issues or questions, review the documentation in the `scripts/` directory or check the console output for specific error messages.
257 changes: 257 additions & 0 deletions tcpkg/convert_to_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
#!/usr/bin/env python3
"""Convert markdown documentation to PDF using Python libraries"""

import sys
import os
from pathlib import Path

# Force UTF-8 encoding for console output on Windows
if sys.platform == 'win32':
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')

def check_dependencies():
"""Check if required packages are installed"""
try:
import markdown
except ImportError:
print("Installing required package: markdown...")
import subprocess
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'markdown'])
import markdown

try:
import xhtml2pdf
except ImportError:
print("Installing required package: xhtml2pdf...")
import subprocess
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'xhtml2pdf'])
import xhtml2pdf

return True

def markdown_to_html(md_content, title="Documentation"):
"""Convert markdown to HTML with styling"""
import markdown

# Convert markdown to HTML
md = markdown.Markdown(extensions=[
'extra',
'codehilite',
'toc',
'tables',
'fenced_code'
])
html_content = md.convert(md_content)

# Create full HTML document with CSS
html = f"""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{title}</title>
<style>
@page {{
size: letter;
margin: 1in;
}}
body {{
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 100%;
}}
h1, h2, h3, h4, h5, h6 {{
color: #d32f2f;
margin-top: 1.5em;
margin-bottom: 0.5em;
}}
h1 {{
font-size: 2em;
border-bottom: 2px solid #d32f2f;
padding-bottom: 0.3em;
}}
h2 {{
font-size: 1.5em;
}}
code {{
background-color: #f5f5f5;
padding: 2px 4px;
border-radius: 3px;
font-family: 'Courier New', monospace;
font-size: 0.9em;
}}
pre {{
background-color: #f5f5f5;
padding: 10px;
border-left: 3px solid #d32f2f;
overflow-x: auto;
border-radius: 3px;
}}
pre code {{
background-color: transparent;
padding: 0;
}}
table {{
border-collapse: collapse;
width: 100%;
margin: 1em 0;
}}
th, td {{
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}}
th {{
background-color: #d32f2f;
color: white;
}}
tr:nth-child(even) {{
background-color: #f9f9f9;
}}
a {{
color: #d32f2f;
text-decoration: none;
}}
a:hover {{
text-decoration: underline;
}}
blockquote {{
border-left: 4px solid #d32f2f;
padding-left: 1em;
margin-left: 0;
color: #666;
}}
.toc {{
background-color: #f9f9f9;
border: 1px solid #ddd;
padding: 1em;
margin-bottom: 2em;
}}
</style>
</head>
<body>
{html_content}
</body>
</html>
"""
return html

def convert_md_to_pdf(md_file, output_file):
"""Convert a single markdown file to PDF"""
from xhtml2pdf import pisa

# Read markdown file
with open(md_file, 'r', encoding='utf-8') as f:
md_content = f.read()

# Get title from filename
title = md_file.stem.replace('-', ' ').replace('_', ' ').title()
title = f"Event Video Playback - {title}"

# Convert to HTML
html = markdown_to_html(md_content, title)

# Convert HTML to PDF
with open(output_file, 'wb') as pdf_file:
pisa_status = pisa.CreatePDF(html, dest=pdf_file)

if pisa_status.err:
raise Exception(f"PDF generation failed with {pisa_status.err} errors")

def main():
"""Main function"""
# Check dependencies
print("Checking dependencies...")
if not check_dependencies():
return 1

print("✓ All dependencies installed\n")

# Set paths
script_dir = Path(__file__).parent
project_root = script_dir.parent
docs_dir = project_root / 'gh_pages' / '_docs'
output_dir = script_dir / 'packages' / 'EventvideoPlayback.Documentation' / 'bin'

# Verify input directory exists
if not docs_dir.exists():
print(f"✗ Documentation directory not found: {docs_dir}")
return 1

# Create output directory
output_dir.mkdir(parents=True, exist_ok=True)

# Get all markdown files
md_files = sorted(docs_dir.glob('*.md'))

if not md_files:
print(f"✗ No markdown files found in {docs_dir}")
return 1

print(f"Found {len(md_files)} markdown files")
print(f"Output directory: {output_dir}\n")

success = 0
failed = 0

# Convert each file
for md_file in md_files:
pdf_name = md_file.stem + '.pdf'
pdf_path = output_dir / pdf_name

print(f"Converting {md_file.name}...", end=' ')

try:
convert_md_to_pdf(md_file, pdf_path)
print("✓")
success += 1
except Exception as e:
print(f"✗ {e}")
failed += 1

# Create combined PDF
print(f"\nCreating combined PDF...", end=' ')
try:
from xhtml2pdf import pisa

# Combine all markdown content
combined_content = []
for md_file in md_files:
with open(md_file, 'r', encoding='utf-8') as f:
content = f.read()
# Add a page break between documents
combined_content.append(content)
combined_content.append("\n\n---\n\n")

# Convert to HTML
html = markdown_to_html(''.join(combined_content), "Event Video Playback - Complete Documentation")

# Convert to PDF
combined_path = output_dir / 'complete-documentation.pdf'
with open(combined_path, 'wb') as pdf_file:
pisa_status = pisa.CreatePDF(html, dest=pdf_file)

if pisa_status.err:
raise Exception(f"PDF generation failed with {pisa_status.err} errors")

print("✓")
success += 1
except Exception as e:
print(f"✗ {e}")
failed += 1

# Summary
print(f"\n{'='*40}")
print(f"Success: {success}, Failed: {failed}")
print(f"{'='*40}")

if failed == 0:
print("\n✓ All PDFs generated successfully!")
print(f"Output: {output_dir}")

return 0 if failed == 0 else 1

if __name__ == '__main__':
sys.exit(main())
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>Beckhoff-USA-Community.EventVideoPlayback.XAE</id>
<version>2.0.0</version>
<version>2.0.1</version>
<title>Event Video Playback</title>
<authors>Beckhoff Automation LLC</authors>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand All @@ -21,7 +21,7 @@
<dependencies>
<dependency id="Beckhoff-USA-Community.XAE.HMI.EventVisionControl" version="1.1.3" />
<dependency id="Beckhoff-USA-Community.XAE.PLC.Lib.EventVideoPlayback" version="1.1.1" />
<dependency id="Beckhoff-USA-Community.XAE.Documentation.EventVideoPlayback" version="2.0.0" />
<dependency id="Beckhoff-USA-Community.XAE.Documentation.EventVideoPlayback" version="2.0.1" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>Beckhoff-USA-Community.XAE.Documentation.EventVideoPlayback</id>
<version>2.0.0</version>
<version>2.0.1</version>
<title>Event Video Playback Documentation</title>
<authors>Beckhoff Automation LLC</authors>
<projectUrl>https://github.com/Beckhoff-USA-Community/EventVideoPlayback</projectUrl>
Expand All @@ -13,7 +13,7 @@
<readme>docs/README.md</readme>
<summary>Documentation and examples for EventVideoPlayback system</summary>
<tags>Beckhoff TwinCAT</tags>
<releaseNotes>Version 2.0.0 - Complete documentation for EventVideoPlayback 2.0 release</releaseNotes>
<releaseNotes>Version 2.0.1 - Complete documentation for EventVideoPlayback 2.0 release</releaseNotes>
<description>EventVideoPlayback Documentation Package - Comprehensive documentation for the EventVideoPlayback system including installation guides, usage instructions, system requirements, and service documentation.</description>
</metadata>
<files>
Expand Down
Loading
Loading