Print Templates, Part V: Re-pagination - Doc JavaScript
Print Templates, Part V: Re-pagination
In this column we continue our series on print templates. Print templates first appeared in Internet Explorer 5.5, and were later improved in Internet Explorer 6. In column 89, Print Templates, Part I, we showed you how to assemble a print template with two out of the four elements of print templates: LayoutRect
and DeviceRect
. In Column 91 (Print Templates, Part II: TemplatePrinter) we added the TemplatePrinter
element. In Column 92 (Print Templates, Part III: HeaderFooter), we cover the fourth and last element of print templates, HeaderFooter
. In Column 93, (Print Templates, Part IV: User Settings) we taught you how to reflect the user settings in the document layout. In this column, we'll explain how to re-paginate a document following a change in its zoom factor. In previous columns, we always dealt with a single static pagination, after which we ended up with a single document format. When the user can change the zoom factor, the number of pages may go up or down, and what to do with the excess pages, if there are any, is not that trivial. We'll show you how to hide unused pages from previous pagination. We'll also show you how to set the different event handlers to support such a capability. This column also combines several capabilities we have presented before, such as dynamic page assembling, printing with and without preview, adding headers and footers, updating the total number of pages in all pages, page formatting according to user settings, etc.
The only way to call TemplatePrinter
and HeaderFooter
is through C++ code. Luckily, someone in Microsoft wrote an application to which you can feed your own print templates and the documents you want to print. This application comes with sample print templates that our columns are based on. In this column we introduce the change in zoom factor with template7.html
.
In this column you will learn:
- How to write the print template
template7.html
- How to prompt the user for a new zoom factor
- How to change the zoom factor of the document
- How to hide excess pages
- How to initialize the print template
You can see the full code listing of template7
on Page 7. Load it from the enclosed zipped file.
Next: How to write the print template
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: October 8, 2001
Revised: October 8, 2001
URL: https://www.webreference.com/js/column94/index.html