Add professional borders to the upload pdf without changing the content and pages

Reading File
Running Command

python3 -c " from pypdf import PdfReader import os path = '/home/daytona/workspace/attachments/d8415369-8480-4a17-bcaa-3b011923ffd9/DOC-20260714-WA0045..pdf' reader = PdfReader(path) print(f'Pages: {len(reader.pages)}') page = reader.pages[0] print(f'Page size: {float(page.mediabox.width):.2f} x {float(page.mediabox.height):.2f} pts') "

Running Command

python3 << 'EOF' import io from pypdf import PdfReader, PdfWriter from reportlab.pdfgen import canvas from reportlab.lib.colors import HexColor INPUT = '/home/daytona/workspace/attachments/d8415369-8480-4a17-bcaa-3b011923ffd9/DOC-20260714-WA0045..pdf' OUTPUT = '/home/daytona/workspace/DOC-20260714-WA0045-bordered.pdf' reader = PdfReader(INPUT) writer = PdfWriter() # ── border parameters ──────────────────────────────────────────────── OUTER_MARGIN = 18 # pt from page edge (~6 mm) INNER_MARGIN = 25 # pt from page edge (~9 mm) OUTER_WIDTH = 2.5 # pt line thickness INNER_WIDTH = 0.8 # pt line thickness CORNER_RADIUS = 6 # pt — for outer rect BORDER_COLOR = HexColor('#1a3a5c') # deep navy blue (professional) INNER_COLOR = HexColor('#2e6da4') # lighter accent blue # ───────────────────────────────────────────────────────────────────── def make_border_pdf(w, h): """Return bytes of a single-page PDF containing only the border.""" buf = io.BytesIO() c = canvas.Canvas(buf, pagesize=(w, h)) # outer thick rounded rectangle c.setStrokeColor(BORDER_COLOR) c.setLineWidth(OUTER_WIDTH) m = OUTER_MARGIN c.roundRect(m, m, w - 2*m, h - 2*m, CORNER_RADIUS, stroke=1, fill=0) # inner thin straight rectangle c.setStrokeColor(INNER_COLOR) c.setLineWidth(INNER_WIDTH) m2 = INNER_MARGIN c.rect(m2, m2, w - 2*m2, h - 2*m2, stroke=1, fill=0) # decorative corner accents (small L-shapes in each corner) c.setStrokeColor(BORDER_COLOR) c.setLineWidth(1.5) accent = 14 # length of each arm pad = OUTER_MARGIN + 4 for (cx, cy, dx, dy) in [ (pad, pad, 1, 1), # bottom-left (w-pad, pad, -1, 1), # bottom-right (pad, h-pad, 1, -1), # top-left (w-pad, h-pad, -1, -1), # top-right ]: c.line(cx, cy, cx + dx*accent, cy) # horizontal arm c.line(cx, cy, cx, cy + dy*accent) # vertical arm c.save() buf.seek(0) return buf.read() for page in reader.pages: w = float(page.mediabox.width) h = float(page.mediabox.height) border_bytes = make_border_pdf(w, h) border_page = PdfReader(io.BytesIO(border_bytes)).pages[0] # merge: original content on top of border so content stays crisp border_page.merge_page(page) writer.add_page(border_page) with open(OUTPUT, 'wb') as f: writer.write(f) print(f'Done! Saved to {OUTPUT}') import os print(f'File size: {os.path.getsize(OUTPUT)/1024:.1f} KB') EOF

Done! Here is your bordered PDF:

DOC 20260714 WA0045 bordered

PDF Document · PDF

Here's what was added to all 21 pages:
  • Outer border - thick (2.5 pt) deep navy blue rounded rectangle, ~6 mm from the page edge
  • Inner border - thin (0.8 pt) lighter accent blue straight rectangle, ~9 mm from the page edge
  • Corner accents - small L-shaped decorative marks in each corner for a polished, professional look
  • All original content is completely unchanged - the borders are layered underneath the text/content so nothing is obscured
This is a shared conversation. Sign in to Orris to start your own chat.