<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Is this for a Dymo style printer?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The easiest way you might do this nowadays is using the Windows API.. I'm sorry for the sort of pseudo-code but I'm stuck with examples my previous work owns so I have to paraphrase a bit:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
GetDefaultPrinter (so you don't have to enumerate and then find the right one, set the label printer to default)</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
CreateDC (we want something to draw our text to)</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
StartDoc(dc, @di); (our initial 'print')<br>
StartPage(dc); (this in our case would be each label)<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Some sample stuff to create a font you can use:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
fillchar(lf, sizeof(lf), 0);
<div>lf.lfWeight:=FW_NORMAL;</div>
<div>lf.lfHeight:=-MulDiv(12, GetDeviceCaps(dc, LOGPIXELSY), 72);</div>
<div>newfont:=CreateFontIndirect(@lf);</div>
<div>oldfont:=GetCurrentObject(dc, OBJ_FONT);</div>
SelectObject(dc, newfont);<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
A little helper function.. not amazing but gets text mostly where you'd want it at column/row<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
procedure printxy(dc: HDC; x, y: byte; s: string);
<div>begin</div>
<div>TextOut(dc, x*50, y*110, @s[1], length(s));</div>
end;<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
EndPage(dc); (in our case end this label)</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
EndDoc(dc); (end the print job)<br>
<div></div>
<div><br>
</div>
<div>SelectObject(dc, oldfont); (cleanup)<br>
</div>
<div>DeleteObject(newfont);</div>
<div></div>
<span>DeleteDC(dc);</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
It'll take a bit of effort to read up on those functions and get them working right, but afterward you should have printing sorted for yourself as long as the windows api is supported.<br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
--</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Alexander Grotewohl</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
https://dcclost.com</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> fpc-pascal <fpc-pascal-bounces@lists.freepascal.org> on behalf of James Richters via fpc-pascal <fpc-pascal@lists.freepascal.org><br>
<b>Sent:</b> Wednesday, February 9, 2022 1:17 PM<br>
<b>To:</b> 'FPC-Pascal users discussions' <fpc-pascal@lists.freepascal.org><br>
<b>Cc:</b> James Richters <james.richters@productionautomation.net><br>
<b>Subject:</b> [fpc-pascal] Text Only printing on Windows.</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:visited, span.x_MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
span.x_EmailStyle17
        {font-family:"Calibri",sans-serif;
        color:windowtext}
.x_MsoChpDefault
        {font-family:"Calibri",sans-serif}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal">Way back in the old Turbo Pascal days, it was super simple to send text to a printer…
<span style="">  </span>I had written a program that printed text on labels in the</p>
<p class="x_MsoNormal">order the labels were needed.. the whole thing took me less than an hour to write and labels were spewing out of the printer.</p>
<p class="x_MsoNormal">I haven’t had a need to print anything since then, but now, I want to do the exact same thing.. print sequential text only labels from my FPC console program…
</p>
<p class="x_MsoNormal">I can display the labels to the console window, or write them to a file… but I’m just staring at my code at a total loss on how to send these simple labels to my</p>
<p class="x_MsoNormal">USB label printer connected to a windows 10 64bit PC.<span style=""> 
</span>Is there no way to just send text to printers anymore? </p>
<p class="x_MsoNormal">I don’t want to go through the windows print dialog for every label, and I don’t want to create one huge document of all the labels and print them all at once..</p>
<p class="x_MsoNormal">I want my FPC console application to spit out the next in sequence single label each time I push the space bar, without dealing with any the print dialog or doing anything else.</p>
<p class="x_MsoNormal">This used to be so easy to do, but now it seems either very complicated or impossible.<span style=""> 
</span>Does anyone know of a way to just send pain text</p>
<p class="x_MsoNormal">to a USB printer with FPC ,preferably without Lazarus?</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">James</p>
</div>
</div>
</body>
</html>