このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


Long vers Hardcopy from Lazarus HOME - - - - - Lazarus Tutorials TOC - - - - - - Other 構成要素 for programmers

Hardcopy

Creating 署名/調印する-on-paper with Lazarus

This page's URL: lt3Nhardcopy.htm

If you 港/避難所't already been there, I would 示唆する that you start with my newer SheepdogGuides page about getting hardcopy from Lazarus. I derived that from this page, so in some ways it is better.. but if you've already been there, this page has more 詳細(に述べる) than it does.

You don't even have to "支払う/賃金s your money" to "take your 選ぶ." But some について言及するs of either page by you in 会議s, social マスコミ, etc would be 極端に welcome!

=================
This was created somewhat in あわてて... sorry... but I 設立する a few errors in the さもなければ excellent "公式の/役人" guide... Freepascal.org's 'Using the printer' page... 井戸/弁護士席, as it stood 21 Jul 19, when I was using Windows 10 and Lazarus 2.0.0, FPC vers 3.0.4. They were "minor" errors... but enough to be annoying つまずくing 封鎖するs.

I 設立する the page a bit daunting, at first, but it really isn't bad at all. In particular, it is 井戸/弁護士席 sequenced, taking you from "getting started" to "doing the fancy stuff".

存在 human, I hoped I could get away with not doing the "追加する Printer4Lazarus" step. I couldn't. The 指示/教授/教育s on Freepascal.org's 'Using the printer' page worked perfectly for me. Here they are, in a more terse form. (Go to the Freepascal.org page, 特記する/引用するd above, if in any 疑問.)

