Home > Back-end >  Printer, genuflect is begged Tpinter control, should play lines appear error
Printer, genuflect is begged Tpinter control, should play lines appear error

Time:10-22

Printer through TCanvas, information output form from images or printer, form information XML code is as follows:

Code above is XML code, through txmldocument read the rows and columns, according to line according to the cell lines and text output to the printer, the output is correct in the pictures, the effect the following

But the output to the printer, the other works, form the first line of the first cell to the left in the 1 mm error, I depressed!!!!! (don't know if the printer problem)

The following is the code:
Dbug:=1;
Act:='print';



//http://localhost:8080/print? Pid=20110705000002 & amp; Djid=20121123000004 & amp; Djtype=xsdingdan& The client=delphi& Act=loadview
The pid: Get_PID=();
Djid=Get_DJID ();
Djtype: Get_DJTYPE=();
Client:='Delphi';
Param:=TStringList. Create;
RStream:=TStringStream. Create (");
Param. Add (' act=loadview ');
Param. Add (' pid='+ pid);
Param. The Add (+ djid djid=);
Param. The Add (+ djtype djtype=);
Param. The Add (+ client client=);


Url:=rootpath + 'print';
Self. Idhttp. Post (' http://localhost:8080/print 'Param, RStream);
Xmlstring:='& lt; ? The XML version="1.0" encoding="gb2312"?> ';
Xmlstring:=xmlstring + RStream. DataString;
PXML:=xmlstring;

Mx:=TXMLDocument. Create (self);
Mx. XML. The Add (xmlstring);
Mx. Active:=true;
Printname:=mx. DocumentElement..childnodes [' printname]. The Text;
Printwidth:=mx. DocumentElement..childnodes [' printwidth]. The Text;
Printheight:=mx. DocumentElement..childnodes [' printheight]. The Text;


Printer. Title:='sales order to print;
SetPaperWidth (round (strtofloat (printwidth)));//mm
SetPaperHeight (round (strtofloat (printheight)));
MyCanvas:=Printer. Canvas;
Printer. BeginDoc;
MyCanvas. Brush. Color:=clWhite;
MyCanvas. FillRect (MyCanvas. ClipRect);//remove residual image
MyCanvas. Brush. Color:=clBlue;
MyCanvas. Brush. Style:=bsclear;
MyCanvas. Pen. Color:=clBlack;
MyCanvas. The Font. Color:=clBlack;


Rowcount:=mx. DocumentElement..childnodes [' mxbody].childnodes. Count;
Pagecount:=1;
Pagesize:=0;
Tableleft:=0;
Tabletop:=0;
Tabrowcount:=0;
Tabmaxheight:=0;
If mx. DocumentElement..childnodes [' printtable].childnodes. Count<> 0 then
The begin
Pagesize:=StrToInt (mx. DocumentElement..childnodes [' printtable].childnodes [' mxloop]. Text);
Then if (rowcount mod pagesize)=0
Pagecount:=Trunc (rowcount/pagesize)
The else
Pagecount:=Trunc (rowcount/pagesize) + 1;
Tableleft:=StrToFloat (mx. DocumentElement..childnodes [' printtable].childnodes [r]. "MXX" Text);
Tabletop:=StrToFloat (mx. DocumentElement..childnodes [' printtable].childnodes [' mxy]. Text);
Tabrowcount:=mx. DocumentElement..childnodes [' printtable].childnodes [' table '].childnodes. Count;
The end;

Tableleftold:=tableleft;
I:=0;
Currentpage:=0;
At:=0;
Pagecount:=1;

While currentpageThe begin


While iThe begin

Trnode:=mx. DocumentElement..childnodes [' printtable].childnodes [' table '].childnodes [I];
Rowheight=Real (trnode. Attributes [' height ']);
Rowtype:=trnode. Attributes [' rowtype];
K:=0;
Cellcount:=trnode.childnodes. Count;



If trnode. HasAttribute (' loop ') then
The begin
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- is a subsidiary part -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Mxnum:=Integer (trnode. Attributes [' loop ']);
Mxrowheight:=Real (trnode. Attributes [' height ']);

While (kThe begin
J:=0;
While jThe begin
Tdnode:=trnode.childnodes [j];
Cellwidth:=Real (tdnode. Attributes [' width ']);
TXT:=tdnode. Text;
If tdnode. HasAttribute (' binding ') then
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull