Hatch native print-to-file support

Bug #1824391 reported by Bill Erickson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
New
Wishlist
Unassigned

Bug Description

Evergreen 3.3

Similar to the XUL client's Alternate Print Strategy, Hatch should support a default print target which simply prints to a file. The location of the file should be configurable via the UI per print context, with a sane default provided in the hatch.properties file.

The use case in our environment are spine labels, which are printed to a file so a 3rd-party application can scoop them up for additional processing.

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>

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

Note also the Hatch branch is built atop the JDK11 branch.

tags: added: pullrequest
Changed in evergreen:
milestone: none → 3.4-beta1
assignee: Bill Erickson (berick) → nobody
Revision history for this message
Bill Erickson (berick) wrote :

Force pushed back to working branch code to support file writing for the Angular hatch service.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.