A kind of universal method of printing the graphing file
Technical field
The present invention relates to computer general-purpose and print the method for graphing file, be applicable to the Windows series operating system of Microsoft.It is partly formed by two, be general printing method for drafting and printing interface dynamic link library (Dynamic Link Lib, be DLL) form, but general printing drawing tool is the application software of an independent operating, patterned interface is provided, print masterplate to draw, and the printing interface dynamic link library provides the application call of using it, to print the content of the printing masterplate form that its general printing drawing tool draws, and transmit the print What of its dynamic change, export the general-purpose interface of printer to.
Background technology
Along with computer management in all trades and professions application more and more widely, many industries all need to be industry custom calculation machine management system, it is mis system, and the difficult point of mis system is the variability of its demand and the singularity of industry, this has brought great difficulty for mis system exploitation supplier, and mis system must relate to a large amount of bill printings and a large amount of report printings, hospital management system (HIS) for example, it generally has outpatient service charge receipt, registration form, the invoice of leaving hospital in hospital, inpatient's daily cost bar, the prescription Requisition for drugs, injection is single, the Drug Storage receiving tally, requisition slip or the like, form is countless especially, as 167 forms, E14 form or the like, for a long time, the mis system exploitation supplier we can say when the Developing MIS system, it is very large spending in the time of printing exploitation, and user's demand constantly changes, so the continuous update routine of developer, satisfying user's requirement, this also is to cause mis system exploitation one of the only difficult reason of taking a step.More than be at mis system, because mis system is the system of customization.
For existing developing instrument, report tool generally is provided, as the Repository of Visual Basic, the QuickReport of Delphi etc., but these report tools are not suitable for bill printing, the one, be difficult to draw, the 2nd, revise form and need recompilate program, it is poor to move system property, the 3rd, the routine call complexity, four are to use trouble, even for form, second point, thirdly, the 4th problem also exist.
Use programming tools such as C language, BASIC, PASCAL when the various bill printing of establishment no matter be, all to write a large amount of codes, its most critical be when the form of printing changes, need the recompility program, and the system of moving each other is very difficult, and this has also expended a large amount of time of developer for safeguarding and upgrading and brought great difficulty, and particularly when others goes to take over this application program, brought difficulty especially.
Summary of the invention
The technical problem to be solved in the present invention is, complicacy and the property of printing when under Windows operating system, (comprising windows95/98/2000 and windowsNT) difficult in maintenance and move system down with various language application programming, a kind of method of general printing graphing file is provided, when the form of printing changes, need not compile source program, anyone (not necessarily programmer) all can safeguard; Make the user can the required printed tickets of patterned drafting, form, finding is beaten, the printing template of drafting saves as file layout, any language all can call, transplantability is strong.(call as C++, Delphi, Visual Ba supervisor convenient, flexible, dynamic data transmits convenient any windows programming language, and size of code is few, irrelevant with type of printer, as long as printer is correctly installed, support many printers be may be output to required printer.
The present invention adopts following technical scheme to solve the problems of the technologies described above: construct a kind of universal method of printing the graphing file, be that print Whats such as line, literal and form are drawn as a masterplate, have many attributes in this masterplate, as page or leaf height, width etc., this masterplate is stored in the file, a dynamic link library that can read this printing masterplate file is provided, adopts following steps to print the file of drawing any graphical form:
1, generate printing masterplate file with printing drawing tool, this document is the file of a text formatting; 2, the interface function by dynamic link library reads printing masterplate file to a new type face object; 3, read print the masterplate file after, the dynamic changing data in the graphical file of need printout is carried out assignment; After dynamic changing data is carried out assignment, 4, printout that whole page or leaf object is paid.
In the universal method of above-mentioned printing graphing file, further comprise the steps: in the described step 1
Produce a new printing masterplate object, described to liking the composition unit of whole drafting, be divided into basic object and composite object, wherein, basic object comprises line object, word string object, form object, and composite object is made up of basic object, and this composite object mainly is a page object;
Accept user's keyboard and mouse input for printing drawing tool, print the button that is provided with basic object line, word string, form in the drawing tool and use for the user;
Judge whether the user has clicked the button of line, word string, form, and carried out corresponding non-productive operation,, enter next step, otherwise wait for keyboard and mouse input if produce a new object to produce a new object;
Print masterplate page or leaf object and its all basic object is used as a chained list manages, when new object produces, automatically this object is added in the chained list of page or leaf object;
By activating the object of chained list, give the attribute assignment of basic object, the attribute of basic object mainly contains:
<1〉line (Line)
The line segment that starting point and terminal point are arranged, it belongs to the outward appearance form object of printing masterplate, can form many figures, and what no dynamic attribute is depicted as, and what promptly is printed as.
Attribute: a, width b, type are as short dash line, dotted line etc.
<2〉word string (String)
The most frequently used object, it can staticly show also dynamically Data transmission, in fact just can be satisfied the needs of the bill printing page by it and line object;
Attribute: a, font b, whether have dynamically, if the value c of its dynamic I D is arranged, whether hide during dynamic print
<3〉form (grid)
This form can be edited the content of its cell, can be made up of line object and word string object in principle; Attribute: a, font b, whether have dynamically, if have the hiding d of value c, grid, columns e, line number f, the form of its dynamic I D whether fixing, be whether its line number can change, g is if the on-fixed form, its mobile h that whether influences object below the coordinate is if the on-fixed form, its whether influence the mobile I of page or leaf, whether hide ruling J, whether hide frame page or leaf object attribute also arranged, its attribute is mainly: a, the high b of page or leaf, page width judge whether not add object to masterplate, if no longer add then preservation printing masterplate; Preserve this and print masterplate, the method for its preservation is: at first preserve marking head WXADRAW001, preserve the page or leaf object properties then, travel through masterplate object chained list, preserve the attribute of each basic object, save as a text.
In the method for above-mentioned general printing graphing file, further comprise the steps: in the described step 2
Apply for a new page or leaf object, open in the mode of reading then and print the masterplate file;
Read first row of file;
Judge whether this row is marking head WXADRAW001, incorrect if not its printing masterplate file layout of explanation;
Reading under the situation that marking head is WXADRAW001, continue to read next line;
Handle according to reading capable content, proceed read step then, when reading End: the time represent to read end, below for printing the form of masterplate file: generating suffix is the text of wxt, the file that meets this call format can be called by RrprintEn.dll, and this class file also can be opened modification by Winterface once more, also can directly use text editor, as modifications such as the notepad of MicroSoft, UltraEdit, but must meet the call format of interface document;
Except that first row, every row is made of a wardrobe sign, be XXX:, perhaps there is not content in (referring to this row) and having thereafter, be listed as STRINGOBJ: show a word string object, do not have content thereafter, but if Point:, show that coordinate is meaningful thereafter, the separator between the content behind every wardrobe is both ASCII character 9 of Tab.
In the method for above-mentioned general printing graphing file, further comprise the steps: in the described step 3
At the dynamic assignment of object in two kinds of situation, a kind of is the word string object, and another kind is a table objects, and word string object and table objects just have dynamically;
For the dynamic assignment situation of word string, after the page or leaf object read printing masterplate file, it formed a chained list to all basic objects, therefore needed the traversal chained list;
As reading the chained list tail end, represent that this assignment finishes;
When also not reading tail end, the object that reads is judged, if being word string object and its dynamic marks (ID), this object equals the required dynamic I D that looks for, the string value of required tax is sent to this word string object, be repeated to above-mentioned steps then;
At the situation of the dynamic assignment of form, need the traversal chained list, finding dynamic I D is the table objects of required dynamic I D;
Carry out dynamic assignment at the table objects of being looked for, the dynamic assignment of form is the assignment to its cell, gives corresponding value one by one to the cell of required assignment and gets final product.
In the method for above-mentioned general printing graphing file, further comprise the steps: in the described step 4
Preserve the information such as high wide and font of printer current page, determine the information such as high wide and font of type face according to the attribute of printing masterplate page or leaf object;
According to the attribute of printing masterplate page or leaf object the information such as high wide and font of type face are set, to satisfy the needs that type face meets design;
The object chained list of traversal page or leaf object, the outward appearance of drawing this object on printing canvas one by one has dynamic object and draws according to its dynamic value, and the table objects with dynamic attribute is drawn by its cell content;
Painting canvas is passed in the printer of formulating, otherwise the printer for giving tacit consent to.
Implement the universal method of printing graphing file provided by the invention, has following advantage: print method for drafting (Winterface) a patterned printing template drawing tool is provided, it provides line, literal and form that print What is drawn as a masterplate, have many attributes in certain this masterplate, as page or leaf height, width or the like, this masterplate is stored in the file, and in fact this file has comprised all the elements description of this printing template.Provide a large amount of application program and methods of printing masterplate that read at dynamic link library (RrprintEn.DLL), it can read by printing the printing masterplate that drawing tool (Winterface) is drawn, can handle the content of masterplate by attribute and method that it provides, as the transmission of dynamic value etc., and can call its preview or Method of printing preview or print masterplate and come out.
The present invention separates data with form, irrelevant for the form and its related source program that make various printings, when the form of printing changes, need not compile source program, and anyone (not necessarily programmer) all can safeguard; Make the user can the required printed tickets of patterned drafting, form, finding is beaten, the printing template of drafting saves as file layout, any language all can call, transplantability is strong.(call as C++, Delphi, Visual Ba supervisor convenient, flexible, dynamic data transmits convenient any windows programming language, and size of code is few.Irrelevant with type of printer, as long as printer is correctly installed; Method provided by the invention is also supported many printers be may be output to required printer.
Description of drawings
Fig. 1 is the printing step flow diagram of the inventive method;
Fig. 2 is the concrete steps flow diagram of steps A among Fig. 1;
Fig. 3 is the concrete steps flow diagram of step B among Fig. 1;
Fig. 4 is the concrete steps flow diagram of step C among Fig. 1;
Fig. 5 is the concrete steps flow diagram of step D among Fig. 1;
Embodiment
Method provided by the invention is the print file pattern that needs follow procedure to print at, think by line, literal, these objects of form are formed, it is changeless for some object, and some is variable to liking, can imagine as open fill substance at a piece of paper, thing (object) before filling on the paper is to immobilize, static object just, the content of filling in is variable, the content that finger is filled in by different needs is referred to as dynamically, therefore program will realize printing such content, whether can print is only to need to change these dynamic objects at every turn, secondly for these static objects, whether can describe, as a file with an interface that has nothing to do with application program, application program only need is just passable from the attribute that this document reads these objects, for dynamic object, there is certain requirement their position simultaneously, and this also can be irrelevant with application program; Based on above-mentioned principle, the invention provides following method in common and realize printing the graphing file:
As shown in Figure 1, 2, steps A is at first used and is printed drawing tool generation printing masterplate file, and this document is the file (steps A is made up of A1, A2, A3, A4, A5, A6, A7, sees Fig. 2) of a text formatting.
Steps A 1 produces a new printing masterplate object, to liking a key concept of this instrument, promptly to liking the composition unit of whole drafting, it divides basic object and composite object, wherein, basic object comprises line object, word string object, form object, and composite object is made up of basic object, and this composite object mainly is a page object.
Steps A 2 is accepted user's keyboard and mouse input for printing drawing tool, and printing drawing tool has the button of basic object line, word string, form to use for the user.
Steps A 3 judges whether the user has clicked the button of line, word string, form, and has carried out corresponding non-productive operation to produce a new object, if produce a new object, enters next step, otherwise waits for keyboard and mouse input.
Steps A 4 is printed masterplate page or leaf objects and its all basic object is used as a chained list is managed, and when new object produces, automatically this object is added in the chained list of page or leaf object.
Steps A 5 is given the attribute assignment of basic object by activating the object of chained list, and the attribute of basic object mainly contains:
<1〉line (Line) has the line segment of starting point and terminal point, and it belongs to the outward appearance form object of printing masterplate, can form many figures, and what no dynamic attribute is depicted as, and what promptly is printed as.
Attribute: a, width b, type are as short dash line, dotted line etc.
<2〉the most frequently used object of word string (String), it can staticly show also dynamically Data transmission, in fact just can be satisfied the needs of the bill printing page by it and line object
Attribute: a, font b, whether have dynamically, if the value of its dynamic I D is arranged
C, whether hide during dynamic print
<3〉form (grid)
This form can be edited the content of its cell, can be made up of line object and word string object in principle; Attribute: a, font b, whether have dynamically, if the value of its dynamic I D is arranged
Whether c, the hiding d of grid, columns e, line number f, form are fixed, and promptly whether its line number can change.G is if the on-fixed form, and its mobile h that whether influences object below the coordinate is if the on-fixed form, its whether influence page or leaf mobile I, whether hide ruling J, whether hide frame page or leaf object attribute is also arranged, its attribute is mainly:
Attribute: a, the high b of page or leaf, page width
Steps A 6 judges whether not add object to masterplate, generally is to have carried out preserving action
Steps A 7 is preserved this and is printed masterplate, and the method for its preservation is: at first preserve marking head WXADRAW001, preserve the page or leaf object properties then, travel through masterplate object chained list, preserve the attribute of each basic object, save as a text.
Shown in Fig. 1,3, the interface function of the step B dynamic link library that to be application program provide by this instrument reads prints masterplate file to a new type face object (step B is made up of B1, B2, B3, B4, sees Fig. 3).
Step B1 is new page or leaf object of application, opens in the mode of reading then and prints the masterplate file.
Step B2 is first row that reads file.
Step B3 judges whether this row is marking head WXADRAW001, and is incorrect if not its printing masterplate file layout of explanation.
Step B4 reads under the situation that marking head is WXADRAW001 in step 3, continues to read next line.
Step B5 reads capable content according to step 3 to handle, and continues step 4 then, when reading End: the time represent to read end, below for printing the form of masterplate file:
The purpose of printing drawing tool is that the generation suffix is the text of wxt, the file that meets this call format can calling by RrprintEn.dll, and this class file also can be opened modification by Winterface once more, also can directly use text editor, as modifications such as the notepad of MicroSoft, UltraEdit, but must meet the call format of interface document.
Except that first row, every row is made of a wardrobe sign, be XXX:, perhaps there is not content in (referring to this row) and having thereafter, be listed as STRINGOBJ: show a word string object, do not have content thereafter, but if Point:, show that coordinate is meaningful thereafter, the separator between the content behind every wardrobe is both ASCII character 9 of T à b.
The method for expressing of following table format is type+sequence number, is used for explanation.
I Integer N decimal S text (can be Chinese character, also English, or both mix) C Chinese-character text E English text B is true and false to have only True or False
Coordinate unit is twip (being the unit that a kind of computer-internal is accurately located use), 1twip=1/20 picture point=1/1440Inch=1/567MM, and the user can adopt mm unit when carrying out the graphical interfaces operation;
<1〉page or leaf
The file that page or leaf saves as has a file header WXADRAW001, and it is first row of file, and this can not change.
End-of-file (EOF) necessarily has an END:, otherwise can make mistakes when reading this document.
Head |
Form |
Describe |
PageSize: |
I?N1?N2?N3?N4 |
The page or leaf size only is concerned about N1, and N2, N1 are page width, and N2 is that page or leaf is high |
DataBase: |
|
Need not be concerned about |
<2〉line
Head |
Form |
Describe |
LINEOBJ: |
|
Show that line begins |
Name: |
E |
Title (the inner use) |
Point: |
N1?N2?N3?N4 |
Coordinate, N1 starting point horizontal ordinate N2 starting point ordinate |
|
|
N3 terminal point horizontal ordinate N4 terminal point ordinate |
TabIndex: |
|
Need not be concerned about |
Movity(0): |
|
Need not be concerned about |
Movity(1): |
|
Need not be concerned about |
Width: |
I |
Line width |
Style: |
I |
The line type |
Hide: |
B |
Whether hide during dynamic print |
LINEEND: |
|
Line object finishes |
<3〉word string
Head |
Form |
Describe |
STRINGOBJ: |
|
Show that word string begins |
Name: |
E |
Title (the inner use) |
Point: |
N1?N2?N3?N4 |
Coordinate, N1 starting point horizontal ordinate N2 starting point ordinate N3 terminal point horizontal ordinate N4 terminal point ordinate |
TabIndex: |
|
Need not be concerned about |
Movity(0): |
|
Need not be concerned about |
Movity(1): |
|
Need not be concerned about |
Font:: |
B1?S?B2?B3?N |
Whether B1 black matrix S font name B2 italic B3 underscore N font size whether whether |
Dyn:: |
E?I |
E dynamic I D, the I alignment thereof |
Hide: |
B |
Whether hide during dynamic print |
Str: |
S |
Videotex |
STRINGEND: |
|
The word string object finishes |
<4〉form
Head |
Form |
Describe |
GRIDOBJ: |
|
Show that form begins |
Name: |
E |
Title (the inner use) |
Point: |
N1?N2?N3?N4 |
Coordinate, N1 starting point horizontal ordinate N2 starting point ordinate N3 terminal point horizontal ordinate N4 terminal point ordinate |
TabIndex: |
|
Need not be concerned about |
Movity(0): |
|
Need not be concerned about |
Movity(1): |
|
Need not be concerned about |
Font:: |
B1?S?B2?B3?N |
Whether B1 black matrix S font name B2 italic B3 underscore N font size whether whether |
Dyn:: |
E?I |
E dynamic I D, the I alignment thereof |
Hide: |
B |
Whether hide during dynamic print |
Rows: |
I |
Maximum number of lines |
Cols: |
I |
Maximum number of column |
RowHeight: |
N1?N2?N3… |
Every line height |
ColWidth: |
N1?N2?N3… |
Every column width |
ColAlign: |
I1?I2?I3.. |
Every column alignment mode |
Data: |
S1@S2@S3… |
The unit text |
GridFrameHide: |
B |
Whether hide separator bar |
Fixed: |
B |
Whether line number is fixed |
GRIDEND: |
|
Table objects finishes |
As Fig. 1, shown in Figure 4, step C be explanation after reading printing masterplate file, how dynamic changing data is carried out assignment? also be that this instrument is realized the method (step C is made up of C1, C2, C3, C4, C5, C6, sees Fig. 4) that print data transmits.
In fact step C1, has only word string object and table objects just to have dynamically at the dynamic assignment of object in two kinds of situation, and the assignment method of word string object and table objects is far different, therefore provides implementation step respectively.
Step C2 is the situation at the dynamic assignment of word string, and after the page or leaf object read printing masterplate file, it had formed a chained list to all basic objects, therefore needed the traversal chained list.
Step C3 represents that as reading the chained list tail end this assignment finishes.
When step C4 does not read tail end in step 3, the object that reads is judged, if this object tail word string object and its dynamic marks (ID) equal the required dynamic I D that looks for, compile the string value of required tax is sent to this word string object, be repeated to step C2 then.
Step C5 is the situation at the dynamic assignment of form, needs the traversal chained list, and finding dynamic I D is the table objects of required dynamic I D, and following steps are to this table objects operation.
Step C6 is undertaken by the table objects that step 5 is looked for, and the dynamic assignment of form is the assignment to its cell, gives corresponding value one by one to the cell of required assignment and gets final product.
As Fig. 1, shown in Figure 5, just the printing that step D can pay whole page or leaf object after carrying out dynamic assignment by step C, step D has illustrated the performing step of printing (step D is made up of D1, D2, D3, D4, sees Fig. 5).
Step D1:, therefore at first should preserve the information such as high wide and font of the current page or leaf of printer because the information such as high wide and font of type face are to determine according to the attribute of printing masterplate page or leaf object.
Step D2: according to the attribute of printing masterplate page or leaf object the information such as high wide and font of type face are set, to satisfy the needs that type face meets design.
Step D3: the object chained list of traversal page or leaf object, the outward appearance of drawing this object on printing canvas one by one has dynamic object and draws according to its dynamic value, and the table objects with dynamic attribute is drawn by its cell content.
Step D4: painting canvas is passed in the printer of formulating, otherwise the printer of acquiescence.
Dynamic link library (RrprintEn.DLL) provides and can be used for reading application program and the method for printing masterplate in a large number, it can read by printing the printing masterplate that drawing tool (Winterface) is drawn, can handle the content of masterplate by attribute and method that it provides, as the transmission of dynamic value etc., and can call its preview or Method of printing preview or print masterplate and come out.
In application program, adopt this method to carry out the customizing print graphic file, can simplify the workload that the programming personnel works out printing portion, and put things right once and for all, (Windows 95 but the Windows environment is adopted in this universal printing method widespread use, Windows 98, Windows NT, Windows2000, Windows XP) printing of the various application programs of establishment needs down, particularly various at the various invoices of this management system, revise frequent characteristics, the independence of its form and data, greatly reduce the maintenance cost of software, make software use the merchant oneself to safeguard the pattern of various printings; It adopts the dynamic chanining bank interface mode, and its programmer who is familiar with the programming language under the different Windows environment all can be convenient to use; The independence of itself and printing device makes the programmer needn't go to be concerned about printing device; The simple, clear of its programming use allows the programmer can tackle the printing demand of various complexity easily, improved development efficiency greatly.
The more important thing is that this method can expand, it provides a framework, can further encapsulate, support more specialized, more specifically print demand.