WebApps with LocalStorage and AppCache/Print

This learning resource focuses on print generated content in the WebApp. The content is considered as result of processing data totally with the browser without submission to a remote server (see design of an AppLSAC)

Demo Files for Printing in an AppLSAC
The repository Print4JS contains a list of examples that are generated for this repository as quickstart. The shell script  generated file   which are also included with. Check out the demos to explore the underlying principles of client-side printing with contacting a remote server.


 * Demo 1: Print Content in Textarea
 * Demo 2: Print Code
 * Demo 3: Print Code with Print Window
 * Demo 4: Print Code with Syntax Highlighting
 * Demo 1: Print Content in Textarea
 * Demo 6: Print PDF with html2pdf
 * Demo 7: Print JSON with Handlebars Template Engine
 * Print Window for Code with highlight.js

pandoc 2.7.3

Print4JS - Print Page for JavaScript
The repository is a fork of   and will be maintained as a learning resource for. Javascript code can be used to creates a print job from the browser. With the library print.js a WebApp is able to print specific browser content like


 * Form content,
 * Images in a canvas,
 * PDF files,
 * Content of a textarea,
 * ... Javascript has as  method of the   object of the browser, but this method allow the printing of content of the current browser window only.   allows printing of specific content elements by calling the   function on new window, that contains the desired content only. This concept leads to the 4 main steps:
 * (Open Window) Open a new browser window,
 * (Create Content) write the content, that should be printed into the browser window with Javascript,
 * (Call Printer API) call the  function for the generated browser window,
 * (Close Window) close the browser window

This repository was forked from and inspired by developements of Rodrigo Vieira (Github User: crabbly). The repository is used learn about printing methods within a Javascript WebApps.

Print4JS Steps
The next steps describe the basic constituents of creating a print job within a WebApp. The following code shows the underlying software design.

For application in a WebApp (e.g. AppLSAC use the library.

Open Browser Window
the following HTML code shows a basic concept of opening a printer window.

Call Printer Dialog
Assume the window with the generated content in  then the content can be submitted to the printer with the   command.

Close Printer Content Window
In general closing a window is called with. In this case we are closing the window with the Printer Content. The printer window can be closed with, if the window was created/opened from the WebApp with Javascript (see also AppLSAC).

HTML Content of Printer Window
The following file shows the content of :

The style sheet  format the output to the desired layout (e.g. font size, fonts, ...)

Remark
The window of loaded HTML page itself cannot be closed with. This is not a bug. This a security feature, because web sites should not be able to close a browser window with all open tabs, because the user might loose the content of forms in that window.