quickrep走纸问题

ccwenwen 2004-06-25 09:50:18
我在程序设定quickrep为自定义纸张,长为135mm,宽为240mm,为什么打完一张之后打印机会走一张空白纸,急需解决~~,解决马上给分,在线等
...全文
55 点赞 收藏 8
写回复
8 条回复
ccwenwen 2004年06月29日
第一次结不知道怎么结
回复 点赞
ccwenwen 2004年06月29日
多谢duchuan(维达定理),问题解决,结帖
回复 点赞
duchuan 2004年06月28日
3、
//打印与预览公用的打印页
void __fastcall TfrmBusiness::PrintPage(int pageNumber,int TotalPg,AnsiString TabTitle,AnsiString OtherSide,TADOTable *Mymaster,TADOTable *Mydetail)
{
TCanvas *MyCanvas;
AnsiString tmp;
AnsiString TitleName;
int TextHt,iX,iY;
int repeatchar=105;
int pgh;//PageHeight
float qty,price,pgSum=0;
if(IsPreview)
{
MyCanvas=frmLinePrintPreview->Image1->Canvas;
pgh=int(940*96/180);
}
else
{
MyCanvas=Printer()->Canvas;
pageline=1;//Class element
pgh=0;
}
MyCanvas->Font->Name="宋体";
MyCanvas->Font->Size=14;
TextHt=MyCanvas->TextHeight("宋");
iY=pageNumber*pgh+TextHt*pageline;
TitleName=BaseData->UserInfo->FieldByName("Name")->AsString;
MyCanvas->TextOut(400,iY,TitleName+TabTitle);
pageline+=1;
MyCanvas->Font->Size=10;
TextHt=MyCanvas->TextHeight("宋");
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
MyCanvas->TextOut(1,iY,AnsiString::StringOfChar('-', repeatchar));
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
MyCanvas->TextOut(1,iY,OtherSide);
tmp="开单日期:"+Mymaster->FieldByName("TabDate")->AsString;
MyCanvas->TextOut(750,iY,tmp);
tmp="单号:"+Mymaster->FieldByName("BookID")->AsString+"-"+Mymaster->FieldByName("TabID")->AsString;
MyCanvas->TextOut(1050,iY,tmp);
//tmp="经办人:"+Mymaster->FieldByName("lkEmp")->AsString;
//MyCanvas->TextOut(1000,TextHt*pageline,tmp);
//MyCanvas->TextOut(1250,TextHt*pageline,"签字:");
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
tmp=Mymaster->FieldByName("Remark")->AsString;
if(Trim(tmp)!="")
MyCanvas->TextOut(1,iY,"备注:"+tmp);
else
MyCanvas->TextOut(1,iY," ");//补位
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
tmp=AnsiString::StringOfChar('-', repeatchar);
MyCanvas->TextOut(1,iY,tmp);
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
MyCanvas->TextOut(1,iY,"代码");
MyCanvas->TextOut(90,iY,"品名型号");
MyCanvas->TextOut(600,iY,"单位");
MyCanvas->TextOut(700,iY,"数量");
MyCanvas->TextOut(900,iY,"单价");
MyCanvas->TextOut(1080,iY,"金额");
MyCanvas->TextOut(1180,iY,"器号");
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
tmp=AnsiString::StringOfChar('-', repeatchar);//最多100字符/行
MyCanvas->TextOut(1,iY,tmp);
int fromRc=RecordsPerPage*pageNumber+1;
Mydetail->RecNo=fromRc;
for(int i=fromRc;i<fromRc+RecordsPerPage;i++)
{
if(Mydetail->Eof)
break;
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
MyCanvas->TextOut(1,iY,Mydetail->FieldByName("GoodID")->AsString);
MyCanvas->TextOut(90,iY,Mydetail->FieldByName("Description")->AsString);
MyCanvas->TextOut(600,iY,Mydetail->FieldByName("lkUnit")->AsString);//单位
//print qty
qty=Mydetail->FieldByName("Qty")->AsFloat;
tmp=FloatToStrF(qty,ffFixed,15,2);
iX=700+MyCanvas->TextWidth("数量")-MyCanvas->TextWidth(tmp);
MyCanvas->TextOut(iX,iY,tmp);
//print price
price=Mydetail->FieldByName("Price")->AsFloat;
tmp=FloatToStrF(price,ffFixed,15,2);
iX=900+MyCanvas->TextWidth("单价")-MyCanvas->TextWidth(tmp);
MyCanvas->TextOut(iX,iY,tmp);
//print qty*price
tmp=FloatToStrF(qty*price,ffFixed,15,2);
iX=1080+MyCanvas->TextWidth("金额")-MyCanvas->TextWidth(tmp);
MyCanvas->TextOut(iX,iY,tmp);
pgSum+=qty*price; //本页小计。
Mydetail->Next();
}
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
if(pageNumber+1==TotalPg)
{
MyCanvas->TextOut(1,iY,"合计金额:");
tmp=FloatToStrF(Mymaster->FieldByName("SumMoney")->AsFloat,ffFixed,15,2);
iX=1080+MyCanvas->TextWidth("金额")-MyCanvas->TextWidth(tmp);
MyCanvas->TextOut(iX,iY,tmp);
}
else if(pageNumber+1<TotalPg)
{
MyCanvas->TextOut(1,iY,"本页金额:");
tmp=FloatToStrF(pgSum,ffFixed,15,2);
iX=1080+MyCanvas->TextWidth("金额")-MyCanvas->TextWidth(tmp);
MyCanvas->TextOut(iX,iY,tmp);
}
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
MyCanvas->TextOut(1,iY,AnsiString::StringOfChar('-', repeatchar));
pageline+=1;
iY=pageNumber*pgh+TextHt*pageline;
MyCanvas->TextOut(1,iY,BaseData->GetCurOperator());
MyCanvas->TextOut(700,iY,"经办人:");
MyCanvas->TextOut(950,iY,"收货人:");
//pageline+=1;
//iY=pageNumber*pgh+TextHt*pageline;
tmp="第"+AnsiString(pageNumber+1)+"页,共"+AnsiString(TotalPg)+"页";
iX=1+MyCanvas->TextWidth(AnsiString::StringOfChar('-', repeatchar))-MyCanvas->TextWidth(tmp); //center
MyCanvas->TextOut(iX,iY,tmp);
}
根据以上作适当的修改,应该合用。
回复 点赞
duchuan 2004年06月28日
还要用画布编写自己的打印程序:
2、打印发货单(小纸条)主函数:
const int RecordsPerPage=8;
void __fastcall TfrmBusiness::PrintByCanvas(AnsiString TabTitle,AnsiString OtherSide,TADOTable *Mymaster,TADOTable *Mydetail)
{
int rc=Mydetail->RecordCount;
int lastpg=Ceil(rc/(RecordsPerPage*1.0));
bool needsnewpg=false;
// Initialize print job
Mydetail->First();//Must have this sentence.
//Printer()->Refresh();
Printer()->BeginDoc();
Printer()->Title = TabTitle;
for (int y=0; y<lastpg; y++) // for each page
{
if (needsnewpg) // page 1 does not need a page break
Printer()->NewPage();
PrintPage(y,lastpg,TabTitle,OtherSide,Mymaster,Mydetail); // print the page
needsnewpg = true; // subsequent pages need page breaks
}
Printer()->EndDoc();
Success("打印完毕。");
}
3、打印自定义纸张的函数
回复 点赞
duchuan 2004年06月28日
页式打印就是这样。下面3个函数可以解决问题:
1、设置打印机使其可以打印自定义纸张
void __fastcall TfrmSetPrn::btViewSetClick(TObject *Sender)
{
char MyDevice[50];
char MyDriver[50];
char MyPort[50];

THandle MyDeviceMode;
TDevMode *pDeviceMode;
//PrintDialog1->Execute();
// Printer()->GetPrinter(
Printer()->GetPrinter(MyDevice,MyDriver,MyPort,MyDeviceMode);
Memo1->Clear();
Memo1->Lines->Add("设备:"+AnsiString(MyDevice));
Memo1->Lines->Add("驱动程序:"+AnsiString(MyDriver));
Memo1->Lines->Add("端口:"+AnsiString(MyPort));
Memo1->Lines->Add("设备句柄号:"+AnsiString(MyDeviceMode));
pDeviceMode=(TDevMode *)GlobalLock((void *)MyDeviceMode);
//char *tmp=pDeviceMode->dmDeviceName;
//Memo1->Lines->Add(AnsiString(((char *)pDeviceMode->dmDeviceName)));
Memo1->Lines->Add("版本号:"+AnsiString(pDeviceMode->dmSpecVersion));// WORD dmSpecVersion版本号;
Memo1->Lines->Add("驱动版本号"+AnsiString(pDeviceMode->dmDriverVersion));//WORD dmDriverVersion驱动版本号;
//Memo1->Lines->Add(AnsiString( WORD dmSize设备模式DEVMODE信息占用空间;
//Memo1->Lines->Add(AnsiString( WORD dmDriverExtra其他信息占用空间;
//Memo1->Lines->Add("域:"+AnsiString(pDeviceMode->dmFields));// DWORD dmFields
Memo1->Lines->Add(AnsiString::StringOfChar('-',Memo1->Width/10));
Memo1->Lines->Add("打印方向:"+AnsiString(pOrn[pDeviceMode->dmOrientation-1]));// short dmOrientation;
Memo1->Lines->Add("纸型:"+AnsiString(ppage[pDeviceMode->dmPaperSize])); //short dmPaperSize;
Memo1->Lines->Add("纸长:"+AnsiString(pDeviceMode->dmPaperLength));// short dmPaperLength;
Memo1->Lines->Add("纸宽:"+AnsiString(pDeviceMode->dmPaperWidth));// short dmPaperWidth;
Memo1->Lines->Add("缩放率"+AnsiString(pDeviceMode->dmScale));// short dmScale;
//Memo1->Lines->Add(AnsiString( short dmCopies;
//Memo1->Lines->Add(AnsiString( short dmDefaultSource;
if(pDeviceMode->dmPrintQuality<4)
Memo1->Lines->Add("打印品质:"+AnsiString(pqlty[pDeviceMode->dmPrintQuality]) );// short dmPrintQuality;
Memo1->Lines->Add("x分辨率:"+AnsiString(pDeviceMode->dmPrintQuality) );// short dmPrintQuality;
//Memo1->Lines->Add(AnsiString( short dmColor;
//Memo1->Lines->Add(AnsiString( short dmDuplex;
Memo1->Lines->Add("y分辨率:"+AnsiString(pDeviceMode->dmYResolution));// short dmYResolution;
//Memo1->Lines->Add(AnsiString( short dmTTOption;
//Memo1->Lines->Add(AnsiString( short dmCollate;
//Memo1->Lines->Add(AnsiString( BCHAR dmFormName[CCHFORMNAME];
//Memo1->Lines->Add(AnsiString( WORD dmLogPixels;
//Memo1->Lines->Add(AnsiString( DWORD dmBitsPerPel;
Memo1->Lines->Add(AnsiString::StringOfChar('-',Memo1->Width/10));
Memo1->Lines->Add("纸宽点数:"+AnsiString(pDeviceMode->dmPelsWidth));// DWORD dmPelsWidth;
Memo1->Lines->Add("纸高点数:"+AnsiString(pDeviceMode->dmPelsHeight));// DWORD dmPelsHeight;
//Memo1->Lines->Add(AnsiString( DWORD dmDisplayFlags;
//Memo1->Lines->Add(AnsiString( DWORD dmDisplayFrequency;

GlobalUnlock((void *)MyDeviceMode);
frmBusiness->IsPreview=false;


}
回复 点赞
夏夜倒骑驴 2004年06月28日
系统打印机的纸张选择应正确设置,最好新建一自定义纸张,将默认纸张为自定义纸张,
该方法未试,不能确定是否会解决问题
回复 点赞
编译失败 2004年06月25日
也许打了空行
回复 点赞
ccwenwen 2004年06月25日
好像没有打空行啊
本来应该打半张a4的,居然打一次就空走半张
各位大侠救我啊,急~~
回复 点赞
发动态
发帖子
数据库及相关技术
创建于2007-08-02

707

社区成员

1.8w+

社区内容

C++ Builder 数据库及相关技术
社区公告
暂无公告