feat: print files over 5,08 m are written at their real size
All checks were successful
Build and deploy / Validate source (push) Successful in 13s
Build and deploy / Integration suite on a real stack (push) Successful in 4m36s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m12s

PDF's /UserUnit scale kept long sheets within Acrobat's page limit, but
CorelDRAW, where Dropstar checks the files, ignores it and showed a 12,8 m
sheet at a third of its size. Long sheets now stay one page at real size;
PRINT_PAGE_SCALE=true in the stack goes back to the scale, for a RIP that
refuses pages over the limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-28 12:42:27 -03:00
parent ac22f9a2f6
commit 8257ac24ab
4 changed files with 34 additions and 10 deletions

View File

@@ -29,9 +29,20 @@ from PIL import Image, ImageOps
from .core.models import PRODUCTION_VERSIONS
PT_PER_CM = 72 / 2.54
# Acrobat's page limit. Longer layouts scale user space with /UserUnit (PDF 1.6)
# rather than cutting the film into pages a RIP might print with gaps.
# Acrobat's page limit, 200 inches (5,08 m). A longer sheet is written at its
# real size, on one page: CorelDRAW, where Dropstar checks the files, ignores
# /UserUnit and showed a 12,8 m sheet at a third of its size (2026-10-28).
# PRINT_PAGE_SCALE=true goes back to scaling user space with /UserUnit (PDF
# 1.6), for software that refuses pages over the limit. Either way the film is
# never cut into pages a RIP might print with gaps.
MAX_PAGE_PT = 14400
def page_unit(width_pt, height_pt):
"""The page's /UserUnit: 1 (real size) unless PRINT_PAGE_SCALE is on."""
if os.environ.get('PRINT_PAGE_SCALE', 'false').strip().lower() != 'true':
return 1
return max(1, math.ceil(max(width_pt, height_pt) / MAX_PAGE_PT))
# How far a file's proportions may drift from the quoted size before the item
# is refused: rounding in the Site keeps real files well inside this.
ASPECT_TOLERANCE = 0.01
@@ -488,7 +499,7 @@ def render(item, files, out, title, footer=None):
width_pt = float(production['film_width_cm']) * PT_PER_CM
page_cm = Decimal(str(production['height_cm'])) + (FOOTER_CM if footer else 0)
height_pt = float(page_cm) * PT_PER_CM
unit = max(1, math.ceil(max(width_pt, height_pt) / MAX_PAGE_PT))
unit = page_unit(width_pt, height_pt)
first = tempfile.TemporaryFile() if vector else out
try:

View File

@@ -75,6 +75,10 @@ x-app-environment: &app-environment
# (CDR, AI, PSD, TIFF, or a length the customer typed). Dropstar set R$ 2,00
# a metro on 2026-10-23; 0 adds nothing. The Site shows it before payment.
MANUAL_FILE_EXTRA_CENTS: ${MANUAL_FILE_EXTRA_CENTS:-200}
# Print files longer than 5,08 m are written at their real size, which Corel
# reads (2026-10-28). true goes back to PDF's /UserUnit scale, for a RIP that
# refuses pages over 5,08 m.
PRINT_PAGE_SCALE: ${PRINT_PAGE_SCALE:-false}
# Order creation in Tiny stays off until it has been tested against the
# client's account (Tiny has no sandbox). The application credentials can be
# set now: they let an operator connect Tiny from the Kanban, and the worker

View File

@@ -406,9 +406,10 @@ in a 1,5 cm footer band below the layout, outside the billed length: "DROPSTAR
· Pedido DTF-<Kanban number> · Item 1/2 · date · billed metres" in black
Helvetica, after Dropstar's logo (app/assets), about 1 cm tall (31 pt, Dropstar
2026-10-28; smaller only when it would not fit the 27 cm UV film). A sheet
longer than 5,08 m (PDF's page limit) is scaled with /UserUnit; CorelDRAW
ignores it and shows such a file at 1/UserUnit of its size (a 12,8 m sheet as
18,9 x 425 cm), while the page itself is right. An original used whole as its
longer than 5,08 m (Acrobat's page limit) is written at its real size on one
page since 2026-10-28: with PDF's /UserUnit scale, CorelDRAW, where Dropstar
checks files, showed a 12,8 m sheet as 18,9 x 425 cm. PRINT_PAGE_SCALE=true
in the stack goes back to /UserUnit, for a RIP that refuses pages over 5,08 m. An original used whole as its
own print file (over 300 MB) has no footer. The print proof (app/proof.py):
an order above 10 m, or one whose customer ticked "quero aprovar uma prova" at
checkout (that one arrives marked Aguardando contato), cannot reach Finalizado

View File

@@ -189,11 +189,19 @@ class PrintFileTests(unittest.TestCase):
with self.assertRaisesRegex(Unsupported, 'não é uma imagem'):
self.render(item([placement(0, 0, 20, 10)], [source(20, 10)], 10), [cdr])
def test_long_layouts_scale_user_space_instead_of_splitting(self):
# 6 m is longer than a PDF page may be (about 5.08 m).
def test_long_layouts_stay_one_page_at_real_size(self):
# 6 m is longer than Acrobat's page limit (5,08 m). Corel ignores
# /UserUnit, so the page is written at its real size (2026-10-28).
path = self.save(quadrants(40, 800), 'a.png')
pdf, detail = self.render(item([placement(0, 0, 30, 600)], [source(30, 600)], 600,
billed='6.0'), [path])
spec = item([placement(0, 0, 30, 600)], [source(30, 600)], 600, billed='6.0')
pdf, detail = self.render(spec, [path])
self.assertEqual(detail['user_unit'], 1)
self.assertNotIn(b'/UserUnit', pdf)
box = re.search(rb'/MediaBox \[ ?([\d. ]+)\]', pdf).group(1).split()
self.assertAlmostEqual(float(box[3]) / PT_PER_CM, 600, places=1)
# PRINT_PAGE_SCALE=true goes back to scaling user space instead.
with mock.patch.dict(os.environ, {'PRINT_PAGE_SCALE': 'true'}):
pdf, detail = self.render(spec, [path])
self.assertEqual(detail['user_unit'], 2)
self.assertIn(b'/UserUnit 2', pdf)