Printing in the thermal Receipt

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

lemodizon
Posts: 219
Joined: Thu Apr 05, 2018 3:33 pm

Printing in the thermal Receipt

Post by lemodizon »

Hello everyone,

good day.


Please help me on how to remove the space or adjust the spaces between the header and body of my fields.
here is my code below

Code: Select all


answer printer
   revShowPrintDialog false ,false 
   put  fld "fldHeader" of stack "StackPrinterGallons" into tHeader
   put  fld "fldIN" of stack "StackPrinterGallons" into tBody
  
  lock screen
   ##### HEADER
   set the printmargins to "0,0,0,0" --L,T,R,B 36=.5", 72=1"
   set the printPaperOrientation to "portrait" --portrait, landscape
   
   set the textFont of fld "fldHeader" of stack "StackPrinterGallons"  to "Arial"
   set the textSize of fld "fldHeader" of stack "StackPrinterGallons" to "20" --different textSize
   set the textStyle of fld "fldHeader" of stack "StackPrinterGallons" to "Bold" --different textStyle
  
   revPrintText tHeader
  
   ##### BODY

   set the textFont of fld "fldIN" of stack "StackPrinterGallons"  to "Courier New"
   set the textSize of fld "fldIN" of stack "StackPrinterGallons" to "10" --different textSize
  
  
   revPrintText tBody 
    unlock screen
   


here is the actual printout from the the printer.
Attachments
393626559_252373857390369_5994393655003180316_n.jpg
Thank you & God Bless Everyone :wink:

Regards,
lemodizon
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Printing in the thermal Receipt

Post by richmond62 »

Put ALL your text into one field, make sure that it looks the way you want it, then print the field.
Last edited by richmond62 on Tue Oct 17, 2023 11:07 am, edited 1 time in total.
lemodizon
Posts: 219
Joined: Thu Apr 05, 2018 3:33 pm

Re: Printing in the thermal Receipt

Post by lemodizon »

richmond62 wrote: Tue Oct 17, 2023 7:13 am Put ALL your text into one field, make sure that it looks the way you want it, the print the field.

Hi richmond62,

I tried it before, but i can't change the font size "header" example "gallon in" it will affect others text in that field.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing in the thermal Receipt

Post by Klaus »

Hi lemodizon,

1. you need to format your fields BEFORE you put the content into a variable! 8)
2. Use the full syntax of revprinttext, see below.
3. Why not format your two fields ONCE and then save that stack? :-)
This way you can leave out the formatting in your print script.
4. However it looks like revprinttext does not respect the formatting at all!?

This will work, however without the formatting:

Code: Select all

...
   answer printer
   revShowPrintDialog false ,false 
   
   lock screen
   ##### HEADER 
   ## FIRST format your fields!
   set the printmargins to "0,0,0,0" --L,T,R,B 36=.5", 72=1"
   set the printPaperOrientation to "portrait" --portrait, landscape
   
   set the textFont of fld "fldHeader" of stack "StackPrinterGallons"  to "Arial"
   set the textSize of fld "fldHeader" of stack "StackPrinterGallons" to "20" --different textSize
   set the textStyle of fld "fldHeader" of stack "StackPrinterGallons" to "Bold" --different textStyle
   
   ##### BODY
   set the textFont of fld "fldIN" of stack "StackPrinterGallons"  to "Courier New"
   set the textSize of fld "fldIN" of stack "StackPrinterGallons" to "10" --different textSize
   
   put  fld "fldHeader" of stack "StackPrinterGallons" into tHeader
   put  fld "fldIN" of stack "StackPrinterGallons" into tBody
   
   ## or if you want an empty line after the header:
   ## put CR &  fld "fldIN" of stack "StackPrinterGallons" into tBody
   
   ## THEN print the text   
   revPrintText tBody,tHeader
   unlock screen
...
I tried it before, but i can't change the font size "header" example "gallon in" it will affect others text in that field.
Well, what about setting the font, size etc. for LINE 1 of that field only to the desired properties?

Best

Klaus
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Printing in the thermal Receipt

Post by richmond62 »

The ODD thing with me is that the first field did not get printed at all:
-
Screen Shot 2023-10-17 at 12.22.28 pm.png
Screen Shot 2023-10-17 at 12.22.28 pm.png (31.21 KiB) Viewed 31867 times
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing in the thermal Receipt

Post by Klaus »

Yes, same happened here.
That is why I made use of the (almost) full syntax of revprinttext.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Printing in the thermal Receipt

Post by richmond62 »

Modifying you script:

Code: Select all

on mouseUp
   

answer printer
   revShowPrintDialog false ,false 
   put  fld "fldHeader" of stack "StackPrinterGallons" into tHeader
   put  fld "fldIN" of stack "StackPrinterGallons" into tBody
  
  lock screen
   set the printmargins to "0,0,0,0" --L,T,R,B 36=.5", 72=1"
   set the printPaperOrientation to "portrait" --portrait, landscape
   
   set the textFont of fld "fldHeader" of stack "StackPrinterGallons"  to "Arial"
   set the textSize of fld "fldHeader" of stack "StackPrinterGallons" to "20" --different textSize
   set the textStyle of fld "fldHeader" of stack "StackPrinterGallons" to "Bold" --different textStyle
  
  --revPrintText tHeader

   set the textFont of fld "fldIN" of stack "StackPrinterGallons"  to "Courier New"
   set the textSize of fld "fldIN" of stack "StackPrinterGallons" to "10" --different textSize
  
   revPrintText (tHeader & cr & cr & tBody)
    unlock screen
   
end mouseUp
at least got everything to print out:
-
Screen Shot 2023-10-17 at 12.28.04 pm.png
Screen Shot 2023-10-17 at 12.28.04 pm.png (24.49 KiB) Viewed 31865 times
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing in the thermal Receipt

Post by Klaus »

at least got everything to print out:
Well, my script did exactly the same, yet a TAD less verbose! :D
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Printing in the thermal Receipt

Post by richmond62 »

Eat My Dust! 8)
-
Screen Shot 2023-10-17 at 12.45.56 pm.png
-
Attachments
StackPrinterGallons.livecode.zip
Stack.
(1.41 KiB) Downloaded 255 times
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing in the thermal Receipt

Post by Klaus »

Cough, cough...
Hey, using another field, which would have been my next hint, is cheating! :-D
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Printing in the thermal Receipt

Post by richmond62 »

cheating
Well, you know me. 8)
lemodizon
Posts: 219
Joined: Thu Apr 05, 2018 3:33 pm

Re: Printing in the thermal Receipt

Post by lemodizon »

richmond62 wrote: Tue Oct 17, 2023 11:05 am
cheating
Well, you know me. 8)
Hi richmond62,

Code: Select all

revPrintField ("field" && "fldToPrint")
i'm trying to find this "field" where is this located? what is the purpose of this "field" that i can't find in the stack.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Printing in the thermal Receipt

Post by richmond62 »

Screen Shot 2023-10-17 at 1.47.54 pm.png
-
The purpose of that field is to sort out the font formatting.

READ the script in the button.
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Printing in the thermal Receipt

Post by Klaus »

And please read "revprintfield" in the dictionary!
That will explain the strange syntax of that command.
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10430
Joined: Fri Feb 19, 2010 10:17 am

Re: Printing in the thermal Receipt

Post by richmond62 »

Screen Shot 2023-10-17 at 2.00.17 pm.png
-
I don't think it explains the strange syntax at all.

What it DOES do is explain how to use revPrintField.
Post Reply