Serious problems with printing coloured text

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kroka
Posts: 52
Joined: Fri Sep 28, 2007 10:20 am
Contact:

Serious problems with printing coloured text

Post by kroka » Fri May 03, 2013 12:27 pm

Hello!

I have been using LiveCode for quite a while. I found that it can do a lot more than I thought in the beginning. But now I am really stuck in a project for a publishing company.

It is about printing the contents of a stack (just one text field). I've done it before, but this time the field is containing characters in different colours.

I made a seperate stack for printing. I set the formatForPrinting to true. I closed and removed the stack from memory. I also used it as a completely seperate file.

I copy the htmltext from another field into my textfield on the print stack.

And I did some other things just to try if it makes a difference.

Basically it now looks like this:

set the formatforprinting of stack (progpath&"/Ressources/druckseite.rev") to true
open invisible stack (progpath&"/Ressources/druckseite.rev")
set the locktext of fld "textseite" of stack "druckseite" to false
set the htmltext of fld "textseite" of stack "druckseite" to ( the htmltext of fld "eg_ergebnis" of stack "uebungseditor")
set the formatforprinting of stack "druckseite" to true
set the locktext of fld "textseite" of stack "druckseite" to true
printPage "druckseite" --- my print function

But NO LUCK. It's looking fine on the screen. But the output will always be wrong: All coloured letters are wrong positioned and destroy the whole layout on every printer or PDF. Whatever I tried, it stayed the same.

I've read the instructions on how to make sure that the stack has "formatforprinting" before it is being loaded very carefully. I'm 100% sure this is the case. Still not working.

Does anybody know if this is a general problem, maybe not solvable at the moment - or have I missed something?

I'd appreciate any hint! Thank you!

kroka
"irgendwas is immer"

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Serious problems with printing coloured text

Post by Klaus » Fri May 03, 2013 2:28 pm

Hi kroka,

try to set the formatforprinting AFTER you set the htmltext of your field(s):
...
## Don't:
## set the formatforprinting of stack (progpath&"/Ressources/druckseite.rev") to true

open invisible stack (progpath&"/Ressources/druckseite.rev")

## Not necessary:
## set the locktext of fld "textseite" of stack "druckseite" to false
set the htmltext of fld "textseite" of stack "druckseite" to ( the htmltext of fld "eg_ergebnis" of stack "uebungseditor")

## Now:
set the formatforprinting of stack "druckseite" to true

## Dito, see above:
## set the locktext of fld "textseite" of stack "druckseite" to true
printPage "druckseite" --- my print function
...

Best

Klaus

kroka
Posts: 52
Joined: Fri Sep 28, 2007 10:20 am
Contact:

Re: Serious problems with printing coloured text

Post by kroka » Fri May 03, 2013 6:01 pm

Hi Klaus,

thank you for your suggestion. I tried it - but sorry... still the same result. I've never seen my text formatted correctly on paper... it's quite frustrating.

kroka
"irgendwas is immer"

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Serious problems with printing coloured text

Post by jacque » Sat May 04, 2013 6:28 pm

Set the printcolors to true in your printing handler. If you don't, you only get black and white printouts by default. See "printcolors" in the dictionary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Serious problems with printing coloured text

Post by Klaus » Sat May 04, 2013 7:58 pm

"printcolors"!? :shock:

LC never stops to surprise me :D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Serious problems with printing coloured text

Post by jacque » Sat May 04, 2013 8:12 pm

LOL, me too. And they keep adding new stuff. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

kroka
Posts: 52
Joined: Fri Sep 28, 2007 10:20 am
Contact:

Re: Serious problems with printing coloured text

Post by kroka » Sun May 05, 2013 12:02 pm

Thank you, Jacques!

printcolors was new to me, too. Only - it didn't solve my problem. The text printed in color before. Not the color itself was the problem. Only - whenever one of the letters is red or blue, it destroys the layout of the whole line. The following charcters appear too far left and some are even overlapping. On the screen the text looks perfectly fine, as soon as I print the stack, it turns into a little mess.

Haven't found any solution and tried everything in connection with "formatforprinting" - no way... seems like there are actually bugs in the printing routines of LiveCode...

Thank you anyway!

kroka
"irgendwas is immer"

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Serious problems with printing coloured text

Post by jacque » Sun May 05, 2013 7:07 pm

What OS are you using? FormatForPrinting is only functional on Windows. Usually it doesn't hurt anything on a Mac but it might be causing misalignment in cases where the engine needs to apply colors. In fact, it may be causing problems on Windows too. What happens if you don't use it at all?

If it still doesn't work, you may have found a bug. The field object was completely rewritten a couple of versions ago and there may be a printing glitch there.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

kroka
Posts: 52
Joined: Fri Sep 28, 2007 10:20 am
Contact:

Re: Serious problems with printing coloured text

Post by kroka » Mon May 06, 2013 8:51 am

I am using Windows for development in this project. The printout gets wrong and the formatforprinting set or not set doesn't make a difference.

I think this is a bug. If anybody would be able to create a simple stack with a text field containing text in different colours (in mycase: some red characters in a black text) and print it out without messing up the format - you'd prove me wrong and I'd be very interested to know how you did it. :-)

Otherwise I have to tell my client that I won't be able to add a printing option to the program because LiveCode can't do it. Instead I might just create a HTML-file which the user can print out using the browser... not very elegant, but what can you do...

Thank you for your help!

kroka
"irgendwas is immer"

user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

Re: Serious problems with printing coloured text

Post by user#606 » Wed May 08, 2013 5:06 pm

Hi,
I have discovered numerous issues with text, being solved with recent versions, if I specify the actual font, font size rather than relying on the default.
For example if you see the Inspector, Text Formatting, Font or Size as having nothing in them, then this has caused me problems between different PCs (text layout varying significantly) and printing to PDF (Text overlapped at odd places in the line and words truncated at the end of the line). All those problems vanished when set to Aerial, 12 for example.
RR have considered this to be a valid point and might get around to mentioning this in the Dictionary.

I have also discovered there is an issue with coloured text in a normal table field and is bug 10654.

This may of course have nothing to do with solving your strange issue, though I hope it does.

user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

Re: Serious problems with printing coloured text

Post by user#606 » Wed May 08, 2013 5:15 pm

Hi, Me again.
I just wondered if you could format the text output on a card and then print that.
I n my early days of using Livecode, I found the printing aspect poorly described and resorted to printing suitably formatted cards.
This served well, because the screen layout adapted well to the printed A4 page, in my case.
It solved two problems in one.

Just a thought, if it gives you time with your client, to get a proper solution.

Post Reply