Giter Club home page Giter Club logo

pdf-generator's Introduction

README

PDF Generator from CSV using Python

This Python script utilizes the fpdf library to generate a PDF document based on data from a CSV file. The generated PDF contains multiple pages, each representing a different topic along with a specified number of pages.

Requirements

  • Python 3.x
  • Install the fpdf library using:
    pip install fpdf

Usage

  1. Ensure you have a CSV file named topics.csv with the following columns:

    • Topic: The title of the topic.
    • Pages: The number of pages for each topic.
  2. Run the script using:

    python main.py
  3. The script will read the CSV file, generate a PDF (pdf-template.pdf), and populate it with topics and pages.

Script Explanation

  1. Import Libraries

    • The script uses the fpdf library for PDF generation and pandas for reading the CSV file.
  2. Initialize PDF Object

    • An FPDF object is created with specified orientation, unit, and format.
  3. Read CSV Data

    • The script reads data from the topics.csv file into a pandas DataFrame (df).
  4. Iterate Over DataFrame

    • For each row in the DataFrame, a new page is added to the PDF.
    • Topic title is added to the page along with a horizontal line.
    • Footer is set with the same topic title.
  5. Generate Multiple Pages for Each Topic

    • If a topic has more than one page, additional pages are generated with the same topic title in the footer.
  6. Output PDF

    • The generated PDF is saved as pdf-template.pdf.

Note

  • Ensure that the CSV file is correctly formatted with the required columns.
  • Check the output PDF (pdf-template.pdf) for the finalized document.

pdf-generator's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.