How to print in livecode.

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: FourthWorld, heatherlaine, Klaus, kevinmiller

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

How to print in livecode.

Post by lemodizon » Wed May 19, 2021 2:22 pm

Hello everyone,

This is my first time to print in livecode but I'm still confused and i don't know if i'm doing the right steps. hope you can help me. i bought a receipt printer(china made) and the paper size is (57mm x 30meters) i set the size of the my substack (receiptTemplate) into 192px . The result of the print out is misaligned hope you can guide me on this. I'm practicing myself on how to print in livecode since livecode has no report builder. I will try it also in my canon printer. hope you can teach step by step procedure on how setup a template for receipt/report in livecode. Thanks

Code: Select all

on  mouseUp
    
   answer "Is the printer on and paper ready to print?" with "Cancel" or "OK"
   if it = "Cancel" then exit to top
   else
          
      put  fld "data" of cd "receiptCard" of stack "ReceiptTemplate" into Box1
      revPrintText Box1,,,the long name of fld "data" of cd "receiptCard" of stack "ReceiptTemplate"  
      
      end if
   end mouseUp
Attachments
printout.JPG
Print.JPG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to print in livecode.

Post by Klaus » Wed May 19, 2021 2:59 pm

Does it work with -> revprintfield?

Code: Select all

...
revPrintField the name of fld "data" of cd "receiptCard" of stack "ReceiptTemplate" 
...
Or maybe just:

Code: Select all

...
print cd "receiptCard" of stack "ReceiptTemplate" 
...

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to print in livecode.

Post by jacque » Wed May 19, 2021 3:58 pm

The default print margins are 1 inch on all sides. It looks like you need to change that. See the printMargins property in the dictionary. Most printers will have an area where they can't print so see if you an find out what that is and include that in your calculations. Try starting with a quarter inch and adjust it from there.RevPrintText should work. You don't need a printing card if you use revPrintText because you are just printing a variable.

If you want styled text then you will need a template field on the printing card that includes the text with the correct styling. Use revPrintField for this method.

To make a template card for more elaborate printing you can use a printing card to layout fields, images, etc. For this method, place the left edge of controls at 0 and the top controls at 0 too, because for this method you use "print card" and any empty space on the card will be added to the printMargins. Most printers have a half inch area at the top where they cannot print so expect at least that much at the top of the printout.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to print in livecode.

Post by dunbarx » Wed May 19, 2021 7:55 pm

Hi.

Should just take a little practice to get going.

Basically you can print text, a card or a field.

Check out the "print" command in the dictionary, especially the fact that you can print into any rect. Also read about setting the "printScale", which I have found useful.

Check out the several "revPrint..." commands as well.

Craig

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

Re: How to print in livecode.

Post by lemodizon » Thu May 20, 2021 2:38 am

Klaus wrote:
Wed May 19, 2021 2:59 pm
Does it work with -> revprintfield?

Code: Select all

...
revPrintField the name of fld "data" of cd "receiptCard" of stack "ReceiptTemplate" 
...
Or maybe just:

Code: Select all

...
print cd "receiptCard" of stack "ReceiptTemplate" 
...
Hi Klaus,

I will try this. thanks again.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: How to print in livecode.

Post by lemodizon » Thu May 20, 2021 2:42 am

jacque wrote:
Wed May 19, 2021 3:58 pm
The default print margins are 1 inch on all sides. It looks like you need to change that. See the printMargins property in the dictionary. Most printers will have an area where they can't print so see if you an find out what that is and include that in your calculations. Try starting with a quarter inch and adjust it from there.RevPrintText should work. You don't need a printing card if you use revPrintText because you are just printing a variable.

If you want styled text then you will need a template field on the printing card that includes the text with the correct styling. Use revPrintField for this method.

To make a template card for more elaborate printing you can use a printing card to layout fields, images, etc. For this method, place the left edge of controls at 0 and the top controls at 0 too, because for this method you use "print card" and any empty space on the card will be added to the printMargins. Most printers have a half inch area at the top where they cannot print so expect at least that much at the top of the printout.

Hi Jacque,

wow. it seem it is not easy to create a template. i need to practice on this I thought this is easy hehehe. do you have a sample stack on this? so that i can see how you done the procedure. Thanks for the response.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: How to print in livecode.

Post by lemodizon » Thu May 20, 2021 2:46 am

dunbarx wrote:
Wed May 19, 2021 7:55 pm
Hi.

Should just take a little practice to get going.

Basically you can print text, a card or a field.

Check out the "print" command in the dictionary, especially the fact that you can print into any rect. Also read about setting the "printScale", which I have found useful.

Check out the several "revPrint..." commands as well.

Craig
Hi dunbarx,

Thanks for the response. I wish livecode will include a control object for report builder. I need to practice to create a template. by the way do you have sample stack on this? so that can i see how you do it.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to print in livecode.

Post by dunbarx » Thu May 20, 2021 2:27 pm

wish livecode will include a control object for report builder.
Hi.

Not sure what this means.
I need to practice to create a template.
Nor this. Do you mean a "form" that you can call on at any time?

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to print in livecode.

