This Streamlit application provides a user-friendly interface to dynamically generate PDF documents from a sequence of image-based Harappan script characters. Users can input a custom string of numeric indices, and the app will compile the corresponding images into a properly formatted, downloadable PDF.
The application takes an input string formatted with underscores (e.g., _1_2_3_4) and maps each number to an image file (e.g., 1.png, 2.png) stored in a designated local folder. It dynamically calculates aspect ratios to maintain image proportions, auto-wraps "text" to the next line when it reaches the page width, and generates new pages automatically.
- Dynamic PDF Generation: Compiles a sequence of images into a single PDF based on user input.
- Customizable Page Layout: Adjust maximum writable page width/height, and starting X/Y margins (in mm).
- Adjustable Character Sizing: Set the exact font width (image width) and fine-tune horizontal and vertical gaps between characters.
- Smart Wrapping: Automatically detects page boundaries to wrap characters to the next line or create a new page.
- Visual Reference: Displays a master reference grid (
all_images.png) at the bottom of the app to help users identify the correct character indices.
For the application to work correctly, ensure your project directory is set up as follows:
your_project_folder/
β
βββ app.py # The main Streamlit script
βββ all_images.png # (Optional) Reference image showing all characters
βββ final/ # Folder containing the individual character images
βββ 1.png
βββ 2.png
βββ 3.png
βββ ...
Ensure you have Python installed along with the following dependencies. You can install them using pip:
pip install streamlit opencv-python fpdf
(Note: opencv-python provides the cv2 module used for calculating image aspect ratios).
- Save the provided code as
app.py. - Ensure your
final/folder is populated with the correctly numbered.pngimages. - Open your terminal or command prompt, navigate to the project directory, and run:
streamlit run app.py
- The application will automatically open in your default web browser.
- Configure Parameters: Use the sidebar on the left to set your desired output filename, page layout, and spacing metrics.
- Enter Indices: In the main text area, enter your sequence of character indices. Ensure they are separated by underscores (e.g.,
_12_45_8_112). - Generate: Click the π Generate PDF button.
- Download: Once the processing is complete, click the π₯ Download PDF button to save the generated file to your local machine.