<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Test Page for Printer</title>
    <description>The latest articles on DEV Community by Test Page for Printer (@printertestpage).</description>
    <link>https://dev.to/printertestpage</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4160513%2Fac9f77e1-dfb0-4b52-86da-8def89a29ec4.webp</url>
      <title>DEV Community: Test Page for Printer</title>
      <link>https://dev.to/printertestpage</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/printertestpage"/>
    <language>en</language>
    <item>
      <title>One layout file, three outputs: building printer test pages as real CMYK PDFs with Astro</title>
      <dc:creator>Test Page for Printer</dc:creator>
      <pubDate>Sun, 04 Oct 2026 21:56:21 +0000</pubDate>
      <link>https://dev.to/printertestpage/one-layout-file-three-outputs-building-printer-test-pages-as-real-cmyk-pdfs-with-astro-243d</link>
      <guid>https://dev.to/printertestpage/one-layout-file-three-outputs-building-printer-test-pages-as-real-cmyk-pdfs-with-astro-243d</guid>
      <description>&lt;p&gt;I built &lt;a href="https://testpageforprinter.com" rel="noopener noreferrer"&gt;testpageforprinter.com&lt;/a&gt;, a free set of printer test sheets (color, black and white, CMYK, alignment, nozzle check, scale, photo, duplex). Most "printer test page" sites hand you one generic image. I wanted sheets that really are what they claim to be: vector, in the right color space, at the right size. This post covers the part I found most interesting to build.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with "just print this image"
&lt;/h2&gt;

&lt;p&gt;A test page that goes through a browser print dialog can quietly be wrong in three ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the page is scaled ("Fit to page"), so an alignment test lies to you;&lt;/li&gt;
&lt;li&gt;colors are converted to RGB, so a "CMYK" test is not testing the cyan, magenta, yellow and black channels separately;&lt;/li&gt;
&lt;li&gt;Letter and A4 are different sizes, and a file made for one gets shrunk onto the other. An A4 sheet on Letter paper prints at about 94%, and a Letter sheet on A4 at about 97%.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One geometry, three renderers
&lt;/h2&gt;

&lt;p&gt;Each sheet is described once, in millimetres, in a single file (&lt;code&gt;layouts.mjs&lt;/code&gt;). Three small renderers consume that description:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;pdf.mjs&lt;/code&gt;&lt;/strong&gt; writes a real PDF with &lt;code&gt;pdf-lib&lt;/code&gt;. Fills and strokes use DeviceCMYK operators, and the font is embedded (the standard-14 Helvetica is not embedded, so I bundle Inter at build time).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;svg.mjs&lt;/code&gt;&lt;/strong&gt; produces the SVG used for the in-browser print layout, with a static &lt;code&gt;@page&lt;/code&gt; size and &lt;code&gt;print-color-adjust: exact&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The same SVG path, rasterized from the real PDF with Poppler, gives the preview images on the pages.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Because the previews are rendered from the real PDFs, what you see on screen is what prints. Every element sets an explicit color, so a CMYK sheet never contains a stray RGB operator. A build step verifies all 20 PDFs (Letter and A4 for each sheet).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// layouts.mjs, simplified: one description, coordinates in mm&lt;/span&gt;
&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;qr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MG&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;site&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/result/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MG&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fy&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;14.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Print at 100% (Actual size). Turn “Fit to page” off.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The scale check is just arithmetic, so it is testable
&lt;/h2&gt;

&lt;p&gt;Print the scale sheet, measure its 100 mm bar, type the length in. The diagnosis is a pure function with no DOM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;A4_ON_LETTER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;279.4&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;297&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 94.07&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;LETTER_ON_A4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;210&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;215.9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 97.27&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the measured scale is within a small tolerance of one of those two numbers, the tool says the paper sizes are mismatched; otherwise it points at "Fit to page" or a custom scale. Pure functions meant I could unit test it with the Node test runner and no browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  QR codes on the sheet read the result
&lt;/h2&gt;

&lt;p&gt;Every sheet carries a QR code that opens a "read your result" page with permalink hashes, so someone can scan the printout and walk through what they see. Only hashes that match a known option are applied, and nothing user-supplied is injected into the HTML.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is not finished (honestly)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A camera-based nozzle check exists but is tuned only on synthetic photos, because I have not collected real phone photos of real printouts yet. It is labelled beta.&lt;/li&gt;
&lt;li&gt;The defect photos on the site are AI-generated placeholders and are tagged "Illustration" until I replace them with real ones.&lt;/li&gt;
&lt;li&gt;I have not tested printing on a range of real printers; the site says so.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Stack
&lt;/h2&gt;

&lt;p&gt;Astro (static output), Tailwind, &lt;code&gt;pdf-lib&lt;/code&gt;, &lt;code&gt;qrcode&lt;/code&gt;, Playwright for QA screenshots, and Node's built-in test runner. Lighthouse on a local preview scored 94 to 99 for performance and 100 for accessibility and SEO on the pages I measured; real-host numbers still need re-measuring.&lt;/p&gt;

&lt;p&gt;If you print test pages for a living, or have a printer that misbehaves in interesting ways, I would like to hear what the sheets miss: &lt;a href="https://testpageforprinter.com" rel="noopener noreferrer"&gt;testpageforprinter.com&lt;/a&gt;. I built it, so this is my own project.&lt;/p&gt;

</description>
      <category>astro</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
