From 927bf24b97274b249873637ce14ab341281f2f16 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 26 Feb 2026 13:37:05 -0800 Subject: [PATCH] start a requestcache.py class --- html_to_pdf.py | 29 +++++++++++++++++++++++++++++ requestcache.py | 0 2 files changed, 29 insertions(+) create mode 100644 html_to_pdf.py create mode 100644 requestcache.py diff --git a/html_to_pdf.py b/html_to_pdf.py new file mode 100644 index 0000000..09e67da --- /dev/null +++ b/html_to_pdf.py @@ -0,0 +1,29 @@ +import fitz # PyMuPDF +import io +from weasyprint import HTML, CSS +from bs4 import BeautifulSoup +import sys + +css=''' +body { + font-size: 40px; + line-height: 40px; + color: #FFF; + font-family: "Times New Roman", Times, serif; + whitespace: pre-wrap; + +} + +@page { + /* Set specific page dimensions: width height */ + size: 1920px 1080px; + margin: 70px; + background-color: #2c5aa0; color: white; + whitespace: pre-wrap; +} +''' +#html_skeleton = "

{}

".format(sys.stdin.read().replace('\n','
').replace('\t',' ')) +html_skeleton = "

{}

".format(sys.stdin.read()) + +HTML(string=html_skeleton).write_pdf('output.pdf', stylesheets=[CSS(string=css)]) +pdf_bytes=HTML(string=html_skeleton).write_pdf(stylesheets=[CSS(string=css)]) diff --git a/requestcache.py b/requestcache.py new file mode 100644 index 0000000..e69de29