大家介绍一些资料吧,最近在做票据打印的软件,但网上、书店找了很久,关于这方面的书籍实在很少。报表打印的到有不少,可我要的是输入一些要素,然后打印有固定格式的空白的票据(比如支票、在银行填写的空白存款单),带一些简单的数据库功能。帮我看看有什么好的资料,最好是VB或者DELPHI方面的,谢谢

解决方案 »

  1.   

    以下是我的打印单元里的东西,你可以看看 目前我正在忙没有时间给你写过多的注释,有问题可以联系
    Unit USysPrinter_5;
    { 国际货物运输代理 }Interface
    Uses
      Windows,
      Messages,
      SysUtils,
      Variants,
      Classes,
      Printers,
      IniFiles,
      Forms;Type  TSysPrinter_5 = Class
      Private    FpstX_Charge5: Integer;
        FpstY_Charge5: Integer;
        FpstX_Bank: Integer;
        FpstY_Bank: Integer;    FPaperLen: Integer;  
        FPaperWid: Integer;    Fstr_Bank: String;
        Fstr_Charge5: String;
        Procedure SetPaperLen(Const Value: Integer);
        Procedure SetPaperWid(Const Value: Integer);    Procedure SetpstX_Bank(Const Value: Integer);    Procedure SetpstX_Charge5(Const Value: Integer);    Procedure SetpstY_Bank(Const Value: Integer);    Procedure SetpstY_Charge5(Const Value: Integer);
        Procedure Setstr_Bank(Const Value: String);    Procedure Setstr_Charge5(Const Value: String);
      Public
        { 读出、保存设置 }
        Procedure LoadConfig();
        Procedure SaveConfig();
        { 打印发票 }
        Function PrintMe(): Boolean;    { 发票长度 }
        Property PaperLen: Integer Read FPaperLen Write SetPaperLen;
        { 发票宽度 }
        Property PaperWid: Integer Read FPaperWid Write SetPaperWid;    { 银行 }
        Property pstX_Bank: Integer Read FpstX_Bank Write SetpstX_Bank;
        Property pstY_Bank: Integer Read FpstY_Bank Write SetpstY_Bank;    { 帐号 }
        { 付款单位 }
       { 开票日期 }
         { 船名、航次、航班、车次 }
          { 提单号 }
         { 开航日期 }
          { 起运港 }
         { 卸货港 }
         { 目的港 }
         { 经营项目 1~~~5 }    Property pstX_Charge5: Integer Read FpstX_Charge5 Write SetpstX_Charge5;
        Property pstY_Charge5: Integer Read FpstY_Charge5 Write SetpstY_Charge5;    { 备注 }
         { 金额大写 }
         { 合计 }
         { 税务登记号 }
      
        { 税控装置号 }
     
        { 制单 }
     
        { 机打票号 }
        { 工商登记号 }
     
        { 复核 }
     
        { 税控装置防伪码 }
      
        { 支票 }
      
        { 送打印内容 }
        Property str_Bank: String Read Fstr_Bank Write Setstr_Bank;
        Property str_Charge5: String Read Fstr_Charge5 Write Setstr_Charge5;
      End;Var
      SysPrinter_5: TSysPrinter_5;ImplementationUses
      USysInfo;{ TSysPrinter_5 }Procedure TSysPrinter_5.LoadConfig;
    Var
      IniFile: TIniFile;
    Begin
      IniFile:= TIniFile.Create(SysInfo.IniFileName);  Try
        { 纸张长度 }
        PaperLen:= IniFile.ReadInteger('PRINT_INFO_5', 'PAPER_LENGTH', 0);
        { 纸张宽度 }
        PaperWid:= IniFile.ReadInteger('PRINT_INFO_5', 'PAPER_WIDTH', 0);    { 经营项目 1~~~5 }
         pstX_Charge5:= IniFile.ReadInteger('PRINT_INFO_5', 'CHARGE5_X', 0);
        pstY_Charge5:= IniFile.ReadInteger('PRINT_INFO_5', 'CHARGE5_Y', 0);  Finally
        IniFile.Free;
      End;
    End;Function TSysPrinter_5.PrintMe: Boolean;
    Var
      PrnDevice, PrnDriver, PrnPort: Array[0..255] Of Char;
      PrnHandle: THandle;
      PrnMode: PDeviceMode;
      i, line, prnline, H: integer;
      StrTemp: String;
    Begin
      Result:= False;  { 设定打印参数 }
      Try
        Printer.GetPrinter(PrnDevice, PrnDriver, PrnPort, PrnHandle);
      Except
        MessageBox(Application.Handle, '无法获取系统打印机信息!', '系统信息',
          MB_OK + MB_ICONINFORMATION);
        Exit;
      End;  If PrnHandle = 0 Then
        Begin
          MessageBox(Application.Handle, '无法获取系统打印机信息!', '系统信息',
            MB_OK + MB_ICONINFORMATION);
          Exit;
        End
      Else
        Begin
          PrnMode:= GlobalLock(PrnHandle);
          With PrnMode^ Do
            Begin
              //打印份数
              dmFields:= dmFields Or dmCopies;
              dmCopies:= 1;          //打印方向
              dmFields:= dmFields Or dmOrientation;
              dmOrientation:= DMORIENT_PORTRAIT;          //纸张大小
              dmFields:= dmFields Or dmPaperSize;
              dmPaperSize:= DMPAPER_USER;          dmFields:= dmFields Or dmPaperWidth;
              dmPaperWidth:= PaperWid;          dmFields:= dmFields Or dmPaperLength;
              dmPaperLength:= PaperLen;          dmFields:= dmFields Or PrnMode^.dmLogPixels;
              dmLogPixels:= 300;          ResetDC(Printer.Handle, PrnMode^);
            End;
        End;  { 开始打印 }
      Try
        Printer.Canvas.Font.Name:= SysInfo.PrnFont;
        Printer.Canvas.Font.Size:= SysInfo.PrnSize;    Printer.BeginDoc;
        h:= Printer.Canvas.TextHeight(str_Bank);
        If length(str_Bank) > 24 Then
          Begin
            prnline:= length(str_Bank) Div 24;        StrTemp:= str_Bank;
            For i:= 1 To prnline Do
              Begin
                If (ByteType(copy(StrTemp, 1, 24), 24) = mbSingleByte) //判断最后一个字节
                Or (ByteType(copy(StrTemp, 1, 24), 24) = mbTrailByte) Then
                  Begin //单字母 //双字节中第二位    //直接打印
                    Printer.Canvas.TextOut(pstX_Bank, pstY_Bank +
                      (i - 1) * h + 1, copy(StrTemp, 1, 24));
                    StrTemp:= copy(StrTemp, 25, Length(StrTemp) - 24);
                  End
                Else
                  If ByteType(copy(StrTemp, 1, 24), 24) = mbLeadByte Then //双字节中第一位
                    Begin //留下一行打印
                      Printer.Canvas.TextOut(pstX_Bank, pstY_Bank +
                        (i - 1) * h + 1, copy(StrTemp, 1, 23));
                      StrTemp:= copy(StrTemp, 24, Length(StrTemp) - 23);
                    End;
              End;
            i:= length(str_Bank) Div 24;
            Printer.Canvas.TextOut(pstX_Bank, pstY_Bank + i * h
              + i, StrTemp);
          End
        Else
          Printer.Canvas.TextOut(pstX_Bank, pstY_Bank, str_Bank);
        Printer.Canvas.TextOut(pstX_Item5, pstY_Item5, str_Item5);
        Printer.Canvas.TextOut(pstX_Charge5, pstY_Charge5, str_Charge5);
    ///////////////////////////////////////////////////////////////////////    Printer.EndDoc;
        Result:= True;
      Except
        MessageBox(Application.Handle,
          '无法处理打印信息,请确定打印机驱动程序安装正确!', '系统信息', MB_OK +
          MB_ICONINFORMATION);
        Exit;
      End;
    End;Procedure TSysPrinter_5.SaveConfig;
    BeginEnd;Procedure TSysPrinter_5.SetPaperLen(Const Value: Integer);
    Begin
      FPaperLen:= Value;
    End;Procedure TSysPrinter_5.SetPaperWid(Const Value: Integer);
    Begin
      FPaperWid:= Value;
    End;Procedure TSysPrinter_5.SetpstX_Bank(Const Value: Integer);
    Begin
      FpstX_Bank:= Value;
    End;
    Procedure TSysPrinter_5.SetpstY_Bank(Const Value: Integer);
    Begin
      FpstY_Bank:= Value;
    End;
    Procedure TSysPrinter_5.SetpstX_Charge5(Const Value: Integer);
    Begin
      FpstX_Charge5:= Value;
    End;
    Procedure TSysPrinter_5.SetpstY_Charge5(Const Value: Integer);
    Begin
      FpstY_Charge5:= Value;
    End;
    Procedure TSysPrinter_5.Setstr_Bank(Const Value: String);
    Begin
      Fstr_Bank:= Value;
    End;Procedure TSysPrinter_5.Setstr_Charge5(Const Value: String);
    Begin
      Fstr_Charge5:= Value;
    End;Initialization
      SysPrinter_5:= TSysPrinter_5.Create;
    Finalization
      SysPrinter_5.Free;End.