How to make your Epson XP-342 print documents with varying page size
Because apparently, the official Linux driver just segfaults when the page size changes midway through a PDF. Patch for 1.7.26 (the current version in Portage) can be downloaded here. It's written for 1.7.22, but there have been no relevant upstream changes since then. The original code is a horror show. Building it produces more compiler warnings than my terminal's scrollback can handle and the original main loop is this busted thing:
while (1) { readPageHeaderAndIgnoreTheDimensionInfo(); if (bEnd) { if (!bCacheEmpty) sendCachedData(); sendCurrentPage(); // wrong when the child isn't spawned yet break; } else if (bCacheFull) { sendCachedData(); cacheCurrentPage(); } if (bFirstIteration) initializeChildProcess(); actuallyReadThePage(); }
Note that the function calls in this sketch don't correspond to function calls
but code sections, which means the sendCachedData()
section is copypasted; I
basically had to rewrite this entire function for what should have been a two
line fix. Somebody got paid for this! The driver also ignores other parts of the
CUPS header; adding support for them is left to the masochistic reader.
Edit 2023-05-22: Updated from 1.7.22 to 1.7.26.
Edit 2023-01-31: Updated from 1.7.8 to 1.7.22. The only differences are the
addition of a completely pointless safe_free
function (free
is already a nop
on NULL
…) and a fix for the child issue mentioned above, which my patch
already fixes anyway.