0

I am trying to use pdfkit module on python to create pdf file from text. the first time I ran the following code, it was alright, but after the second attempt the background of the created file is dark, I tried to write this code into a different file and execute it but the result is the same. Would somebody please show me how to fix it. Thanks.

This is the code I tried to test the pdfkit:

#!/usr/bin/python3 
import pdfkit
pdfkit.from_string('MicroPyramid', 'micro_2.pdf')
2
  • this code works correctly on Linux Mint 19.2, Python 3.7, pdfkit 0.6.1 Commented Jun 17, 2020 at 21:56
  • did you run it in console/terminal to see if you don't get error message? Did you delete micro_2.pdf before running code again ? Commented Jun 17, 2020 at 21:57

1 Answer 1

0

If you can use a different library, try pdfme. It's a powerful library in python to create PDF documents.

from pdfme import buid_pdf

with open('micro_2.pdf', 'wb') as f:
    build_pdf({'sections': [{'content': ['MicroPyramid']}]})

Check the docs here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.