timetrack-pro/convert_to_pdf.ps1
StillHammer 7c3dd3fb31 Add VBS scripts, documentation, and HTML form templates
- Test and helper VBS scripts for VBA MCP development
- Technical reference documentation and PDFs
- HTML form templates for all 5 forms
- PowerShell and Python scripts for PDF/documentation generation

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-21 11:53:09 +07:00

43 lines
1.1 KiB
PowerShell

# PowerShell script to convert Markdown to PDF using Microsoft Word
param(
[string]$MarkdownFile = "C:\Users\alexi\Documents\projects\timetrack-pro\TECHNICAL_REFERENCE.md",
[string]$OutputPdf = "C:\Users\alexi\Documents\projects\timetrack-pro\TECHNICAL_REFERENCE.pdf"
)
Write-Host "Converting Markdown to PDF using Microsoft Word..."
try {
$Word = New-Object -ComObject Word.Application
$Word.Visible = $false
Write-Host "Opening Markdown file..."
$Doc = $Word.Documents.Open($MarkdownFile)
Write-Host "Converting to PDF..."
$Doc.SaveAs([ref]$OutputPdf, [ref]17)
$Doc.Close()
$Word.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Doc) | Out-Null
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Word) | Out-Null
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
Write-Host "PDF created successfully!"
} catch {
Write-Host "Error occurred:"
Write-Host $_.Exception.Message
if ($Word) {
$Word.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Word) | Out-Null
}
exit 1
}