Project

General

Profile

Actions

Bug #145

open
AS AS

Fix the NSDL BOE print PDF being cropped on the right

Bug #145: Fix the NSDL BOE print PDF being cropped on the right

Added by Akshath Shettigara 7 days ago.

Status:
New
Priority:
Normal
Target version:
Start date:
10/15/2026
Due date:
% Done:

0%

Estimated time:

Description

Fix the NSDL BOE print PDF being cropped on the right

The PDF that Phase B attaches to each record now shows the whole NSDL print form, on A4 landscape, scaled to fit.

1. Summary

The PDF attached to FTWZ DTA Sale and FTWZ BOE Import documents was cut off on the right. NSDL's print view is a wide form, and it was printed at 100% on a US Letter portrait page, so everything past the page edge was lost (from about column 12, including the right-hand duty and declaration block). Manually saved copies on the Frappe sites were cut off the same way. The print step now uses A4 landscape, measures the real width of the print page and scales it down when needed. Verified on live runs for DTA and BE. Real customer PDFs are not attached to this story.

2. Requirement

# Requirement Source Status
R1 The attached PDF must show the whole form user (2026-10-13) Done
R2 Match a PDF printed by hand from the same page (reference file supplied by the user) user Done, with small differences (section 7)
R3 Works for BE and DTA without separate code user (2026-10-14) Done

3. Decisions

Decision Options considered Why this one Date
Page format US Letter portrait scaled to about 0.6; A4 landscape The user's reference is A4 landscape with the whole form and even margins; landscape gives larger text 2026-10-13
Scaling Fixed scale; measure the page and scale only if wider than the printable width The form width can differ; content is measured at run time 2026-10-13
Safety margin None; 1% A rounding difference must not push the last column off the page 2026-10-13
Re-attach older PDFs Back-fill; leave Phase B does not re-attach; the user did not ask for a back-fill. Not confirmed 2026-10-13

4. Logic & Workflow

open print page -> measure rightmost edge (document and every element) -> compute scale -> print A4 landscape with 0.35 in margins -> log width and scale -> attach

Item Value
Page A4 landscape, 11.69 in wide
Margins 0.35 in each side
Printable width about 1055 px at 96 px per inch
Scale 1.0 if the content fits, otherwise printable width / content width, times 0.99, never below 0.1
Unknown width Prints at 100% as before

5. Files & Components Changed

File / resource Type Change Purpose
app/phase_b_deliver/pdf_fetch.py Code A4 landscape, fit_scale(), width measurement, log line per PDF Fix the crop
app/phase_b_deliver/lambda_handler.py Code Passes the logger to fetch_boe_pdf (one line) Width and scale are logged per PDF

6. Configuration & Deployment

No new settings; the values are constants in pdf_fetch.py. Deployed through the pipeline after the merge on 2026-10-13. Each PDF logs a line with the measured width and the scale.

7. Testing

Test Data / Site Expected Actual Status
fit_scale for widths up to 6,000 px Local Content always fits Always fits; 1280 px gives 0.816, 1600 px gives 0.653 Pass
Ruff, compile, earlier test suites Repo Pass Pass Pass
Live DTA PDF (wud, 2026-10-13) Real NSDL, TEST site Whole form, A4 landscape 1298 px measured, scale 0.805, whole form visible; page 1 has 729 words against 733 in the reference (the four missing words are the browser's own header and footer) Pass
Layout differences from the reference Same Match 2 pages against 4 (the reference includes the annexure and browser header and footer); left margin 76 px against right 49 px, reference 34 px each; later pages' content not compared Cosmetic differences
Live BE PDF (eap, 2026-10-14) Real NSDL, TEST site Whole form Same 1298 px and scale 0.805; all 16 columns and the declaration block on page 1 Pass

8. Known Limitations & Open Items

  • PDFs attached before this fix (6 on wud, some on eap) stay cropped because Phase B never re-attaches.
  • The form is centred slightly left (cosmetic).
  • Content of pages after the first was not compared with the reference.
  • The Letter-portrait approach was tried first and discarded before commit; it never ran live.

9. Status

Item Value
Branch feature/AI-TBD-nsdl-otp-login
Commits 92fc290
PR Created and merged by the user; number not confirmed
Deployed to TEST stack

10. References

Related stories: nsdl-pdf-attachment-be-dta (the PDF attach flow), nsdl-data-parity-dta-be.


Pushed to Redmine on 15 Oct 2026, 16:35 from nsdl-boe-pdf-print-layout_20261015-1616_20261015-163531.md (README created 15 Oct 2026, 16:35).


Files

README.md (4.75 KB) README.md README: Fix the NSDL BOE print PDF being cropped on the right Akshath Shettigara, 10/15/2026 04:35 PM

No data to display

Actions

Also available in: PDF Atom