Page 1 of 2

Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 7:10 am
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.

Re: Printing in the thermal Receipt

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

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 7:31 am
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.

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 10:10 am
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

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 10:23 am
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 29904 times

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 10:24 am
by Klaus
Yes, same happened here.
That is why I made use of the (almost) full syntax of revprinttext.

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 10:28 am
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 29902 times

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 10:46 am
by Klaus
at least got everything to print out:
Well, my script did exactly the same, yet a TAD less verbose! :D

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 10:47 am
by richmond62
Eat My Dust! 8)
-
Screen Shot 2023-10-17 at 12.45.56 pm.png
-

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 10:51 am
by Klaus
Cough, cough...
Hey, using another field, which would have been my next hint, is cheating! :-D

Re: Printing in the thermal Receipt

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

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 11:38 am
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.

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 11:51 am
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.

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 11:54 am
by Klaus
And please read "revprintfield" in the dictionary!
That will explain the strange syntax of that command.

Re: Printing in the thermal Receipt

Posted: Tue Oct 17, 2023 12:02 pm
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.