<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">By the way, the Ruby wrapper to do it is called <a href="https://github.com/mileszs/wicked_pdf" class="">Wicked PDF</a>. Using it in favour of Prawn not only eases the testing, but eases the development itself because all you do is develop a webpage and then let Wicked PDF convert it to a PDF.<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 1 Aug 2017, at 23:52, Wilson Silva <<a href="mailto:wilson.dsigns@gmail.com" class="">wilson.dsigns@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">If you’re in the early stages of development, you can also ditch Prawn in favour of wkhtmltopdf, then test the webpage before converting it to PDF! You get all the testing niceties such as Capybara.<div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 1 Aug 2017, at 23:38, Sam Livingston-Gray <<a href="mailto:geeksam@gmail.com" class="">geeksam@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Well, as long as we're suggesting tools that might not actually be helpful, check out the appropriately-named Quixote[1], which lets you do JS-based testing of CSS rendering.  :D<div class=""><br class=""></div><div class="">[1] <a href="https://github.com/jamesshore/quixote" class="">https://github.com/jamesshore/quixote</a></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Aug 1, 2017 at 3:31 PM, Roland Swingler <span dir="ltr" class=""><<a href="mailto:roland.swingler@gmail.com" target="_blank" class="">roland.swingler@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Don't know if any of the tools already mentioned do something like this internally, but if not you could investigate perceptual hashing - think phash is a well known standard <a href="http://www.phash.org/" target="_blank" class="">http://www.phash.org/</a><div class=""><br class=""></div><div class="">Something like this probably isn't really the right fit, because phashes are designed to be robust against transformations such as rotation etc. which you probably care about in this context; also it would probably be a lot of work to get implemented in a ruby test suite.<br class=""></div><div class=""><br class=""></div><div class="">However, throwing it out there because you may find it an interesting approach/something to google more about - even if for its own sake and it turns out to be useless for your problem.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">R</div><div class=""><br class=""></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:39 PM, Josh McMillan <span dir="ltr" class=""><<a href="mailto:josh@joshmcmillan.co.uk" target="_blank" class="">josh@joshmcmillan.co.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra">I'm currently writing a bunch of smoke tests that involve checking the validity of machine generated PDFs. We use a multi-layer approach depending on how fast we want the suite to run:</div><div class="gmail_extra"><ul class=""><li class="">Basic tests for the content in the document – checking the right text boxes etc are rendered in the right place. This is done with Prawn's pdf-inspector package: <a href="https://github.com/prawnpdf/pdf-inspector" target="_blank" class="">https://github.com/pr<wbr class="">awnpdf/pdf-inspector</a></li><li class="">Pixel-by-pixel comparison tests using ImageMagick (the `convert` tool can handle PDFs as if it they were images) with a level of tolerance: <a href="https://www.imagemagick.org/script/compare.php" target="_blank" class="">https://www.imagema<wbr class="">gick.org/script/compare.php</a></li></ul><div class="">In the event that there's a major difference between two PDFs as flagged by ImageMagick, we output a load of visual diffs (which can be done via `compare -verbose -metric RMSE -highlight-color <actual> <expected> <diff>`, see the above link) for validation by a human.</div><div class=""><br class=""></div><div class="">The validity of these PDFs is "mission critical" though (they get printed and sent to customers as a physical product that they've paid money for) so this is probably overkill for most scenarios.</div></div><div class=""><div class="m_388395995987173775h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:29 PM, Mark Burns <span dir="ltr" class=""><<a href="mailto:markthedeveloper@gmail.com" target="_blank" class="">markthedeveloper@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class="">Yeah that's the kind of thing I was thinking.<div class=""><br class=""></div><div class="">I guess I may have been a bit too hopeful. No magical silver bullet shortcuts. </div><div class=""><br class="">Just about getting as close as possible to automating the actual eyeballing of the doc.<br class=""><br class="">diff-pdf sounded promising then:<br class=""><br class="">```<br class=""><div class="">$ diff-pdf book-1.pdf book-2.pdf<br class="">$ diff-pdf book-1.pdf book-2.pdf --verbose</div><div class="">page 1 differs</div><div class="">page 4 differs<br class="">```<br class=""><br class="">Much better than nothing though :)</div></div></div><div class="m_388395995987173775m_7067664014687819567gmail-HOEnZb"><div class="m_388395995987173775m_7067664014687819567gmail-h5"><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, Aug 1, 2017 at 8:21 PM Gerhard Lazu <<a href="mailto:gerhard@lazu.co.uk" target="_blank" class="">gerhard@lazu.co.uk</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div style="font-size: small;" class=""><span style="font-family:arial,helvetica,sans-serif" class="">A visual diff sounds most reasonable. Never used it myself, but <a href="https://github.com/vslavik/diff-pdf" target="_blank" class="">https://github.com/vslavik/dif<wbr class="">f-pdf</a> is worth a try. And guess what? </span><font face="monospace, monospace" style="background-color:rgb(255,242,204)" class="">brew install diff-pdf</font></div><div class="gmail_extra"><br class=""><div class="gmail_quote"></div></div></div><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:00 PM, Mark Burns <span dir="ltr" class=""><<a href="mailto:markthedeveloper@gmail.com" target="_blank" class="">markthedeveloper@gmail.com</a>></span> wrote:<br class=""></div></div></div><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class="">Has anyone any recommendations or suggestions for testing PDF generation?<div class=""><br class=""></div><div class="">I'm working on a side project and using Prawn. Which is great. I can programmatically generate large aspects of the content I want.</div><div class=""><br class=""></div><div class="">But so far I've been tweaking then looking at the result in the browser.</div><div class="">It's not an absolute nightmare - a few seconds to render. But it's hard to know whether the result is working without actually looking at it.</div><div class=""><br class=""></div><div class="">The DSL is nice, but very imperative. Mocking method calls out would be insane.</div><div class=""><br class=""></div><div class="">I'm managing to refactor into small objects to represent the components and layout, pages, typography aspects etc of the document. Which brings the complexity back down to manageable chunks. <br class=""><br class="">But ultimately everything just calls underlying prawn DSL methods. So I can test little bits of logic that I have in my objects, but ultimately whether it works or not comes down to "have a look and see".</div><div class=""><br class=""></div><div class="">Perhaps the best I can hope for is screenshotting when I'm happy and using approvals to verify each major change hasn't radically borked everything.</div><div class=""><br class=""></div><div class="">It seems like there are tools to test which strings get into the document, but that seems like the easiest part. And probably the only part I'd be happy with test doubles for prawn and setting expectations on the text generating methods.</div></div>
<br class=""></blockquote></div></div></div><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">______________________________<wbr class="">_________________<br class="">
Chat mailing list<br class="">
<a href="mailto:Chat@lists.lrug.org" target="_blank" class="">Chat@lists.lrug.org</a><br class="">
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/pipermai<wbr class="">l/chat-lrug.org</a><br class="">
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/options.<wbr class="">cgi/chat-lrug.org</a><br class="">
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/listinfo<wbr class="">.cgi/chat-lrug.org</a><br class="">
<br class=""></blockquote></div></div></div>
______________________________<wbr class="">_________________<br class="">
Chat mailing list<br class="">
<a href="mailto:Chat@lists.lrug.org" target="_blank" class="">Chat@lists.lrug.org</a><br class="">
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/pipermai<wbr class="">l/chat-lrug.org</a><br class="">
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/options.<wbr class="">cgi/chat-lrug.org</a><br class="">
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/listinfo<wbr class="">.cgi/chat-lrug.org</a><br class="">
</blockquote></div>
</div></div><br class="">______________________________<wbr class="">_________________<br class="">
Chat mailing list<br class="">
<a href="mailto:Chat@lists.lrug.org" target="_blank" class="">Chat@lists.lrug.org</a><br class="">
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/pipermai<wbr class="">l/chat-lrug.org</a><br class="">
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/options.<wbr class="">cgi/chat-lrug.org</a><br class="">
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/listinfo<wbr class="">.cgi/chat-lrug.org</a><br class="">
<br class=""></blockquote></div><br class=""></div></div></div></div>
<br class="">______________________________<wbr class="">_________________<br class="">
Chat mailing list<br class="">
<a href="mailto:Chat@lists.lrug.org" target="_blank" class="">Chat@lists.lrug.org</a><br class="">
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/pipermai<wbr class="">l/chat-lrug.org</a><br class="">
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/options.<wbr class="">cgi/chat-lrug.org</a><br class="">
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/listinfo<wbr class="">.cgi/chat-lrug.org</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></div><br class="">______________________________<wbr class="">_________________<br class="">
Chat mailing list<br class="">
<a href="mailto:Chat@lists.lrug.org" class="">Chat@lists.lrug.org</a><br class="">
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/<wbr class="">pipermail/chat-lrug.org</a><br class="">
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/options.<wbr class="">cgi/chat-lrug.org</a><br class="">
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank" class="">http://lists.lrug.org/<wbr class="">listinfo.cgi/chat-lrug.org</a><br class="">
<br class=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">Chat mailing list<br class=""><a href="mailto:Chat@lists.lrug.org" class="">Chat@lists.lrug.org</a><br class="">Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" class="">http://lists.lrug.org/pipermail/chat-lrug.org</a><br class="">Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" class="">http://lists.lrug.org/options.cgi/chat-lrug.org</a><br class="">List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" class="">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>