Giter VIP home page Giter VIP logo

rsprint's Introduction

RSPrint

A Delphi component for matrix printing using device’s native commands.

With this component, you can print in matrix printers using draft mode – high speed.

You can use it to fill easily documents like orders, invoices and others that are previous made in off-set.

Delphi and platform compatibility

This component was tested on Delphi XE. I think it’ll run withiout problem in above versions.

It’s running just under Microsoft Windows.

How to Install

See here in the wiki’s project.

Contributing

We encourage you to contribute to RSPrint!

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am ‘Add some feature’`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

About original RSPrint

A variety of versions of this component can be found on Internet.

Unfortunately there isn’t (or there wasn’t) an official repository to it. And it was very dificult to discover who was the original author.

So, I found Mr. Saverio Vertoni who told me that was the author. I told him about my plans of maintaining the project and he donated me the source.

The original source-code can be found here in the v2.0.0.original tag.

License

RSPrint is released under the MIT License.

rsprint's People

Contributors

cesarjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rsprint's Issues

[patch] Add the pagination feature

Hello,

This patch add the pagination feature. Feel free to changing it:

From 6750de2a86dbd2c58842c28fcd9f719e47a46290 Mon Sep 17 00:00:00 2001
From: silvioprog <[email protected]>
Date: Tue, 24 Nov 2015 18:19:42 -0300
Subject: [PATCH 1/1] Add the pagination feature.

---
 Component/RSPrint.pas | 70 +++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 60 insertions(+), 10 deletions(-)

diff --git a/Component/RSPrint.pas b/Component/RSPrint.pas
index 10bee8a..acdf7a5 100644
--- a/Component/RSPrint.pas
+++ b/Component/RSPrint.pas
@@ -4,7 +4,8 @@ interface

 uses
   Windows, Messages, SysUtils, CommDlg, Classes, Graphics, Controls, ExtCtrls, StdCtrls, Consts, ShellAPI, Menus,
-  Printers, ComCtrls, Forms, Dialogs, RSPrint.Types.CommonTypes, RSPrint.Types.Document, Generics.Collections;
+  Printers, ComCtrls, Forms, Dialogs, RSPrint.Types.CommonTypes, RSPrint.Types.Document, Generics.Collections,
+  System.UITypes;

 type
   TRSPrinter = class(TComponent)
@@ -26,6 +27,8 @@ type
     FZoom: TInitialZoom;
     FWinPrinter: string;        // NOMBRE DE LA IMPRESORA EN WINDOWS
     FCancelado: Boolean;
+    FCurrLine: Cardinal;
+    FPaginated: Boolean;

     function GetModelRealName(model: TPrinterModel): string;
     procedure SetModel(name: TPrinterModel);
@@ -82,9 +85,18 @@ type
     procedure Print;
     procedure PrintAll;

-    procedure Write(line, col: Byte; text: string);
-    procedure WriteFont(line, col: Byte; text: string; font: TFastFont);
-    procedure NewPage;
+    procedure Write(line, col: Byte; const text: string); overload; virtual;
+    procedure Write(line, col: Byte; const text: string;
+      ALineFeed: Boolean); overload; virtual;
+    procedure Write(col: Byte; const text: string;
+      ALineFeed: Boolean); overload; virtual;
+    procedure Write(col: Byte; const text: string); overload; virtual;
+
+    function WriteFont(line, col: Byte; const text: string;
+      font: TFastFont): Boolean; overload; virtual;
+    procedure WriteFont(line, col: Byte; const text: string; font: TFastFont;
+      ALineFeed: Boolean); overload; virtual;
+    procedure NewPage; virtual;

     procedure DrawMetafile(col, line: Single; picture: TMetafile);

@@ -92,7 +104,7 @@ type
     procedure LineH(line, col1, col2: Byte; kind: TLineType);
     procedure LineV(line1, line2, col: Byte; kind: TLineType);

-    procedure SetModelName(name: string);
+    procedure SetModelName(const name: string);
     function GetModelName: string;
     procedure GetModels(models: TStrings);

@@ -104,6 +116,7 @@ type
     property WinPrinter: string read FWinPrinter write FWinPrinter;
     property PageNo: Integer read GetCurrentPageNumber;

+    property CurrLine: Cardinal read FCurrLine;
   published
     property PageContinuousJump: Byte read GetPageContinuousJump write SetPageContinuousJump default 5;
     property PageSize: TPageSize read GetPageSize write SetPageSize;
@@ -123,6 +136,7 @@ type
     property Transliterate: Boolean read GetTransliterate write SetTransliterate default True;
     property WinMarginTop: Integer read FWinSupMargin write FWinSupMargin default 0;
     property WinMarginBottom: Integer read FWinBotMargin write FWinBotMargin default 0;
+    property Paginated: Boolean read FPaginated write FPaginated;
   end;

 procedure Register;
@@ -149,6 +163,8 @@ begin
   if (AOwner is TForm) and not (csDesigning in ComponentState) then
     FOwner := TForm(AOwner);

+  FCurrLine := 1;
+
   FColumnas := 80;
   FZoom := zWidth;

@@ -433,12 +449,14 @@ begin
   FDocument.ClearPages;
 end;

-procedure TRSPrinter.WriteFont(line, col: Byte; text: string; font: TFastFont);
+function TRSPrinter.WriteFont(line, col: Byte; const text: string;
+  font: TFastFont): Boolean;
 var
   Escritura: TWrittenText;
   P: Integer;
 begin
-  if FDocument.Pages.Count > 0 then
+  Result := FDocument.Pages.Count > 0;
+  if Result then
     begin
       P := 0;

@@ -466,9 +484,40 @@ begin
     end;
 end;

-procedure TRSPrinter.Write(line, col: Byte; text: string);
+procedure TRSPrinter.Write(line, col: Byte; const text: string);
+begin
+  WriteFont(line, col, text, FDocument.DefaultFont, False);
+end;
+
+procedure TRSPrinter.Write(line, col: Byte; const text: string;
+  ALineFeed: Boolean);
 begin
-  WriteFont(line, col, text, FDocument.DefaultFont);
+  WriteFont(line, col, text, FDocument.DefaultFont, ALineFeed);
+end;
+
+procedure TRSPrinter.Write(col: Byte; const text: string; ALineFeed: Boolean);
+begin
+  WriteFont(FCurrLine, col, text, FDocument.DefaultFont, ALineFeed);
+end;
+
+procedure TRSPrinter.Write(col: Byte; const text: string);
+begin
+  WriteFont(FCurrLine, col, text, FDocument.DefaultFont, False);
+end;
+
+procedure TRSPrinter.WriteFont(line, col: Byte; const text: string;
+  font: TFastFont; ALineFeed: Boolean);
+begin
+  if WriteFont(line, col, text, font) and ALineFeed then
+  begin
+    if FPaginated and (FCurrLine = Lines) then
+    begin
+      FCurrLine := 1;
+      NewPage;
+    end
+    else
+      Inc(FCurrLine);
+  end;
 end;

 procedure TRSPrinter.DrawMetafile(col, line: Single; picture: TMetafile);
@@ -1081,10 +1130,11 @@ end;

 procedure TRSPrinter.NewPage;
 begin
+  FCurrLine := 1;
   FDocument.NewPage;
 end;

-procedure TRSPrinter.SetModelName(name: string);
+procedure TRSPrinter.SetModelName(const name: string);
 begin
   if FMode = pmWindows then
   begin
-- 
1.9.5.msysgit.0

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.