|
このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a 狭くする window. With most browsers, 圧力(をかける)ing 加える, minus or 無 while the 支配(する)/統制する 重要な (ctrl) is held 負かす/撃墜する will change the texts size. (大きくする, 減ずる, 回復する to default, それぞれ.) (This is more fully explained, and there's another tip, at my 力/強力にする Browsing page.)
Want to 令状 a Lazarus 使用/適用 which will 原因(となる) a printer to spit out some hardcopy?
You've come to the 権利 place!
And if this page doesn't give you what you want, it may be 価値(がある) going to an earlier essay I wrote on getting hardcopy from Lazarus. In that earlier essay I covered some 詳細(に述べる)s I've left out of this more 簡素化するd page.
Start at... wiki.freepascal.org's "Using The Printer".
And yes, Virginia, you "need" the Printer4Lazarus" 一括. At 8 Jan 21, Win10, Lazarus vers 2.0.0 of 28 Nov 2020 I 設立する that it was already 任命する/導入するd on the PC I was using when 準備するing this tutorial. (Reviewed 2 Oct 21, same 環境.)
To see if you have it: From Lazarus IDE main menu: 一括s/ 任命する/導入する-Uninstall 一括s, and ざっと目を通す the "任命する/導入する" 覚え書き.
You should see something like the に引き続いて...
... which, in my mind, gives rise to three mysteries...
First mystery: Did I 任命する/導入する this by 手渡す some time ago? It would have been before I 任命する/導入するd vers 2.0.0. Was it carried over? Or did it come "as 基準" when I updated my Lazarus to vers 2.0.0? Whatever.
Second mystery: Why is the left 手渡す 名簿(に載せる)/表(にあげる) of 一括s, in the 覚え書き, below a パネル盤 肩書を与える 説 "任命する/導入する"? These seem to be the already 任命する/導入するd 一括s! Oh 井戸/弁護士席. Whatever. My PC seems to have the 一括, so I won't be able to take you through how to 任命する/導入する it.
Third mystery: What is that "printers4lazide 0.0" we can also see in the 名簿(に載せる)/表(にあげる)? (I don't know. I "let that one go".)
Sigh. Onward...
Remember: This is meant to be the "short form" 見解/翻訳/版 of how to create hardcopy from a Lazarus 使用/適用. Finish this, and if you are still not where you want to be, try this tutorial's ancestor... which has some overlap, I 恐れる, but also has 詳細(に述べる)s I've left out of this "concise" 小旅行する.
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)
I started with the first example on FreePascal's "Using The Printer". It doesn't do much, but always best to walk before running...
I built a tiny 事業/計画(する) called svy002. 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.
My little starting point had JUST what was on the FreePascal page. That threw a "SIGSEGV" error. I spent an hour Jan 2021 struggling with that before finding the answer in my own page. (I will give you the answer in a moment!). I "read on the internet" that maybe you need the osPrinters 一括, too. At least under Windows, I couldn't find the 一括, but the code worked 罰金 without it... if you've used the "直す/買収する,八百長をする" explained below.
What you see below is VERY NEARLY the code on the FreePascal page. But I've...
Also be advised, nota bene: The に引き続いて won't work unless you have 追加するd "Printer4Lazarus" 一括 to your IDE, and 追加するd "Printers" to the 事業/計画(する)'s Uses 条項. (This is nothing exotic. Just a normal optional 一括, and use thereof.)
Obvious? The form needs a button. This is the mouse click event handler for that. (It might be better to 令状 this as a 手続き called PrintAPage, and 始める,決める up a button which 単に calls PrintAPage. That bit of "divide and 征服する/打ち勝つ" is perhaps overkill here. 減少(する) the "(Sender: TObject)" if you create a PrintAPage 手続き.
As について言及するd a moment ago, the form needs a TPrintDialog 構成要素 called PrintDialog1.
手続き Tsvy002f1.Button1Click(Sender: TObject);
const
kLeftmargin = 100;
kHeadline = 'I Printed My Very First Text On ';
var
YPos, LineHeight, TopMargin: Integer;
SuccessString: String;
begin
if PrintDialog1.遂行する/発効させる then begin //SIGSEGV 直す/買収する,八百長をする- 1 of 2 lines
with Printer do
try
//準備する the "paper"...
BeginDoc;
Canvas.Font.指名する := '特使 New';
Canvas.Font.Size := 10;
Canvas.Font.Color := clBlack;
LineHeight := 一連の会議、交渉/完成する(1.2 * Abs(Canvas.TextHeight('I')));
TopMargin := 4 * LineHeight;
//Put 令状ing on it...
YPos := TopMargin;
SuccessString := kHeadline + DateTimeToStr(Now);
Canvas.TextOut(kLeftmargin, YPos, SuccessString);
finally //If all of the above 完全にするd okay,
//"EndDoc" will 誘発する/引き起こす the actual printing...
EndDoc;
end; //of "try... finally..."
end; //SIGSEGV 直す/買収する,八百長をする- 2 of 2 lines
end; //Button1Click
The 使用/適用 結局 収集するd and ran and worked as 推定する/予想するd: It spits a page out of my printer as soon as I click my button and 確認する which printer to send the page to. The page had two lines of text at its 最高の,を越す. (It could be written to run すぐに on some systems I 嫌疑者,容疑者/疑う but 地雷 needed the PrintDialog1.遂行する/発効させる to 避ける the SIGSEGV error.)
Digression: Here's an even SIMPLER 見解/翻訳/版, with even more of the distractions 削減(する) away... You still need "Printer4Lazarus", but that's all you need aside from a button to run the code.
手続き 試みる/企てるd;
begin
if PrintDialog1.遂行する/発効させる then begin//To 妨げる SIGSEGV error
with Printer do
try
BeginDoc;
Canvas.Font.指名する := '特使 New';
Canvas.Font.Size := 10;
Canvas.Font.Color := clBlack;
Canvas.TextOut(10,10,'xxx');
finally
EndDoc;
end;//of "try.."
end;//If Pri..
end;//PrintAPageSimply
(This is 罰金 to 押し進める a whole, 完全にするd page of text to your printer. That's all you can do with most ありふれた printers at 2020 and earlier. (You can buy the other sort, a "line printer"... look for printers ーするつもりであるd for things like cash 登録(する)s.) (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... which still have their uses... cash 登録(する)s?... but are not 広範囲にわたって used (or 利用できる!) today. Many are thermal printers.)
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 the "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. 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).
With the simple code above, I hope you don't 推定する/予想する "everything" to be in place?
The code is only meant to Get You Started. It won't 供給(する) all wants.
But even that simple little 使用/適用 can 対処する, up to a point, with the fact that different people use different paper sizes. During your interaction with PrintDialog1.遂行する/発効させる, you can go into the printer's 所有物/資産/財産s.
罰金. We can do text.
If you want a discussion that 作品 more 直接/まっすぐに with the later 構成要素 on the FreePascal page, then look at the earlier 版 of this tutorial, について言及するd 以前.
In this 見解/翻訳/版, I am trying to cover what's in the language, using more or いっそう少なく the path taken by the FreePascal page, but with coding which I think will be easier to follow.
By the way, the FreePascal page has some その上の, more esoteric ideas that may 利益/興味 you once you are (疑いを)晴らす on the basic ideas. One that fascinated me was...
MyPrinter.BeginDoc;
page.PaintTo(myPrinter.Canvas, 0, 0);
MyPrinter.EndDoc;
But to come 支援する to earth: I'm going to create something very の近くに to the code we had a moment ago. That will then be developed into something like the second FreePascal example. Later an 代案/選択肢 実施 of the その後の 見本 code's functionality will also be given.
----
What sort of thing did I want to do 異なって? One example: I didn't like "page" as the 指名する for a パネル盤. I would call the 同等(の) 反対する in my 使用/適用 "paDrawHere"... but I didn't need a パネル盤 in my simple answer.
根底となる fact: We are "doing graphics"... the text is put の上に a field of pixels, and that is what gets printed. The "graphic" might look like "this is text as a graphic", but as far as the program is 関心d, it's just meaningless (to the computer) squiggles.
The "TextOut" 手続き is going to be important to us. It turns text into a graphic that looks (to a human) to be the text. "TextOut" is really very simple...
Printer.canvas.textout(10,20,'Hello');
..."draws" a graphic that look like 'Hello' on the canvas, 10 部隊s from it's left 辛勝する/優位, 20 部隊s 負かす/撃墜する from it's 最高の,を越す 辛勝する/優位. Of course, the "mapping" of the "canvas" to the physical sheet of paper passing through the printer, what the 部隊s are, etc, are all devilish 詳細(に述べる)s to master. But the basic 概念 is (疑いを)晴らす, I hope. There will be more on this later.
In the simple 使用/適用 現在のd above, which got us started, we 簡単に "drew" on the canvas of the system-供給するd "Printer" 反対する.
To 達成する greater 支配(する)/統制する over what is printed where, at what 規模, we need to be more fancy. Sigh. We will come to that. Something we will not come to at this time is using TextOut except crudely.
What do I mean by "crudely"?
You should already be (疑いを)晴らす about where the upper left of the graphic of "Hello" will be. (It will be at 10,20). How far across, how far 負かす/撃墜する will it go? 井戸/弁護士席... for now... as far as it needs to! The one (small) bit of good news is that at least if you ask to print something which would be "off the page", there won't be problems. Bits will be 行方不明の from your hardcopy, but at least what CAN be printed, will be!
We will only use TextOut to build a 選び出す/独身 line of the final page hardcopy at a time. (You will have to 扱う breaking a long paragraph into page-wide lines.)
These 制限s do not stop you doing lots of Good Stuff. And there are answers... for another time... for doing fancier things.
For now, to put a short poem on a page, you'd use....
TextOut(100,200,'A man that looks on glass'); TextOut(100,300,'On it may stay his 注目する,もくろむ.'); TextOut(100,400,'Or if he pleaseth,'); TextOut(100,500,'Though it pass,'); TextOut(100,600,'And then the heavens 遠くに見つける.');
(A 詳細(に述べる): As you can see, I've 簡単に 増加するd the Y value by 100 each time. TextOut doesn't care how big you've 始める,決める the text to print. For a given font size, 30 may be too big... and there would be 抱擁する vertical gaps, or too small, in which 事例/患者, the fourth line would overlap the 3rd, the 3rd the 2nd, and the 2nd the first.
That example drags me clicking and 叫び声をあげるing to a topic I've been 避けるing... the 部隊s of the first two parameters, the x and y 場所 for where the text appears on the page.
The 部隊s are simple: The 相殺するs are 手段d in pixels. Ah, yes, but how big is a pixel? If I put the second line 100 pixels その上の 負かす/撃墜する the page than the first line, where does that put it?
With my レーザー printer, with my Windows 体制/機構... as left (for now) after MS's 最新の "updates" (bah), that puts the second line a bit more than 4 mm below the first. But with your printer, you may get a different result! Sigh.
The good news? When you send text to the printer with the system 始める,決める out here, a 広大な/多数の/重要な 取引,協定 of the work is done by Windows. In particular, the translation of the characters to the graphic that 描写するs them. If you ask the system 始める,決める out here to put an "A" on the page, in Times New Roman, 12 pt, it should look just like the A of the same specs 生産(高) by your wordprocessor. Hurrah!
And do you remember "Abs(Canvas.TextHeight('I')" which we met a little while 支援する? That will be a help to you, too. There are probably other such things. (See the links regarding TextExtent, TextRect at the 底(に届く) of this page for A-level 構成要素 that may 利益/興味 you... someday. For now, we have easier ways to 規模 the cats.)
But don't try to 令状 your own wordprocessor just yet
Start a new 事業/計画(する). To 正確に/まさに match what I am doing here use the に引き続いて 指名するs. (If you do that, using "copy/paste" between here and your Lazarus IDE will be easier.) (I will try... 結局... to 供給する the finished code... but "building it up" for yourself will probably be a big help to you in trying to fully understand what is here.)
In the first part of this tutorial, we managed to make a Lazarus program put some text on a page.
In the second part, I was going to do that again, but a bit better. (Energy failed me, and I didn't get やめる that far! But read on! I've given you what you'd need to do it!)
Our second 使用/適用 will have a button and a 覚え書き box and a button. Whatever text is in the 覚え書き box will appear as hardcopy when we click the button. To 強調する that we are working with graphics, there will also be a circle on the hardcopy.
I said we'd do it better. In this second 見解/翻訳/版, we will be able to "manage" things like the 利ざやs used, etc.
I will also be moving where some things are 宣言するd. In general, I applaud the practice of making things as 地元の, as "not 全世界の" as possible. However, I do have 推論する/理由s for most of the moves you will see in my code.
Create the empty 爆撃する of a new 使用/適用.
Put a 覚え書き on it. "memo1" is an 許容できる 指名する.
Put a button on it. 改名する it buProduceHardcopy. (That will do for the button's caption, or get fancy and make the caption "Produce hardcopy", if you like.)
Those will give rise to things you will see if you run the code. Also 追加する a TPrintDialog 反対する. The default 指名する, "PrintDialog1" is 満足な.
Be sure to... 追加する "Printers" to the 使用/適用's "uses" 条項.
宣言する the に引き続いて variables in the "私的な" 封鎖する of the 宣言 of the TLDN162_simple_hcF1 class.
(自白... I made this more 複雑にするd that it "needed" to be... if you did the left and 最高の,を越す 利ざや specs in PIXELS instead of MM, as I've tried to do, your programming life could be わずかに simpler. But using the 使用/適用 would be harder! You'll have to 人物/姿/数字 out the 権利 value for you, for your system, for iPrinterPixelsPerCM... how many pixels your printer uses to produce a 1 cm long line. After that, things just "flow through". Yes... I know that I 港/避難所't given you direct 接近 to the 高さs of lines 手段d in pixels. Sorry! You CAN do it, but where you would do it, how you would use that would be "messy", distract readers from the 核心 of this "introductory"(!) 構成要素.
//"PP" prefix is for "Printer Page"... the hardcopy this
// 使用/適用 生成するs
iPPPixelsPerCM,
iPPLeftMarginMM,iPPTopMarginMM,
iPPLeftMarginPix,iPPTopMarginPix,iPPLineHeightPix:integer;
割り当てる values to those variables in your FormCreate event handler, e.g...
iPPPixelsPerCM:=120;//権利 for a 300 dpi printer iPPLeftMarginMM:=5; iPPTopMarginMM:=10;
... and on the next lines, 変える to the computer-friendly 同等(の)s in pixels...
iPPLeftMarginPix:=iPPLeftMarginMM * (iPPPixelsPerCM div 10);
iPPTopMarginPix:=iPPTopMarginMM * (iPPPixelsPerCM div 10);
//.. and calculate the vertical 調整する of where the text will go.
iPPLineHeightPix:=一連の会議、交渉/完成する(1.2 * Abs(Canvas.TextHeight('I')));
公式文書,認める: Any time you change the 特徴 of the font used by the canvas, you may have to re-calculate iPPLineHeightPix.
In setting the left and 最高の,を越す 利ざやs, remember that these will be the 利ざやs into the printable area that your printer gives you.
Yes... there will be 一連の会議、交渉/完成するing errors. You may not get "正確に/まさに" the 利ざやs you request. With even a 150 dpi printer, I would be surprised if the "errors" are noticeable.
With those changes made, the heart of creating two lines of hardcopy has become...
手続き TLDN162_simple_hcF1.buProduceHardcopyClick(Sender: TObject);
var
sTextToPrint:string;
iPPYPos:integer;
begin
if PrintDialog1.遂行する/発効させる then begin //SIGSEGV 直す/買収する,八百長をする- 1 of 2 lines for this
with Printer do
try
//準備する the "pen and paper"...
BeginDoc;
Canvas.Font.指名する:='特使 New';
Canvas.Font.Size:=10;
Canvas.Font.Color:=clBlack;
//Re- calculate the vertical 調整する of where the text will go.
iPPLineHeightPix:=一連の会議、交渉/完成する(1.2 * Abs(Canvas.TextHeight('I')));
//始める,決める 初期の 最高の,を越す-of-line
iPPYPos:=iPPTopMarginPix;
//Calculate, once and for all, the 高さs for lines
//(the 1.2 is your "主要な". It should probably be
//in another PP 始める,決める-once "variable" (like
// iPrinterPixelsPer, but it will need to be of
// type "real" (unless you use clever trickery!).
//Put 令状ing on "the paper"...
sTextToPrint:='Hello hardcopy world ';
Canvas.TextOut(iPPLeftmarginPix,iPPYPos,sTextToPrint);
iPPYPos:=iPPYPos+iPPLineHeightPix;
//
//The に引き続いて line is an unnecessary frill... but it
//追加するs a bit to help you distinguish one 実験(する) print from another...
//(And illustrates how you do a second, etc, line.
sTextToPrint:=DateTimeToStr(Now);
Canvas.TextOut(iPPLeftmarginPix,iPPYPos,sTextToPrint);
//The に引き続いて should help you find the 権利 value for iPPPixelsPerCM
//for your system...
iPPYPos:=iPPYPos+iPPLineHeightPix;
Canvas.TextOut(iPPLeftmarginPix,iPPYPos,'Two x''s, 5cm apart, '+
'if iPPPixelsPerCM is 始める,決める 正確に...');
iPPYPos:=iPPYPos+iPPLineHeightPix;
Canvas.TextOut(iPPLeftmarginPix,iPPYPos,'X');
Canvas.TextOut(iPPLeftmarginPix+5*iPPPixelsPerCM,iPPYPos,'X');
finally //If all of the above 完全にするd okay,
//"EndDoc" will 誘発する/引き起こす the actual printing...
EndDoc;
end; //of "try... finally..."
end; //SIGSEGV 直す/買収する,八百長をする- 2 of 2 lines for this
end; //buProduceHardcopyClick
A 詳細(に述べる): 公式文書,認める, within the code just 現在のd, the 創造 of two 地元の variables...
var sTextToPrint: String;
iPPYPos:integer;
The 初めの had 類似の variables. I only について言及する them as...
a) I changed the 指名するs
b) I moved most variables and constants, made them 全世界の.
For those who need it: 陳謝s of the "unnecessary" use of some 全世界のs. I think it helps for the novice see what is going on. In general, I agree with the mantra "Use a 地元の variable when you can." (Within 推論する/理由!)
All of that 単に gets us 支援する to where we were!
If looking through that, all is VERY (疑いを)晴らす to you, and you aren't 深く,強烈に 利益/興味d in the first place, feel 解放する/自由な to skip the sub-page I've written to go into parts of that in 詳細(に述べる). There's a link there to bring you 支援する here if you need it. In any 事例/患者, the link should open the digression in a new tab (you can 始める,決める your browser to switch to new tabs as soon as they are opened, you know?). Just の近くに that tab, and you will be 支援する here... this never went away. It was just "under" the digression.
We now have a way to put lines of text の上に hardcopy.
We 指定する what the text is. We can 始める,決める things like font family and size. We can say where the upper left of the first line should go on the page, 親族 to the upper left of the total "can print here" area as understood by Lazarus.
As a fun (?) 転換, we'll now look 簡潔に at putting graphics on the hard copy, just because we can. And along the way, we will cover an important general 問題/発行する.
This is as far as I went in 詳細(に述べる) during my editing 開会/開廷/会期 of 2 Oct 21.
I skimmed the 残り/休憩(する) at that time. I hope you will find it useful. If you find 欠陥s, or even just 不正に explained bits... anywhere... PLEASE get in touch! It encourages me to produce these things, and if you've read this far, it must at least have seemed like it MIGHT be useful! Even if someone is only "complaining", it shows me that at least someone READ this!
Just after the...
Canvas.TextOut(iPPLeftmargin,iPPYPos,sTextToPrint);
... in what we have, 追加する...
canvas.小衝突.color:=clLime; canvas.FillRect(150,250,500,100); canvas.pen.color:=clBlack; canvas.moveto(50,450); canvas.lineto(250,450); canvas.TextOut(iPPLeftmargin,iPPYPos+600,sTextToPrint);
There are several things you need to keep in mind...,
The に引き続いて will always draw a vertical line on your hardcopy.
canvas.moveto(300,400); canvas.lineto(300,2400);
... but where it lies on the page, and how long it will be will depend on your printer. In my 事例/患者, with a modest レーザー printer, it produced a line about 1.3 インチs long... 暗示するing that the printer runs at about 1500dpi
公式文書,認める that I didn't 試みる/企てる to draw from Y=0, nor along X=0. On My printer, that wouldn't have been a problem... it doesn't 試みる/企てる borderless printing. But some do. (On my printer, the 辛勝する/優位 of the area used for printing is about 4.5 mm from the 辛勝する/優位 of the sheet. I 設立するd this by 実験....
canvas.moveto(1000,0); canvas.lineto(0,0); canvas.lineto(0,2000);
If your first graphics 実験(する)s "don't work", check to be sure that your numbers aren't too small... my first 試みる/企てるs gave rise to such tiny "製図/抽選s" that I nearly overlooked them! Or too big... maybe you've drawn everything off either the 底(に届く) or 権利 手渡す 辛勝する/優位s of the sheet?
If I did a program that would be 製図/抽選 graphics to be printed, I'd have two "始める,決める once and don't change" variables 始める,決める up... ScaleToPrintX and ScaleToPrintY. Then, in my program, something like the "find corner" code 現在のd a moment ago would look like...
[P.S., 2 Oct 21... see iPPPixelsPerCM in the 構成要素 above!]
canvas.moveto(10*ScaleToPrintX,0*ScaleToPrintY); canvas.lineto(0*ScaleToPrintX,0*ScaleToPrintY); canvas.lineto(0*ScaleToPrintX,20*ScaleToPrintX);
If the time (機の)カム that you 手配中の,お尋ね者 to print with a different printer, you would only need to 始める,決める ScaleToPrintX and ScaleToPrintY to new values, and all would be 井戸/弁護士席! (I think that for most printers, they would both 持つ/拘留する the same number. I also think... this 公式文書,認める in haste, during "tidy up" edit, Oct 21, that the "ScaleToPrintX" and "ScaleToPrintY" which I spoke of when, long ago, I wrote this section is what the "iPPPixelsPerCM" in more 最近の parts of this takes care of.)
In a 類似の vein: TextOut doesn't "care" or "know" about any 利ざやs that may be inherent in your printer. Many printers are incapable of printing to the 辛勝する/優位 of the page. TextOut(0,0,'Hi') will put "Hi" as far up and as far to the left as is possible, but it may not be fully in the upper left corner of the sheet of paper. (My printer put it about 4 mm from the 最高の,を越す, 4 mm from the left 辛勝する/優位.)
You'll want 利ざやs, anyway. So to put the two lines we made a moment ago in the "upper left" of the part you are using on the sheet of paper, i.e. to "示す" where your 利ざや ends, create two more "variables" which will be 始める,決める once, and then not changed... and "追加する" them to everything, e.g....
TextOut((x*ScaleToPrintX)+(MargX*ScaleToPrintX),
(y*ScaleToPrintY)+(MargY*ScaleToPrintY),
'実験(する)ing 1,2,3');
That could, of course, be done more elegantly.
Oh! Why do I use variables for things like ScaleToPrintX when the values in them shouldn't 普通は change while the 使用/適用 is running? Why not use a constant?
The answer is in the "shouldn't 普通は change..."
What if you 追加するd a pair of 無線で通信する buttons to the 使用/適用? The 使用/適用 could be written so that when one was selected, your hardcopy would be formatted for "letter" paper, but if the other were selected, the 生産(高) would be formatted for "A4" paper. That's why I often use variables even for things that 普通は might not change.
Compared to what I might have gone into, I've kept this 公正に/かなり simple(!)
If you read the page that 始める,決める me 負かす/撃墜する the road to success, について言及するd earlier, wiki.freepascal.org's "Using The Printer", you will find some Good Stuff under "前進するd steps: printing 支配(する)/統制するs" and "On we go: resizing", but rather コンビナート/複合体 stuff, ふさわしい for "difficult" problems.
If you want to have a "preview" on your 審査する, before producing the hard-copy of your work, an answer NOT in the FreePascal might 控訴,上告 to you...
You could have TWO canvases, two pairs of 規模ing constants...
For each of the 手続きs you want to use... TextOut, MoveTo, LineTo, you'd create small subroutines. Taking "moveto" as an example...
手続き TLDN162_simple_hcF1.MoveToBoth(x,y:integer); begin Printer.Canvas.MoveToBoth(x*ScaleToPrint,y*ScaleToPrintY); MyScreenCanvas.MoveToBoth(x*ScaleToScreenX,y*ScaleToScreenY); end;
I hope you 設立する what you were looking for when you (機の)カム here. Thank you for reading to the end! Let me know if there are things that didn't make sense, didn't get answered? 接触する 詳細(に述べる)s below.
When I started this, I was going to show you how you might 生産(高) whatever was in a 覚え書き on your 審査する to 署名/調印する-on-paper.
井戸/弁護士席... it seemed like a good idea at the time. Still seems like a good idea, and even do-able. But I'm afraid I'm out of time and energy, just want this "done", and I'm not going to 令状 it up in 詳細(に述べる). Sorry.
But you have almost everything you need!
You would 単に go through the lines, one by one, and use TextOut to pass them to the Printer.Canvas. The code would be something LIKE...
手続き TLDN162_simple_hcF1.Button1Click(Sender: TObject);
var iPosX,iPosY,iCount,iLast:integer;
begin
iPosX:=100;
iPosY:=150;
iCount:=0;
iLast:=memo1.lines.count;
repeat
TextOut(iPosX,iPosY,memo1.lines[iCount]);
iPosY:=iPosY+300;
inc(iCount);
until iCount=iLast;
end;
Something like the に引き続いて would 扱う printing out the contents of a 覚え書き that were so 広範囲にわたる that they 要求するd more than one page. 公式文書,認める that "page" is defined as a 確かな number of lines. Make that too large, and some lines that should appear in the hardcopy will be 行方不明の. You can make it small to save 署名/調印する when 実験(する)ing... the printer and the ソフトウェア will work together to start a new piece of paper at the 権利 times, even if you 港/避難所't used all the lines you might have on it.
手続き Tldn153AggFrmXtabF1.PrintReport;
//See https://sheepdogguides.com/lut/lt3Nhardc-short.htm for a guide
//to getting hardcopy from an 使用/適用
var
sTextToPrint:string;
iPPYPos,iLinesOfReportCount,iLinesOfPageCount,
iLastLineInMemo:integer;
bTmpKludgeToFigureOutPrintingTwoPages:byte;
begin
bTmpKludgeToFigureOutPrintingTwoPages:=1;//Always init as 1.
iLastLineInMemo:=meOutput.lines.count;
ShowPnE('Starting 世代 of hardcopy.');
ShowPnE('Lines in 覚え書き, 含むing headers, etc: '+inttostr(iLastLineInMemo));
iLinesOfReportCount:=1;//This count will be 明白な to 使用者s,
//so counting from one. If you 始める,決める iMaxLinesPerPage to 25,
//you will get 25 lines of 生産(高). It will
//also be used to fetch lines from a TMemo 構成要素, so.... q-FINSIH REMARK!
if PrintDialog1.遂行する/発効させる then begin //SIGSEGV 直す/買収する,八百長をする- 1 of 2 lines for this
with Printer do
while (bTmpKludgeToFigureOutPrintingTwoPages<5)//始める,決める to "<5" for only 4 pgs
and (iLinesOfReportCount<iLastLineInMemo+1) do begin //
try //Does one page of 報告(する)/憶測
//準備する the "pen and paper"...
BeginDoc;
Canvas.Font.指名する:='特使 New';
Canvas.Font.Size:=10;
Canvas.Font.Color:=clBlack;
//Calculate the vertical dimension of a line of text.
//This must be re-calculated any time the 高さ of font is changed.
// (And also any 扶養家族 values, e.g iMaxLinesPerPage.)
//The 1.2 is your "主要な" (Rhymes with "red"). The 主要な number
// should probably be in another PP "variable" (like
// iPrinterPixelsPerCM. That variable would need to be of
// type "real", unless you use clever tricks.
iPPLineHeightPix:=一連の会議、交渉/完成する(1.2 * Abs(Canvas.TextHeight('I')));
//始める,決める 初期の 最高の,を越す-of-line
iPPYPos:=iPPTopMarginPix;
//--------
iLinesOfPageCount:=1;//This count will be 明白な to 使用者s,
//so counting from one. If you 始める,決める iMaxLinesPerPage to 25,
//you will get 25 lines of 生産(高).
//First line... 公式文書,認める basic patter... fill sText.., Textout...,
// and then a iPPYPos:=iPPYPos+iPPLineHeightPix; to
// update that, ready for the NEXT TextOut.
sTextToPrint:='報告(する)/憶測 printed: '+DateTimeToStr(Now);
Canvas.TextOut(iPPLeftmarginPix,iPPYPos,sTextToPrint);
iPPYPos:=iPPYPos+iPPLineHeightPix;
inc(iLinesOfPageCount);
//The に引き続いて should help you find the 権利 value for iPPPixelsPerCM
//for your system...
Canvas.TextOut(iPPLeftmarginPix,iPPYPos,'X');
Canvas.TextOut(iPPLeftmarginPix+5*iPPPixelsPerCM,iPPYPos,'X');
Canvas.TextOut(iPPLeftmarginPix+6*iPPPixelsPerCM,iPPYPos,'< 5cm apart, '+
'if iPPPixelsPerCM 権利.At left 利ざや.');
iPPYPos:=iPPYPos+iPPLineHeightPix;
inc(iLinesOfPageCount);
//"挿入する" a line's 価値(がある) of vertical space
iPPYPos:=iPPYPos+iPPLineHeightPix;
inc(iLinesOfPageCount);
//Main 宙返り飛行 to send 報告(する)/憶測 to printer...
while (iLinesOfPageCount<iMaxLinesPerPage+1)
and (iLinesOfReportCount<iLastLineInMemo+1) do begin //Yes... the "+1" annoys
//me... but there's a 推論する/理由 for it this time!
sTextToPrint:=meOutput.lines[iLinesOfReportCount-1];//Yes... the "-1"
//annoys me... but again there's a 推論する/理由 for it.
inc(iLinesOfReportCount);
Canvas.TextOut(iPPLeftmarginPix,iPPYPos,sTextToPrint);
iPPYPos:=iPPYPos+iPPLineHeightPix;
inc(iLinesOfPageCount);
end;//while iLinesOfPageCount...
finally //If all of the above 完全にするd okay,
//"EndDoc" will 誘発する/引き起こす the actual printing...
EndDoc;
end; //of "try... finally..."
inc(bTmpKludgeToFigureOutPrintingTwoPages);
end; //.. of While bTmpKludgeToFigureOutPrintingTwoPages...
end; //End With. SIGSEGV 直す/買収する,八百長をする- 2 of 2 lines for this
end; //PrintReport
I said that for now, we would 扱う/治療する TextOut as a rather 限られた/立憲的な 手続き, only 有能な of 取引,協定ing with a 選び出す/独身 line. There are ways to send text with line 料金d in it to the 審査する with just one line of code. And I funked showing you how to be sure that the line you 手配中の,お尋ね者 to 追加する to the hardcopy was short enough to fit.
If you want to search out the answers for the wants 暗示するd in the above, you should look at...
TextExtent... see... https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tcanvas.textextent.html TextRect... see... https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tcanvas.textrect.html .. and the に引き続いて discussion, in particular the 地位,任命するs 近づく the 底(に届く)... https://会議.lazarus.freepascal.org/索引.php?topic=21118.0
Links to the above...
TextExtent
TextRect
(If you use TextRect, I think you still have the problem of "too long" lines 簡単に 存在 "chopped 負かす/撃墜する". I don't believe there is any 平易な 同等(の) to a 覚え書き with "DoWordWrap" 始める,決める to "true".)
Discussion
I hope you will find the above is already useful in itself? I will try to 延長する this... if there's any 利益/興味. A few Facebook likes, について言及するs at Reddit, etc, etc, would be welcome.
Search across all my 場所/位置s with the Google search...
Use this to search THIS 場所/位置.... (Go to my other 場所/位置s, below, and use their search buttons if you want to search them.)
|
|||
| search engine by freefind |
The search engine 単に looks for the words you type, so....
* (一定の)期間 them 適切に.
* Don't bother with "How do I get rich?" That will 単に return pages with "how", "do", "I"....
Please also 公式文書,認める that I have two other 場所/位置s, and that this search will not 含む them. They have their own search buttons.
My SheepdogSoftware.co.uk 場所/位置.
To email this page's editor, Tom Boyd.... Editor's email 演説(する)/住所. Suggestions welcomed! Please 特記する/引用する "lt3Nhardc-short.htm".
Page has been 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes.
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 .....