The PDF build process now automatically replaces the first page (auto-generated title page) with a custom cover image.
- Location:
chapters/media/TS_SysmonCommunityGuide_Cover.png - Format: PNG
- Size: ~3 MB (high resolution)
- Page Size: Scaled to fit A4 with aspect ratio maintained
-
Build/replace_cover.py- Python script that handles cover replacement- Uses
pypdf(or PyPDF2) to manipulate PDF pages - Uses
Pillowto process cover image - Uses
reportlabto convert image to PDF page - Maintains A4 page size and centers image
- Uses
-
Build/md2pdf.sh- Updated to call cover replacement after PDF generation- Generates PDF with XeLaTeX (2 passes for TOC)
- Checks for cover image existence
- Replaces first page automatically
- Handles errors gracefully (falls back to original if replacement fails)
-
Dependencies - Added Python packages:
pypdf- PDF manipulationPillow- Image processingreportlab- PDF generation
1. Pandoc converts Markdown → LaTeX
2. XeLaTeX generates PDF (2 passes)
3. Custom cover replacement:
a. Check if TS_SysmonCommunityGuide_Cover.png exists
b. Convert cover image to PDF page (A4, centered, scaled)
c. Replace first page of generated PDF with cover
d. Save final PDF
4. Clean up temporary files
# Just build as usual - cover replacement happens automatically
make pdf
# Or using build.sh
./build.sh pdfmacOS:
make install-deps-mac
# Or manually:
pip3 install --user --break-system-packages pypdf Pillow reportlabUbuntu/Debian:
make install-deps
# Or manually:
pip3 install pypdf Pillow reportlabDocker:
# Dependencies already included in Docker image
make docker-pdf- Replace
chapters/media/TS_SysmonCommunityGuide_Cover.pngwith your image - Image can be any size - will be automatically scaled to fit A4
- Maintains aspect ratio - will not distort
- Centered on page
If you want to use the default Pandoc-generated title page:
- Remove or rename the cover image file, OR
- Comment out the cover replacement section in
Build/md2pdf.sh(lines 64-80)
- Cover image is converted to a temporary PDF (
/tmp/cover_page.pdf) - Image is scaled to fit A4 (210mm × 297mm) while maintaining aspect ratio
- Image is centered on the page
- Uses high-quality rendering from Pillow
- Original PDF is temporarily renamed
- Cover page PDF is created with exact A4 dimensions
- First page of original PDF is replaced with cover
- All other pages (2-N) are copied unchanged
- Temporary files are cleaned up
- Checks if cover image exists before attempting replacement
- Validates PDF was generated successfully
- Falls back to original PDF if replacement fails
- Provides clear error messages in build output
After building, verify the cover replacement worked:
# Check PDF exists and has correct size
ls -lh Build/SysmonGuide.pdf
# Check number of pages
file Build/SysmonGuide.pdf
# Open PDF and visually inspect first page
open Build/SysmonGuide.pdf # macOS
xdg-open Build/SysmonGuide.pdf # LinuxInstall Python dependencies:
pip3 install --user --break-system-packages pypdf Pillow reportlabCheck build log for errors:
cat Build/pdfgen.logVerify the image exists:
ls -lh chapters/media/TS_SysmonCommunityGuide_Cover.pngThe cover image adds ~3MB to the PDF. To reduce size:
- Optimize the cover image before building
- Convert to lower DPI (e.g., 150 DPI instead of 300 DPI)
- Use JPEG instead of PNG (with quality setting)
Potential improvements:
- Support for back cover page
- Configurable cover image path in chapters.json
- Multiple cover formats (PDF, SVG, etc.)
- Automatic image optimization
- Cover template system