Open PDF-file instead of saving it with weasyprint in python

Viewed 10

I am creating a pdf file in python with the weasyprint package. Creation and saving it works fine but I would prefer python to simply create the PDF and open it in a viewer so that the reader can save it manually.

A sample code of the saving version is as follow:

from jinja2 import Environment, FileSystemLoader
from weasyprint import HTML


env = Environment(loader=FileSystemLoader('.'))

string = '<!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><title>TEST</title></head><body><h2>Test</h2></body></html>'

HTML(string = string, base_url = '.').write_pdf('example.pdf')

How can I open the created PDF instead of saving it, please?

0 Answers
Related