Printing With Different Text Styles With Windows

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Printing With Different Text Styles With Windows

Post by johnmiller1950 » Thu Oct 23, 2008 2:56 am

Greetings All,

I am trying to print a card that contains a field with text that has different textStyles. Under Windows XP, the words that are bolded, underlined or italicized overlap surrounding words.

Is this a bug, or is there a way around this.

Thanks,
John Miller

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Thu Oct 23, 2008 6:21 am

Hi John,

On Windows, there's a difference at the operating system level between on-screen fonts and printer fonts. In order to improve printing on Windows, you have to set the 'formatForPrinting' of the stack to true.
The tricky part is that you have to set this before putting any data into it, and then you shouldn't manually change the contents (as in: the stack is visible, the suer clicks into a field and starts typing away)
So the straightforward option is to make a separate stack, set the 'formatForPrinting' property of this stack to true, add all the fields and other graphic elements, save it to disk and from then on use this stack as a template for printing.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Post by johnmiller1950 » Thu Oct 23, 2008 11:49 pm

Jan,

Thanks for your post. I thought the proper procedure was to set the formatforprinting to false. Put the text into the fields of the stack. Close the stack, and then set the formatforprinting to true. Open the stack and then print.

Has this changed, or have I always had it wrong?

John

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Fri Oct 24, 2008 5:59 am

Heh, I got it wrong in the past too - the docs on this property seem designed to confuse you somewhere in the process. I finally figured it out on the basis of the script of the 'revPrintText' command - which you can find in the 'revPrintBack' backscript.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Post by johnmiller1950 » Fri Oct 24, 2008 11:51 am

OK! I'm stepping back and starting over.

I created a new stack with a text field set to textfont = "Arial" and textsize = 8.

Next I created a substack called "Print Stack" with one fld that is identical to the one in the main stack.

The field in the main stack has the following htmlText:

<p>Install new air <u><b>conditioner</b></u> in Storage Building #1. The rest of this line is a test to see if the <b>htmlText</b></p>
<p><u>command</u> will do away with the line wrapping.</p>



Here is the script of the button on the main stack.

on mouseUp
close stack "Print Stack"
set the formatforprinting of stack "Print Stack" to false
put the htmltext of cd fld 1
set the htmlText of cd fld 1 of cd 1 of stack "Print Stack" to the htmlText of cd fld 1

set the formatforprinting of stack "Print Stack" to true
open stack "Print Stack"
print cd 1 of stack "Print Stack"
set the formatforprinting of stack "Print Stack" to false
end mouseUp


When windows prints this cd, the text that has a modified textstyle overlaps the surrounding words.

Can anyone see what I'm doing wrong?

John

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Fri Oct 24, 2008 12:22 pm

Just leave the 'formatForPrinting' property true, there's no need to change it back and forth if you only use that stack for printing. Also, the stack doesn't have to be visible to print.

Code: Select all

on mouseUp
  set the htmlText of cd fld 1 of cd 1 of stack "Print Stack" to the htmlText of cd fld 1
  open invisible stack "Print Stack"
  print cd 1 of stack "Print Stack"
end mouseUp
HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Post by johnmiller1950 » Fri Oct 24, 2008 12:59 pm

Jan,

I set the formatforprinting of stack "Print Stack" to true and used the script just as you suggested, but the result I am getting here is still the same. All of the bold, underlined and italicized text overlaps the surrounding words.

Any other suggestions?

Also, if what you say is true (and you seem like an upstanding person), then the documentation for the formatforprinting function needs to be seriously updated.

John

Chipp
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 27
Joined: Sat Apr 08, 2006 9:50 am
Contact:

Post by Chipp » Sat Oct 25, 2008 3:33 am

John,

Try setting the formatForPrinting to true, then SAVE the stack, then close the stack, then don't mess with it again. You can then open it and print from it. It needs to be saved and closed the first time.

Also, try setting the margins for the field to something very large-- like 8 or 10:

set the margins of fld "fred" to 10

See if that doesn't help.
[url=http://www.altuit.com/webs/hemingway/Products/AltuitProducts.htm]Visit Altuit, creator of ButtonGadget and other Rev add-ons[/url]

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sat Oct 25, 2008 6:49 am

Printing from Revolution has always had an aura of black magic - but once you get the hang of it, you can do some very powerful things. The User Guide has an entire chapter devoted to it (pp 286-307) which does a great job on explaining how to print.

It also contains an entry on the 'formatForPrinting' property (pp. 292-293) and how you have to set it to true, save and then Close and remove from memory to make sure it's purged from memory - and then open it again, fill it up with data and print.

Maybe they should add a specific section that includes an annotated step-by-step example going from creating the 'formatForPrinting' stack to actually printing it.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Post by johnmiller1950 » Sun Oct 26, 2008 1:04 am

Chipp, I tried what you suggested without success. Thanks for the suggestions, though.

Jan, I tried to follow the user's guide to NO avail.

It sounds like you have done what I'm trying to do with success. Would it be too much trouble for you or someone else to send me a stack with a printing substack that actually works.

Again, the htmlText that I am trying to print follows:

<<p>Install new air <u><b>conditioner</b></u> in Storage Building #1. The rest of this line is a test to see if the <b>htmlText</b></p>
<p><u>command</u> will do away with the line wrapping.</p>

I am feeling really discouraged and stupid that I can't figure this out. I have tried dozens of different scripts and workarounds to get this to work, and it just won't. I would be ever so grateful. If someone would send me a working sample.

Thanks,
John

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sun Oct 26, 2008 10:21 am

I can send you the quick-and-dirty test stack that I wrote to verify my claims - if you PM me with your email address, I'd be happy to email it to you.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply