Share a custom printing scheme (1), Overview

Source: Internet
Author: User

In the recent project, you need to implement the document hedging function. After the function is implemented, leave this diary for memo and provide a solution for students with similar requirements.

Original requirements:

1. The print template supports flexible customization and visual settings (including setting whether the print items are printed, and the position, size, Font, etc ...).

2. Supports custom print items.

3. General print item settings (such as automatic print subtotal/total, header table tail, etc ...)

4. Supports real-time preview when setting a template.

First, let's take a look at the previous figure. Let's take a look at the rough picture of the printed template.

Next, let's briefly discuss how to implement this requirement. After a brief analysis, the following role objects may exist in this function.

1. print item: it is also called printitem. It is not difficult to find at least the following attributes: Tag Name, data source, width, height, Font, color, alignment, print coordinates (indicating that the fine area may be a print Position Index )...

2. print template data: For the sake of simplicity, we can split the template data into the header, table body, and table end, because the table header and the table end are basically the same in terms of control behavior, we naturally derived the table header and the "Table body" in the middle.

3. header table tail: it is called billheaderorbottom temporarily. It is not hard to see that it should include a set of print items and a data source that assigns values to these print items. and the size and actual coordinates of the region.

4. The table body is the middle table. It is called billgridbody for the moment. It has the same content as billheaderorbottom. You should also set the rows to subtotal/total.

5. The print controller, called billprinter, is used to load the print format and control the output to the printer according to the parameter configuration.

With the simple analysis above, let's briefly draw the class structure diagram of this requirement.

With the above analysis, let's take a look at how to implement this function. considering that it may take a long time to explain how to implement the function, we will divide the function into the following sections.

1. to support template visualization settings, we need to process a container control that supports mouse drag. For simplicity, the extended panel is used as an example. ---- share a custom printing scheme (2 ).

2. Designer panel. ---- share a custom print sleeve Program (3 ).

3. Save and load the format. ---- share a custom printing scheme (4 ).

4. Implementation of printing ---- share a custom printing scheme (5 ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.