Comment 1 for bug 1824391

Revision history for this message
Bill Erickson (berick) wrote :

Two working branches:

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1824391-hatch-write-to-file

https://git.evergreen-ils.org/?p=working/Hatch.git;a=shortlog;h=refs/heads/user/berick/lp1824391-print-to-file-with-jdk11

This code is somewhat different than what I was planning, but it gets the job done, similar to how the XUL client handled it.

---

After much research, I was not able to find a way to force a print job to print to a file via the javafx print API (which is required for html rendering). Other Java print APIs support it, but it looks like those components are not exposed in the javafx print package.

So instead of treating this like "Print to File", where the expectation is a print job of any type will be written to a file a la "print to file" in a printer dialog, the new feature is more like "write text to file", with an option to use a stock "Hatch File Writer" printer from the Hatch print configuration.

The key difference is only text content can be printed. For backwards compatibility with the XUL client, which supports translating HTML content to text, I have ported the XUL JS functions over to do that. With this, simple spine labels, etc. can be translated into plain text and sent to the Hatch File Writer.

Also, in the interest of security, I have not allowed staff to set the filename of the generated text file. The text files will be written to the Hatch profile directory for the origin and named "receipt.<context>.txt".

---

In the end, the Hatch Java changes are minimal, just a new option to the "set" command which tells Hatch to avoid JSON-encoding the data before writing.

The browser client code is a little more involved, with the addition of the stock file-writer printer and html2txt translation.

---

FWIW, I was able to generate the spine labels we need using a label template like this:

<div ng-repeat="row in label_output_copies">
<table eg-print-label-table>
<tr>
<td ng-repeat="col in row.columns">
<pre ng-if="col.cls === 'spine'">
{{col.c ? get_cn_for(col.c) : ''}}</pre>
</td>
</tr>
</table>
&#012;
</div>