(We're told: "The Printer4Lazarus 一括 defines a basic printer and 供給するs 壇・綱領・公約-独立した・無所属 printing."

I take that to be 説 that Printer4Lazarus is "middleware", to make our lives easier, if we port a Lazarus program どこかよそで. 公式文書,認める that you still need it, even if you work in only 環境, say, Windows. And also 公式文書,認める that it isn't an 任命する/導入するd part of the "default" 一括, at least at 20 Jul 19, though the 構成要素 was already on my machine, ready to be 任命する/導入するd, 7/19, when it almost certainly was there from my basic Lazarus "任命する/導入する".

Something not on the Freepascal page!

I was puzzled by the use of "Printer", as an 反対する, in some of the デモ code from Freepascal.

It give me 蜂の巣s to use something I do not understand. Where did "Printer" come from?? At www.delphibasics.co.uk/Article.asp?指名する=Printing we are told " The Printer 反対する is 永久的に 利用できる to your code (you must put the Printers 部隊 in your "Uses" 条項 to get 接近 to its methods and fields though). With this 反対する, printing proceeds in an 整然とした fashion.". (There's more good stuff there, by the way.) (There's also Good Stuff at www.delphibasics.co.uk/RTL.asp?指名する=printer)

支援する to a run through Freepascal's advice, with 是正s

I will not fault the text from Freepascal. There were just a few "typo-like" errors that I would point out.

I started with their first example. It doesn't do much, but always best to walk before running...

I built a tiny 事業/計画(する) called syv02. It consisted of a form with just a button on it. The button's Click handler was the に引き続いて, taken from Freepascal's Using The Printer page...

手続き Tsvy02f1.Button1Click(Sender: TObject);
const
  LEFTMARGIN = 100;
  HEADLINE = 'I Printed My Very First Text On ';
var
  YPos, LineHeight, VerticalMargin: Integer;
  SuccessString: String;
begin
  with Printer do
  try
    BeginDoc;
    Canvas.Font.指名する := '特使 New';
    Canvas.Font.Size := 10;
    Canvas.Font.Color := clBlack;
    LineHeight := 一連の会議、交渉/完成する(1.2 * Abs(Canvas.TextHeight('I')));
    VerticalMargin := 4 * LineHeight;
    // There we go
    YPos := VerticalMargin;
    SuccessString := HEADLINE + DateTimeToStr(Now);
    Canvas.TextOut(LEFTMARGIN, YPos, SuccessString);
  finally
    EndDoc;
  end;
end;

Don't forget to 追加する "Printers" to your 事業/計画(する)'s Uses 条項. (I don't know why "HEADLINE" and "LEFTMARGIN were done ALL IN UPPERCASE. Probably unnecessary, but I 港/避難所't got time to check that just now.

App 収集するd and ran without 出来事/事件, and worked as 推定する/予想するd, first time. (Put two lines of text at the 最高の,を越す of a page spat out by my printer as soon as I clicked on my button. It just sends it to the 現在の system default printer, even if that is printing across a LAN. More on this later.)

IF IT DOESN'T work, first time, for you, don't be alarmed. Did you get something like...

Error... exception class '外部の: SIGSEGV'.
In とじ込み/提出する 'printers.pas'...
result:=(pfPrinting in fFlags)

?? If got that... or anything について言及するing SIGSEGV... skip 負かす/撃墜する the page a bit to the section with more on this. You probably only need to 追加する two lines ("2a" and "2b") and then you can come 支援する here.

(That's 罰金, to 押し進める a 完全にするd page of text to your printer. (Years ago, I wrote other help pages here at "Lut" (Lazarus tUTorials), and/ or over at my Delphi tutorials about working with... or was it emulating?... line printers.)

Jan 2021 I "read on the internet" that maybe you need the osPrinters 一括, too. At least under Windows, I couldn't find that but DID find that with the 直す/買収する,八百長をする I've explained below the code 作品 罰金 for me.

Moving on

罰金. We can do text. 公式文書,認める: We are already "doing graphics"... the text is put の上に a field of pixels, and that is what gets printed.

The second デモ on the page....

  MyPrinter.BeginDoc;
    page.PaintTo(myPrinter.Canvas, 0, 0);
  MyPrinter.EndDoc;

... very nearly 作品.

(An aside: I didn't like "page" as the 指名する for a パネル盤, but I have left it thus.)

Be sure you 始める,決める up the small 名簿(に載せる)/表(にあげる) things 要求するd, explained on Freepascal's page just above the code. Not least, a パネル盤, "page", 持つ/拘留するing some TShape 反対する. (Make the パネル盤 it is on (Panel1) about 190x 190, so that "page" can be about 140x140, and Shape1 about 100x100. ("Panel1" is an unnecessary "frill", I think, but I am trying to stick to example).

A "Gotcha"... 早期に in my 成果/努力s, I thought the code "wasn't working". It was... but the image on my hardcopy was so small, and in such a light shade of gray, that I was overlooking what was on the sheet of paper 配達するd from my printer. (Make your TShape 反対する DARK... Shape1.小衝突.color:=clRed. You would probably do this with the GUI, but to を強調する the importance, I've done it in code, in the FormCreate subroutine, to "make it 明白な" for you. Line 示すd "直す/買収する,八百長をする 所有物/資産/財産 1".)

If you do what the page calls for, when you try to 収集する, you should get "Error: Identifier not 設立する: MyPrinter"

The first part of the 直す/買収する,八百長をする for that is the two lines 示すd "直す/買収する,八百長をする 1" in the に引き続いて. Don't, by the way, "put in" the other "直す/買収する,八百長をする" and "直す/買収する,八百長をする 所有物/資産/財産" lines until they are called for, if you want to work through this story as you read along.

手続き TForm1.FormCreate(Sender: TObject);
begin
  Shape1.小衝突.color:=clRed; //直す/買収する,八百長をする 所有物/資産/財産 1
  page.color:=clMedGray; //直す/買収する,八百長をする 所有物/資産/財産 2
end;

手続き TForm1.Button1Click(Sender: TObject);
var MyPrinter : TPrinter; //直す/買収する,八百長をする 1a
begin
  if PrintDialog1.遂行する/発効させる then begin //直す/買収する,八百長をする 2a
    MyPrinter:= printer; //直す/買収する,八百長をする 1b
    MyPrinter.BeginDoc;
      //page.PaintTo(MyPrinter.Canvas, 0, 0); //初めの
      page.PaintTo(MyPrinter.Canvas, 50, 50);//直す/買収する,八百長をする 3
    MyPrinter.EndDoc;
  end;//直す/買収する,八百長をする 2b
end; 

公式文書,認める also that some inconsistencies in capitalization have been tidied up... some "myPrinter"s made "MyPrinter".

That should 収集する, and "run"... but when you click on the button, you may, いつかs, get...

Error... exception class '外部の: SIGSEGV'.
In とじ込み/提出する 'printers.pas'...
result:=(pfPrinting in fFlags)

At the same time, the code for "printers.pas" will open in your source code editor. (権利-click on it, elect "の近くに page", before you inadvertently make changes!)

I have no idea what this is, where it comes from. Maybe a printer that is 現在/一般に on low 現在の 代替要員,物?

But the に引き続いて made it go away for me...

Run the app again. This time, just before it tries to print, you'll get the probably-familiar dialog about what printer you want to use, etc. Usually, you'd just click on the "okay" button on that to proceed.

(半端物, but true... I was able to rem those two lines out again, once I'd run the code once with them in. The app would, for now at least for a time, still run! Best, for a host of 推論する/理由s, to leave them in, methinks.)

That worked BETTER... I now got a sheet out of my printer- a blank sheet.

Now... as I hinted 以前, what you see on the paper may not be as large as what you see on your 審査する. So maybe the 生産(高) is very small, and is "lost" in the 利ざや of the page, if your printer can't print all the way to the 辛勝する/優位 of the page?

The "直す/買収する,八百長をする 3" 代案/選択肢 to...

page.PaintTo(MyPrinter.Canvas, 0, 0);

...changes the 0,0 to 50,50. this may be a good idea, anyway... but didn't 直す/買収する,八百長をする the "gives blank sheet" problem.

The Secret 成分

I have no idea why, but if you 追加する what is 示すd as "直す/買収する,八百長をする 所有物/資産/財産 2" to the code as it now stands, the app "作品".

On my system (it will 変化させる, depending on system settings), that, from a "page" that was 140x140, results in a 6mm x 6mm hardcopy of what was on the 審査する. (The 直す/買収する,八百長をする called "3" (changing the paint 相殺する to 50,50) probably 事柄d, too.

Don't despair! Remember that the page this trys to 完全にする says that this approach is just a 行う/開催する/段階 on the 旅行. You 生産(高) will not always be tiny! And we 港/避難所't far to go to reach the ultimate goal of all of this.

Re-read the "前進するd steps: printing 支配(する)/統制するs" section of Freepascal.org's 'Using the printer' page. Did I 行方不明になる something that would explain why the background color has to be "poked"? While the default background may 井戸/弁護士席 have printed as white, I can see no 推論する/理由 why I didn't get the image of the TShape, with it's 黒人/ボイコット 輪郭(を描く) and dark 中心 in my hardcopy until after....

page.color:=clMedGray; //直す/買収する,八百長をする 所有物/資産/財産 2

...was 追加するd.

The 見解/翻訳/版 with re-sizing....

At Freepascal.org's 'Using the printer' page, 近づく the 底(に届く), under "And on we go: Resizing", there is some stuff you should read.

The に引き続いて is what I ended up with, when I tried to use the final bit of code (FBOC) on that page.

When you click Button1, the app takes whatever you've put on a パネル盤. (In the FBOC, it was the パネル盤 指名するd "page", in my code it is the パネル盤 指名するd "Panel1" ("パネル盤 One"). You can, of course, use all sorts of 命令(する)s to put things on the パネル盤. (As illustrated in the Click handler for Button2.)

It takes what is on that パネル盤, and copies it の上に a part of the canvas of the MyPrinter 反対する.

It then prints the page that you 用意が出来ている... It prints what's on the canvas of the MyPrinter 反対する.

The code got a bit "messy" because I didn't want the hardcopy of what was on the 審査する to (*try to) go all of the way to the 辛勝する/優位s of the paper. AND I 手配中の,お尋ね者 to save toner, so not only did I 供給する 利ざやs, I also said "don't use the 十分な width or 高さ of the page.

Read the 内部の documentation about the need to keep 面 割合s constant, if you don't want the hardcopy to be a distorted image of what was on the 審査する.

My code derives from the FBOC on the FreePascal page. It hasn't really deviated, or been developed, very far. Some of the tweaks and gotcha-直す/買収する,八百長をするs explained before we got to "The 見解/翻訳/版 with re-sizing...." have been 会社にする/組み込むd without repeated comment.

部隊 Demo3u1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, 支配(する)/統制するs, Graphics, Dialogs, StdCtrls, ExtCtrls,
  PrintersDlgs, printers;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Panel1: TPanel;
    PrintDialog1: TPrintDialog;
    Shape1: TShape;
    手続き Button1Click(Sender: TObject);
    手続き Button2Click(Sender: TObject);
    手続き FormCreate(Sender: TObject);
  私的な

  public

  end;

var
  Form1: TForm1;

実施

{$R *.lfm}

{ TForm1 }

手続き TForm1.FormCreate(Sender: TObject);
begin
  Shape1.小衝突.color:=clRed;
  Panel1.Color:=clMedGray;
  Panel1.BorderStyle:=bsNone;//A perhaps-unnecessary "frill"
  Panel1.BorderStyle:=bsSingle;//A perhaps-unnecessary "frill"
end;

手続き TForm1.Button1Click(Sender: TObject);
  var
  myPrinter : TPrinter;
  myBitMap : TBitMap;

begin
  if PrintDialog1.遂行する/発効させる then begin (*See 公式文書,認めるs re- the second デモ...
         If this is absent, the app いつかs fails.*)
      myBitMap := TBitMap.Create;
      myBitMap.Width := Panel1.Width;
      myBitMap.高さ := Panel1.高さ;(*N.B.- I have dispensed with the
        "パネル盤 on a a パネル盤" used in the FreePascal.org page *)

      Panel1.PaintTo(myBitMap.Canvas, 0, 0);//Put what's on the パネル盤 の上に the bitmap

      myPrinter := Printer;
      myPrinter.BeginDoc;

        //"xx.CopyRect.." copies TO 反対する "xx"
        //CopyRect 明示するs DESTINATION first, then source
        myPrinter.Canvas.CopyRect(
             //copy TO -part of- MyPrinter.canvas...
             //Without the "div 2", and 利ざや creators, what was on
             //  Panel1 would be printed, trying to use the whole area
             //  of what the printer thinks is the paper 利用できる to it.

             //If the 形態/調整 you CopyRect to has a different 面 割合
             //  than Panel1 had, the graphics from Panel1 will be distorted.
             //  All there... but stretched in one direction or the other.
             Classes.Rect(10,10,//Create 利ざやs, to left and above
                   (myPrinter.PaperSize.Width div 2)-12, //-12: 利ざや on 権利
                   (myPrinter.PaperSize.Width div 2)-12),//-12: 利ざや at 底(に届く)
                     //N.B.: WIDTH on 目的... to keep printing area
                     //  square. For now, paPage and myBitMap are also square
             //copy from the に引き続いて...
             myBitMap.Canvas,
             //copy the に引き続いて part of myBitMap...
             Classes.Rect(0, 0, myBitMap.Width,
                                       myBitMap.高さ));
        //If from/to have different 面 割合s, CopyRect will stretch
        //  an axis.

      myPrinter.EndDoc;
      myBitMap.解放する/自由な;
  end;// if PrintDialog...
end;

手続き TForm1.Button2Click(Sender: TObject);
begin
   Panel1.canvas.pen.color:=clBlack;
   Panel1.canvas.moveto(30,30);
   Panel1.canvas.lineto(60,90);
end;

end.

I hope that helped?

I hope that was useful? If so, I would be 感謝する for について言及する of this tutorial in web discussions?

If it fails to work for you, please let me know? (接触する 詳細(に述べる)s below.) Please 特記する/引用する "Lazarus tutorial lt3Nhardcopy.htm". Even better, if it doesn't QUITE work, but you solved your own problem, please let me know... to spare the next person the hassle you had?





Search across all my 場所/位置s with the Google search...

Custom Search
            力/強力にするd by FreeFind
  場所/位置 search Web search
場所/位置 地図/計画する    What's New    Search This search 単に looks for the words you enter. It won't answer "Where can I download InpOut32?"
広告 from page's editor: Yes.. I do enjoy 収集するing these things for you. I hope they are helpful. However... this doesn't 支払う/賃金 my 法案s!!! Sheepdog ソフトウェア (tm) is supposed to help do that, so if you 設立する this stuff useful, (and you run a Windows or MS-DOS PC) please visit my freeware and shareware page, download something, and 循環させる it for me? Links on your page to this page would also be 高く評価する/(相場などが)上がるd!
Click here to visit editor's freeware, shareware page.

Link to Lazarus Tutorials main page
How to 接触する the editor of this page, Tom Boyd


Valid HTML 4.01 Transitional Page has been 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes.

AND passes... Valid CSS!

If this page 原因(となる)s a script to run, why? Because of things like Google パネル盤s, and the code for the search button. Why do I について言及する scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....