Clean TAS header wrap and build master fax PDF
Browse files- make_pdf.py +68 -0
make_pdf.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from pypdf import PdfReader, PdfWriter
|
| 3 |
+
from reportlab.lib.pagesizes import letter
|
| 4 |
+
from reportlab.pdfgen import canvas
|
| 5 |
+
|
| 6 |
+
base = Path.home() / "viper_hf_space"
|
| 7 |
+
dl = Path("/sdcard/Download")
|
| 8 |
+
ssn_full = "680-05-3812"
|
| 9 |
+
ssn_red = "XXX-XX-3812"
|
| 10 |
+
|
| 11 |
+
txt_path = base / "tas_form_911_escalation.txt"
|
| 12 |
+
if txt_path.exists():
|
| 13 |
+
raw = txt_path.read_text(encoding="utf-8")
|
| 14 |
+
raw = raw.replace("DEDICATED FAX : (855) 820-7112 DATE", "DEDICATED FAX : (855) 820-7112\nDATE")
|
| 15 |
+
txt_path.write_text(raw, encoding="utf-8")
|
| 16 |
+
full_txt = raw.replace(ssn_red, ssn_full)
|
| 17 |
+
else:
|
| 18 |
+
full_txt = "TAS FORM 911 ESCALATION BRIEF - JONATHAN ANTHONY TAYLOR"
|
| 19 |
+
|
| 20 |
+
if dl.exists():
|
| 21 |
+
(dl / "TAS_Form_911_Escalation_Taylor.txt").write_text(full_txt, encoding="utf-8")
|
| 22 |
+
|
| 23 |
+
tmp_pdf = base / "brief_pages.pdf"
|
| 24 |
+
c = canvas.Canvas(str(tmp_pdf), pagesize=letter)
|
| 25 |
+
w, h = letter
|
| 26 |
+
|
| 27 |
+
def add_doc(title, body):
|
| 28 |
+
c.setFont("Courier-Bold", 10)
|
| 29 |
+
c.drawString(40, h - 40, title)
|
| 30 |
+
c.setFont("Courier", 8.5)
|
| 31 |
+
y = h - 60
|
| 32 |
+
for line in body.splitlines():
|
| 33 |
+
if y < 45:
|
| 34 |
+
c.showPage()
|
| 35 |
+
c.setFont("Courier", 8.5)
|
| 36 |
+
y = h - 45
|
| 37 |
+
c.drawString(40, y, line[:90])
|
| 38 |
+
y -= 11
|
| 39 |
+
c.showPage()
|
| 40 |
+
|
| 41 |
+
add_doc("FAX TO: LAS VEGAS TAS (1-855-820-7112)", full_txt)
|
| 42 |
+
|
| 43 |
+
cp05 = base / "cp05_reconciliation_packet.md"
|
| 44 |
+
if cp05.exists():
|
| 45 |
+
ct = cp05.read_text(encoding="utf-8")
|
| 46 |
+
ct = ct.replace("[INSERT REDACTED / LAST 4 OR FULL SSN ON PRINTED COPY]", ssn_full)
|
| 47 |
+
add_doc("ATTACHMENT: IRS CP05 RECONCILIATION PACKET", ct)
|
| 48 |
+
|
| 49 |
+
c.save()
|
| 50 |
+
|
| 51 |
+
writer = PdfWriter()
|
| 52 |
+
f911 = base / "IRS_Form_911_Official.pdf"
|
| 53 |
+
if f911.exists():
|
| 54 |
+
try:
|
| 55 |
+
writer.append(PdfReader(str(f911)))
|
| 56 |
+
except Exception as e:
|
| 57 |
+
print("Note:", e)
|
| 58 |
+
|
| 59 |
+
for p in PdfReader(str(tmp_pdf)).pages:
|
| 60 |
+
writer.add_page(p)
|
| 61 |
+
|
| 62 |
+
if dl.exists():
|
| 63 |
+
out = dl / "TAS_Form_911_Complete_Fax_Packet_Taylor.pdf"
|
| 64 |
+
with open(out, "wb") as f:
|
| 65 |
+
writer.write(f)
|
| 66 |
+
print("[+] MASTER FAX PDF CREATED:", out)
|
| 67 |
+
|
| 68 |
+
tmp_pdf.unlink(missing_ok=True)
|