Avatar of Shailesh Shinde
Shailesh Shinde
Flag for India asked on

Formatting and layout in word or pdf

Hi All,

We have an requirement to adjust formatting and layout (like., fonts, line breaks in table, columns and margins) of word or PDF files using any script [Perl, Python or Ruby].

Can you please suggest or provide any references or sample codes for this or suggest which scripting languages will be good for such requirements.

Thanks,
Shail
PDFPythonScripting LanguagesMicrosoft Word

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
Walter Ritzel

The best starting point I know is this: https://automatetheboringstuff.com/chapter13/
It uses python and give pointers to python libraries that can handle PDF and word documents.
Colleen Kayter

Why are you scripting vs. applying a theme that sets all that on the fly? Just curious. With security restrictions becoming more prevalent, I would think that scripting might not work well everywhere.
Shailesh Shinde

ASKER
Hi Colleen Kayter,

The reason for scripting is to include this script in existing automated processing workflow.
This script will read the config file which will contains
font-size=##
font-name=###
....
and manipulate the input source word or pdf files.

Thanks,
Shail
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Shailesh Shinde

ASKER
Hi All,

Can formatting be applied to the text level and the page level to a specific paragraph, a set of paragraphs, a range of pages. Is this possible using perl or python scripts?

Thanks,
Shail
ASKER CERTIFIED SOLUTION
Colleen Kayter

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Shailesh Shinde

ASKER
Hi,

Waiting for coder experts comments.

Thanks,
Shail
Ray Paseur

This looks at things from a PHP perspective, so it may or may not fit your environment, but since PHP is free and open-source it could be worth considering.

PHP has two well-supported libraries for building PDF documents: FPDF and TCPDF.  Both are self-contained object-oriented libraries.  The documentation is pretty good. and they have online examples.  I have never used them to import and adjust pre-existing PDF files, but some others in the E-E forums claim this can be done.  Most of my work has been to take external inputs (forms, databases, API data) and build PDF documents.  For this kind of work, either of the extensions will work well, giving you access to a variety of fonts, colors, layouts, and image placements.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.