<?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: David Garay</title>
    <description>The latest articles on DEV Community by David Garay (@garaekz).</description>
    <link>https://dev.to/garaekz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3938955%2Fdbc856d2-1da4-42c8-a346-9dafa366c45b.jpeg</url>
      <title>DEV Community: David Garay</title>
      <link>https://dev.to/garaekz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/garaekz"/>
    <language>en</language>
    <item>
      <title>I built a Laravel PDF package because I was tired of debugging screenshots from ghosts</title>
      <dc:creator>David Garay</dc:creator>
      <pubDate>Mon, 18 May 2026 21:32:07 +0000</pubDate>
      <link>https://dev.to/garaekz/i-built-a-laravel-pdf-package-because-i-was-tired-of-debugging-screenshots-from-ghosts-2872</link>
      <guid>https://dev.to/garaekz/i-built-a-laravel-pdf-package-because-i-was-tired-of-debugging-screenshots-from-ghosts-2872</guid>
      <description>&lt;p&gt;Every HTML-to-PDF system eventually hits the same wall.&lt;/p&gt;

&lt;p&gt;Chrome captures too early.&lt;/p&gt;

&lt;p&gt;Not because Chrome is broken.&lt;br&gt;
Not because the PDF library is bad.&lt;/p&gt;

&lt;p&gt;Because the renderer is guessing.&lt;/p&gt;

&lt;p&gt;Sometimes the chart is still animating.&lt;br&gt;
Sometimes the font has not swapped in yet.&lt;br&gt;
Sometimes async data arrived 200ms later on a slow queue worker.&lt;/p&gt;

&lt;p&gt;And eventually somebody reports:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“The invoice from 3 days ago looked wrong.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now you are debugging a render that already shipped.&lt;/p&gt;

&lt;p&gt;No logs.&lt;br&gt;
No screenshot.&lt;br&gt;
No DOM state.&lt;br&gt;
No idea what Chrome actually saw.&lt;/p&gt;

&lt;p&gt;I have fought this problem for years across different stacks and projects.&lt;/p&gt;

&lt;p&gt;The usual fixes always looked like this:&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="nx"&gt;waitUntilNetworkIdle&lt;/span&gt;
&lt;span class="nf"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// cross fingers &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works.&lt;br&gt;
Until it does not.&lt;/p&gt;

&lt;p&gt;The core problem is simple:&lt;/p&gt;

&lt;p&gt;The renderer does not actually know when your application is ready.&lt;/p&gt;

&lt;p&gt;Only your application knows that.&lt;/p&gt;

&lt;p&gt;So I built Canio.&lt;/p&gt;
&lt;h2&gt;
  
  
  The readiness contract
&lt;/h2&gt;

&lt;p&gt;Instead of relying on timing heuristics, the page explicitly signals readiness:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__CANIO_READY__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That signal can happen after:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fonts are loaded&lt;/li&gt;
&lt;li&gt;charts finish animating&lt;/li&gt;
&lt;li&gt;async requests complete&lt;/li&gt;
&lt;li&gt;Vue hydration finishes&lt;/li&gt;
&lt;li&gt;whatever “done” means for your document&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The renderer stops guessing.&lt;/p&gt;

&lt;p&gt;Your application decides when capture happens.&lt;/p&gt;

&lt;p&gt;That single inversion changes the entire rendering model.&lt;/p&gt;

&lt;h2&gt;
  
  
  The real feature is not readiness
&lt;/h2&gt;

&lt;p&gt;The part I actually care about is this:&lt;/p&gt;

&lt;p&gt;Every render can leave evidence.&lt;/p&gt;

&lt;p&gt;Canio can persist:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML source&lt;/li&gt;
&lt;li&gt;DOM snapshot&lt;/li&gt;
&lt;li&gt;screenshot at capture time&lt;/li&gt;
&lt;li&gt;console logs&lt;/li&gt;
&lt;li&gt;network logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So when someone says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“This PDF looked broken last Tuesday.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You do not try to reproduce the race condition.&lt;/p&gt;

&lt;p&gt;You open the artifact screenshot and see exactly what Chromium saw.&lt;/p&gt;

&lt;p&gt;That changes PDF debugging from archaeology into inspection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters
&lt;/h2&gt;

&lt;p&gt;Most HTML-to-PDF tooling treats rendering as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML in
PDF out 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But rendering is not instantaneous.&lt;/p&gt;

&lt;p&gt;Modern pages are temporal systems.&lt;/p&gt;

&lt;p&gt;Fonts load later.&lt;br&gt;
Animations complete later.&lt;br&gt;
Hydration finishes later.&lt;br&gt;
Data arrives later.&lt;/p&gt;

&lt;p&gt;The renderer is sampling a moving target.&lt;/p&gt;

&lt;p&gt;Canio treats rendering as a synchronization problem instead of a timeout problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Under the hood
&lt;/h2&gt;

&lt;p&gt;Canio uses a Go runtime called Stagehand.&lt;/p&gt;

&lt;p&gt;Stagehand talks directly to real Chromium over CDP.&lt;/p&gt;

&lt;p&gt;Why Go instead of Node?&lt;/p&gt;

&lt;p&gt;Mostly deployment ergonomics.&lt;/p&gt;

&lt;p&gt;I wanted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a single static binary&lt;/li&gt;
&lt;li&gt;predictable memory usage&lt;/li&gt;
&lt;li&gt;no node_modules in production&lt;/li&gt;
&lt;li&gt;isolated render infrastructure&lt;/li&gt;
&lt;li&gt;simpler containerization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Canio supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;embedded runtime&lt;/li&gt;
&lt;li&gt;remote CDP runtime&lt;/li&gt;
&lt;li&gt;existing local Chrome&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also installs a pinned Chrome for Testing build automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browsershot is still excellent
&lt;/h2&gt;

&lt;p&gt;This is important to say clearly:&lt;/p&gt;

&lt;p&gt;Browsershot is excellent.&lt;/p&gt;

&lt;p&gt;I still use it.&lt;/p&gt;

&lt;p&gt;Canio is not trying to replace Browsershot for simple rendering.&lt;/p&gt;

&lt;p&gt;Canio exists for the cases where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rendering timing matters&lt;/li&gt;
&lt;li&gt;deterministic capture matters&lt;/li&gt;
&lt;li&gt;production debugging matters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is the lane.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require oxhq/canio
php artisan canio:install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repo:&lt;br&gt;
&lt;a href="https://github.com/oxhq/canio" rel="noopener noreferrer"&gt;https://github.com/oxhq/canio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feedback and criticism are genuinely welcome.&lt;br&gt;
Especially from people who have fought HTML-to-PDF rendering in production.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>opensource</category>
      <category>php</category>
      <category>go</category>
    </item>
  </channel>
</rss>
