Serious problems with printing coloured text
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Serious problems with printing coloured text
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
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"
Re: Serious problems with printing coloured text
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
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
Re: Serious problems with printing coloured text
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
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"
Re: Serious problems with printing coloured text
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
HyperActive Software | http://www.hyperactivesw.com
Re: Serious problems with printing coloured text
"printcolors"!?
LC never stops to surprise me

LC never stops to surprise me

Re: Serious problems with printing coloured text
LOL, me too. And they keep adding new stuff. 

Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Serious problems with printing coloured text
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
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"
Re: Serious problems with printing coloured text
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.
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
HyperActive Software | http://www.hyperactivesw.com
Re: Serious problems with printing coloured text
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
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"
Re: Serious problems with printing coloured text
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.
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.
Re: Serious problems with printing coloured text
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.
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.