Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You can achieve this using a programming language like Python and a library like ReportLab for generating PDFs. Here's a basic outline of how you can accomplish this:
- Load your image and CSV file containing the names into your Python script.
- Use ReportLab to open a new PDF file and add the image onto each page.
- Iterate through each name in the CSV file, add the name onto the image, and save the PDF file with the corresponding name.
- Below is a sample code snippet to get you started:
- from reportlab.pdfgen import canvas
- from reportlab.lib.pagesizes import letter
- from reportlab.lib.units import inch
- from reportlab.pdfbase.ttfonts import TTFont
- from reportlab.pdfbase import pdfmetrics
- import csv
- # Load image
- image_path = 'your_image.jpg'
- # Load CSV file
- csv_file = 'your_names.csv'
- # Function to generate PDF with name
- def generate_pdf(name):
- c = canvas.Canvas(f'{name}.pdf', pagesize=letter)
- c.drawImage(image_path, 0, 0, width=8.5*inch, height=11*inch)
- c.setFont("Helvetica", 12)
- c.drawString(100, 100, name)
- c.save()
- # Main function
- def main():
- # Load names from CSV file
- with open(csv_file, 'r') as file:
- reader = csv.reader(file)
- for row in reader:
- name = row[0]
- generate_pdf(name)
- if __name__ == '__main__':
- main()
- Replace your_image.jpg with the path to your image and your_names.csv with the path to your CSV file containing names. This script will generate a PDF file for each name in your CSV list with the name added onto the image. You may need to adjust the positioning of the name on the image to suit your needs.
- Make sure to install ReportLab library, you can do it by running pip install reportlab command.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement