feat: the print PDF ends in a footer naming the order, item, date and length
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 3m55s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Has been skipped
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 3m55s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Has been skipped
Dropstar's item 4 (2026-10-21): the PDF had no text at all, so a sheet cut off or dropped in the room was guesswork. A 1,5 cm band after the last piece, outside the billed length and never over artwork, carries one line in black with no background: DROPSTAR · Pedido DTF-123 · Item 1/2 · 21/10/2026 · 0,90 m The order is named by its Kanban number, the purchase order Tiny keeps, since Tiny's own number may not exist yet when the PDF is made. The brand is text until Dropstar sends the logo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -87,8 +87,10 @@ def run():
|
||||
pdf = response.read()
|
||||
assert pdf.startswith(b'%PDF-') and pdf.rstrip().endswith(b'%%EOF')
|
||||
width, height = map(float, re.search(rb'/MediaBox \[0 0 ([\d.]+) ([\d.]+)\]', pdf).groups())
|
||||
assert abs(width - 57 * PT_PER_CM) < 0.01 and abs(height - 10 * PT_PER_CM) < 0.01, (width, height)
|
||||
print('PASS: paid order generated a 57 x 10 cm print file with both copies')
|
||||
# The layout's 10 cm and the 1,5 cm footer band, outside the billed length.
|
||||
assert abs(width - 57 * PT_PER_CM) < 0.01 and abs(height - 11.5 * PT_PER_CM) < 0.01, (width, height)
|
||||
assert row['detail']['footer'].startswith('DROPSTAR · Pedido DTF-%d · Item 1/1 · ' % order['number']), row['detail']
|
||||
print('PASS: paid order generated a 57 x 10 cm print file with both copies and its footer')
|
||||
|
||||
# The automatic folder, downloading on arrival, gets the generated file
|
||||
# before anyone approves it; at the queue only, it does not.
|
||||
|
||||
@@ -87,6 +87,30 @@ class PrintFileTests(unittest.TestCase):
|
||||
streams = re.findall(rb'/Filter /FlateDecode/Length \d+ 0 R>>\nstream\n(.*?)\nendstream', pdf, re.S)
|
||||
return zlib.decompress(streams[-1])
|
||||
|
||||
def test_footer_band_is_added_below_the_layout(self):
|
||||
# Dropstar, 2026-10-21: 1,5 cm after the last piece, black text, no fill.
|
||||
path = self.save(quadrants(), 'a.png')
|
||||
spec = item([placement(0, 0, 20, 10)], [source(20, 10)], 10)
|
||||
out = io.BytesIO()
|
||||
line = 'DROPSTAR · Pedido DTF-7 · Item 1/2 · 21/10/2026 · 1,00 m'
|
||||
detail = render(spec, {0: (path, 'a.png')}, out, 'test', footer=line)
|
||||
pdf = out.getvalue()
|
||||
height = float(re.search(rb'/MediaBox \[0 0 [\d.]+ ([\d.]+)\]', pdf).group(1))
|
||||
self.assertAlmostEqual(height, 11.5 * PT_PER_CM, places=2)
|
||||
self.assertEqual((detail['height_cm'], detail['page_height_cm'], detail['footer']), ('10', '11.5', line))
|
||||
content = self.content(pdf)
|
||||
self.assertIn(b'/F1 18 Tf', content)
|
||||
self.assertIn(b'(DROPSTAR) Tj', content)
|
||||
self.assertIn(' · Pedido DTF-7 · Item 1/2 · 21/10/2026 · 1,00 m'.encode('cp1252'), content)
|
||||
self.assertNotIn(b' re f', content) # no filled background
|
||||
self.assertIn(b'/BaseFont /Helvetica-Bold', pdf)
|
||||
# The artwork keeps its place from the top: the band is below it.
|
||||
matrix = re.search(rb'q ([\d. -]+) cm /Im0 Do Q', content).group(1).split()
|
||||
self.assertAlmostEqual(float(matrix[5]), 1.5 * PT_PER_CM, places=2)
|
||||
# Without a footer, the page is the layout.
|
||||
plain = io.BytesIO()
|
||||
self.assertEqual(render(spec, {0: (path, 'a.png')}, plain, 'test')['page_height_cm'], '10')
|
||||
|
||||
def test_jpeg_bytes_are_embedded_unchanged(self):
|
||||
path = self.save(quadrants(), 'a.jpg', quality=90)
|
||||
pdf, _ = self.render(item([placement(0, 0, 20, 10)], [source(20, 10)], 10), [path])
|
||||
|
||||
Reference in New Issue
Block a user