Python Forum
Using Pypdf2 write a string to a pdf file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Pypdf2 write a string to a pdf file
#1
I will read 130+ excel files in as lines of strings in Python. I want to write each line to a pdf. Each excel file is just 1 A5 landscape sheet. I can batch print pdfs in a bash shell easily.

I import PyPDF2

I can create a pdf or a series pdf files with:

with open(path + fileName, 'wb') as out:
        pdf_writer.write(out)
but I'm too dumb to see how to write a string to this pdf. If I try to write a string variable, I just get errors. If I convert the string to bytes, I just get errors.

How do I get string into my pdf??

string = 'any old string'
Reply


Messages In This Thread
Using Pypdf2 write a string to a pdf file - by Pedroski55 - Apr-11-2019, 01:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What does .flush do? How can I change this to write to the file? Pedroski55 3 288 Apr-22-2024, 01:15 PM
Last Post: snippsat
  Last record in file doesn't write to newline gonksoup 3 484 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  write to csv file problem jacksfrustration 11 1,626 Nov-09-2023, 01:56 PM
Last Post: deanhystad
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,560 Nov-09-2023, 10:56 AM
Last Post: mg24
  PyPDF2 deprecation problem gowb0w 5 4,356 Sep-21-2023, 12:38 PM
Last Post: Pedroski55
  Need to replace a string with a file (HTML file) tester_V 1 796 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,598 Aug-07-2023, 05:32 AM
Last Post: DPaul
  How do I read and write a binary file in Python? blackears 6 7,051 Jun-06-2023, 06:37 PM
Last Post: rajeshgk
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,149 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Read text file, modify it then write back Pavel_47 5 1,685 Feb-18-2023, 02:49 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020