# Generate Batches of Placeholder PDFs and Images for Upload Testing

> Set a name, a count and an icon folder; the scripts produce numbered test documents (PDF via Word, or PNG/JPG via Pillow) for testing upload forms and workflows.

URL: https://thuyavan.netlify.app/scripts/bulk-test-document-generator
Updated: 2026-10-07

## Problem
Testing upload forms and document workflows needs dozens of distinct sample files, and creating them by hand is slow.

## Solution
Two scripts generate N numbered files: one builds Word documents and converts them to PDF through Microsoft Word, the other draws PNG/JPG images with Pillow. Each shows a heading, date, time and a centred icon cycled from a folder.

## Result
Any number of unique, clearly labelled test files in seconds.

## Input
- An icon/image folder
- base_name, count and output folder set in the script

## Output
- {base_name}_{n}.pdf (Word route) or .png/.jpg (image route)

## Optional output
- Intermediate .docx files (delete line is commented out)

## System flow
Icon folder (Sorted images, circular use) -> Build document (Heading · date · time · icon) -> Convert / draw (Word -> PDF or Pillow canvas) -> Numbered files ({base_name}_1 â€¦ _N)

## How it works
- **Circular image selection:** Icons are taken in sorted order and wrap around, starting from image_start_index.
- **Two output routes:** Word-to-PDF via python-docx and Word automation, or PNG/JPG via Pillow.
- **Configurable layout:** Heading size, image height, canvas size and formats are all parameters.
- **Timestamped content:** Each file shows the generation date and time so test files are easy to tell apart.

## Configuration
- `base_name / count`: File name prefix and how many files to create.
- `image_folder / output_dir`: Where icons are read from and results are written.
- `image_start_index`: 1-based start position in the sorted icon list.
- `output_formats`: Image route only: ('png', 'jpg').

## How to run
Install:

    pip install -r requirements.txt
PDF route (Windows + Microsoft Word):

    python word_to_pdf_batch.py
Image route:

    python image_batch.py

## Impact
- Fast QA data for upload and workflow testing.
- Reproducible, numbered, labelled files.
- No design work needed.

## FAQ
**How do I generate many PDF files with Python?**
word_to_pdf_batch.py builds a .docx per file with python-docx and exports it to PDF through Word automation (Windows).

**Can I make PNG or JPG test images instead?**
Yes. image_batch.py draws the same layout with Pillow and saves PNG and/or JPG.

**Is it meant for real documents?**
No. It is for placeholder test data only.