Post by jacque » Thu May 20, 2021 5:17 pm

Since every print job is different, there are no universal templates. But for your example it can be simple if you only need plain text. Just set the print margins to a smaller number and use revPrintText like you did before.

Code: Select all

put  fld "data" of cd "receiptCard" of stack "ReceiptTemplate" into Box1
set the printMargins to 20 -- adjust this as needed
revPrintText box1
If you don't care about styled text, you don't need any of the other parameters.

If you want to use styled text, let us know and we can help.

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

Re: How to print in livecode.

Post by lemodizon » Fri May 21, 2021 5:31 am

dunbarx wrote:
Thu May 20, 2021 2:27 pm
wish livecode will include a control object for report builder.
Hi.

Not sure what this means.
I need to practice to create a template.
Nor this. Do you mean a "form" that you can call on at any time?

Craig
Hi Craig,

sorry for the confuse

What I mean is if there is a widget or control object from the tool palette for report builder or a form.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: How to print in livecode.

Post by lemodizon » Fri May 21, 2021 5:32 am

jacque wrote:
Thu May 20, 2021 5:17 pm
Since every print job is different, there are no universal templates. But for your example it can be simple if you only need plain text. Just set the print margins to a smaller number and use revPrintText like you did before.

Code: Select all

put  fld "data" of cd "receiptCard" of stack "ReceiptTemplate" into Box1
set the printMargins to 20 -- adjust this as needed
revPrintText box1
If you don't care about styled text, you don't need any of the other parameters.

If you want to use styled text, let us know and we can help.

Hi Jacque,

I will try this weekend. Thanks
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to print in livecode.

Post by bogs » Fri May 21, 2021 10:35 am

lemodizon wrote:
Fri May 21, 2021 5:31 am
What I mean is if there is a widget or control object from the tool palette for report builder or a form.
Well, there used to be, but it was removed from the IDE a long long time ago...
Image

However, if you wanted to try it in the current IDE, you can copy the file from Lc 7.1.4 (last version I know has it) into the plugins folder, and run it as a plugin.

The file your looking for would be [livecodecommunity-7.1.4 (x86_64)/Toolset/Unsupported/revreportsetup.rev]

Once it is in the plugins folder, you could then select / run it, however, I do not believe that it runs properly in the current IDE and would require some digging to figure out why (which is why it was in the unsupported folder to begin with, I suspect).
Image

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

Re: How to print in livecode.

Post by lemodizon » Sat May 22, 2021 1:10 am

bogs wrote:
Fri May 21, 2021 10:35 am
lemodizon wrote:
Fri May 21, 2021 5:31 am
What I mean is if there is a widget or control object from the tool palette for report builder or a form.
Well, there used to be, but it was removed from the IDE a long long time ago...
Image

However, if you wanted to try it in the current IDE, you can copy the file from Lc 7.1.4 (last version I know has it) into the plugins folder, and run it as a plugin.

The file your looking for would be [livecodecommunity-7.1.4 (x86_64)/Toolset/Unsupported/revreportsetup.rev]

Once it is in the plugins folder, you could then select / run it, however, I do not believe that it runs properly in the current IDE and would require some digging to figure out why (which is why it was in the unsupported folder to begin with, I suspect).
Hi bogs,

I saw this interface while searching in the internet. how come livecode removed it? anyway thanks for the information.
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to print in livecode.

Post by bogs » Sat May 22, 2021 12:25 pm

lemodizon wrote:
Sat May 22, 2021 1:10 am
I saw this interface while searching in the internet. how come livecode removed it? anyway thanks for the information.
The answer as to why it was removed would require someone that was around during the time period, and that isn't me unfortunately, I have no idea why it was removed, it seems a fairly simple and easy to use tool.
Image

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

Re: How to print in livecode.

Post by lemodizon » Mon May 24, 2021 12:52 pm

Hello Everyone,

Good day.

I did my practice today on how to print in livecode. Thanks for all the information I appreciated. thanks and stay safe everyone.

Code: Select all

on mouseUp
   answer printer
   lock screen
   set the printmargins to "0,0,0,0" --L,T,R,B 36=.5", 72=1"
   set the textFont of fld "data" of card "RTemplateCard" of stack "Rtemplate"  to "Courier New"
   set the textSize of fld "data" card "RTemplateCard" of stack "Rtemplate" to "7" --different textSize
   set the textStyle of fld "data" card "RTemplateCard" of stack "Rtemplate" to "plain" --different textStyle
   set the printPaperOrientation to "portrait" --portrait, landscape
   print card "RTemplateCard" of stack "Rtemplate"
   set the textFont of fld "data" of card "RTemplateCard" of stack "Rtemplate" to empty --default font/size/style
   set the textSize of fld "data" of card "RTemplateCard" of stack "Rtemplate" to empty --default
   set the textStyle of fld "data" of card "RTemplateCard" of stack "Rtemplate" to empty --default
   reset printing --default
   unlock screen
   
end mouseUp
Image

see the simple final print out
Image
Attachments
printout_1.JPG
livecode.JPG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”