25 lines
751 B
Python
25 lines
751 B
Python
import json
|
|
import glob
|
|
from fpdf import FPDF
|
|
|
|
pdf = FPDF()
|
|
pdf.set_auto_page_break(auto=True, margin=15)
|
|
|
|
for f in glob.glob('output/20260612_110447/articles/*/info.json'):
|
|
info = json.loads(open(f, encoding='utf-8').read())
|
|
if not info.get('priority'):
|
|
continue
|
|
|
|
pdf.add_page()
|
|
pdf.set_font("helvetica", "B", 16)
|
|
pdf.cell(0, 10, "Header", ln=True)
|
|
|
|
pdf.set_font("helvetica", "B", 12)
|
|
pdf.multi_cell(0, 8, f"Headline: {info.get('headline_english', '')}")
|
|
print(f"Testing Category: {info.get('category', '')}")
|
|
pdf.multi_cell(0, 8, f"Category: {str(info.get('category', '')).upper()}")
|
|
pdf.multi_cell(0, 8, f"Why: {info.get('reasoning', '')}")
|
|
|
|
pdf.output('test_real.pdf')
|
|
print("SUCCESS!")
|