taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit f07b294d6665e35731b1f115f78de1dbf3665b5a
parent b94c2026c4d92a750de391e2122ad87cbd0d5ee2
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 15 Dec 2025 21:46:41 +0100

fix inline PDF generation logic in the test

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-tops-aml-pdf.ts | 36++++++++++++++----------------------
1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-tops-aml-pdf.ts b/packages/taler-harness/src/integrationtests/test-tops-aml-pdf.ts @@ -31,14 +31,17 @@ interface FileField { MIME_TYPE: string; } + /** * Helper function to create a mock PDF file attachment. */ function createPdfAttachment(name: string): FileField { - // Escape parentheses for PDF literal strings - const contentEscaped = name.replace(/\(/g, "\\(").replace(/\)/g, "\\)"); + // Escape parentheses and backslashes for PDF literal strings + const contentEscaped = name.replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)"); + + const contentStream = `BT /F1 12 Tf 10 20 Td (${contentEscaped}) Tj ET`; - // Minimal PDF + // Minimal PDF with standard font const pdf = `%PDF-1.1 1 0 obj << /Type /Catalog /Pages 2 0 R>> @@ -48,38 +51,27 @@ endobj endobj 3 0 obj << /Type /Page /Parent 2 0 R /MediaBox[0 0 200 50] -/Resources<< /Font<< /F<< /Type/Font /Subtype/Type3 /FontBBox[0 0 0 0] -/FontMatrix[0.001 0 0 0.001 0 0] /CharProcs<< /H 4 0 R >> /Encoding<< /Type/Encoding/MissingWidth 1 /Differences[0/H] >> -/FirstChar 0 /LastChar 0 /Widths[1000] >> >> /Contents 5 0 R >> +/Resources<< /Font<< /F1<< /Type/Font /Subtype/Type1 /BaseFont/Helvetica >> >> >> +/Contents 4 0 R >> endobj 4 0 obj -<< /Length 8>> -stream -0 0 m -endstream -endobj -5 0 obj -<< /Length ${35 + contentEscaped.length - "Hello World".length}>> +<< /Length ${contentStream.length}>> stream -BT /F 12 Tf 10 20 Td (${contentEscaped}) Tj ET +${contentStream} endstream endobj xref -0 6 +0 5 0000000000 65535 f 0000000009 00000 n 0000000056 00000 n 0000000107 00000 n -0000000334 00000 n -0000000409 00000 n -trailer<< /Size 6 /Root 1 0 R>> +0000000251 00000 n +trailer<< /Size 5 /Root 1 0 R>> startxref -475 +${330 + contentStream.length} %%EOF`; - // FIXME: Dold: which encoding are we using? Base64 or Crockford? - // Also: this doesn't yet wrap in "FILE". "File" data type seems - // unspecified in tops.rst! return { CONTENTS: Buffer.from(pdf, "utf8").toString("base64"), ENCODING: "base64",