start a requestcache.py class

This commit is contained in:
admin 2026-02-26 13:37:05 -08:00
parent c12ddb3e91
commit 927bf24b97
2 changed files with 29 additions and 0 deletions

29
html_to_pdf.py Normal file
View File

@ -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 = "<!DOCTYPE html><html lang=en><head><meta charset='utf-8'></head><body><p>{}</p></body></html>".format(sys.stdin.read().replace('\n','<br>').replace('\t',' '))
html_skeleton = "<!DOCTYPE html><html lang=en><head><meta charset='utf-8'></head><body><p>{}</p></body></html>".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)])

0
requestcache.py Normal file
View File