/ Published in: Python

So, when I try to set the BYTES_TO_READ variable to more than 200-300 thousands (i.e., just to see what happening, not reading the full book, just some part of it) - it takes HUGE amount of time...
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
BYTES_TO_READ = 10000 def go(text): doc = SimpleDocTemplate("output.pdf") Story = [Spacer(1, 2*inch)] style = styles["Normal"] p = Paragraph(text, style) Story.append(p) doc.build(Story) def get_text_from_file(): source_file = open("book.txt", "r") text = source_file.read(BYTES_TO_READ) source_file.close() return text go(get_text_from_file())
Comments
