feat: the print PDF footer starts with Dropstar's logo
All checks were successful
Build and deploy / Validate source (push) Successful in 15s
Build and deploy / Integration suite on a real stack (push) Successful in 4m25s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Successful in 1m49s

Dropstar sent the logo on 2026-10-23: black on transparent, so the room's
white-base profile prints nothing around it. It is drawn 1,3 cm high at
the start of the footer band, in place of the brand's name, followed by
"Pedido DTF-123 · Item 1/2 · date · metres". Without the file, the footer
falls back to the name in bold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-23 14:15:23 -03:00
parent 56e5462647
commit c21497d71b
4 changed files with 34 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ import re
import tempfile
import unittest
import zlib
from unittest import mock
from PIL import Image
@@ -99,11 +100,20 @@ class PrintFileTests(unittest.TestCase):
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)
# Dropstar's logo first (black on transparent: a soft mask), then the line.
self.assertIn(b' cm /Logo Do Q', content)
self.assertIn(b'/Logo ', pdf)
self.assertIn(b'/SMask', pdf)
self.assertNotIn(b'(DROPSTAR) Tj', content)
self.assertIn(b'/F2 18 Tf', content)
self.assertIn('(Pedido DTF-7 · Item 1/2 · 21/10/2026 · 1,00 m) Tj'.encode('cp1252'), content)
self.assertNotIn(b' re f', content) # no filled background
self.assertIn(b'/BaseFont /Helvetica-Bold', pdf)
# Without the logo file, the brand's name in bold.
with mock.patch('app.printfile.FOOTER_LOGO', os.path.join(self.dir.name, 'none.png')):
bare = io.BytesIO()
render(spec, {0: (path, 'a.png')}, bare, 'test', footer=line)
self.assertIn(b'(DROPSTAR) Tj', self.content(bare.getvalue()))
self.assertIn(b'/BaseFont /Helvetica-Bold', bare.getvalue())
# 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)