Completed

Python function to resize text to predefined Pdf canvas sizes.

Published on the March 31, 2023 in IT & Programming

About this project

Open

I need someone to write a python function that fits the text from a word file in one of the predefined size PDF canvas. The input for this function should be the word file path.

The function should work like this:

1. Extract the text from the word file.

2. Fit the text in one of the predefined pdf sizes. It should start with the smallest size of width 95.4mm x height 30mm, and work its way up to the largest size of width 246.4mm x height 294mm.  The goal is to fit the text in the smallest canvas size without changing: font style, font size, font type or line breaks.

The sizes are:
95.4mm x 30mm
95.4mm x 63mm
95.4mm x 96mm
95.4mm x 129mm
95.4mm x 162mm
95.4mm x 195mm
95.4mm x 228mm
95.4mm x 261mm
95.4mm x 294mm
145.4mm x 30mm
145.4mm x 63mm
145.4mm x 96mm
145.4mm x 129mm
145.4mm x 162mm
145.4mm x 195mm
145.4mm x 228mm
145.4mm x 261mm
145.4mm x 294mm
246.4mm x 30mm
246.4mm x 63mm
246.4mm x 96mm
246.4mm x 129mm
246.4mm x 162mm
246.4mm x 195mm
246.4mm x 228mm
246.4mm x 261mm
246.4mm x 294mm

3. If the text is too large to fit in the canvas sizes, the function should progressively increase the canvas size until it finds a size that fits all the text.

4. It should then save the modified document as a 300dpi pdf file.

The function must not change the line breaks.
The function must not change the font type.
The function must not change the font style.
The function must not change the font size.

Category IT & Programming
Subcategory Other
Project size Small
Is this a project or a position? Project
I currently have Not applicable
Required availability As needed

Delivery term: Not specified

Skills needed