problem printing an image

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jwkrussel
Posts: 7
Joined: Thu Jan 14, 2010 9:35 pm

problem printing an image

Post by jwkrussel » Thu Jan 14, 2010 10:03 pm

I've created a stack to keep track of my genealogy and recently scripted a button to create a family tree, drawing lines with the pen tool. It all shows up on the screen beautifully, but when I try to print, the lines sometimes appear, sometimes they don't, sometimes they appear only in a specific area of the card. This is the case whether I print or save as a PDF. I can export a snapshot, but then the quality of the text deteriorates markedly.

Any suggestions?

bsouthuk
Posts: 261
Joined: Fri Dec 05, 2008 7:25 pm

Re: problem printing an image

Post by bsouthuk » Fri Jan 15, 2010 12:48 pm

Set the print format of image to true and this may improve it.

jwkrussel
Posts: 7
Joined: Thu Jan 14, 2010 9:35 pm

Re: problem printing an image

Post by jwkrussel » Fri Jan 15, 2010 10:29 pm

I am using a Mac and I hadn't tried that because the dictionary says it improves appearance for Windows. I just tried it anyway and it had no effect.

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

Re: problem printing an image

Post by Klaus » Sat Jan 16, 2010 12:11 pm

bsouthuk wrote:Set the print format of image to true and this may improve it.
You can only set "the formatforprinting" of a STACK!
And this only applies to windows, since Windows uses different fonts for printing than for the display!

Could you post your script please, jwkrussel?


Best

Klaus

jwkrussel
Posts: 7
Joined: Thu Jan 14, 2010 9:35 pm

Re: problem printing an image

Post by jwkrussel » Mon Jan 18, 2010 10:33 pm

I could post it, but it's about 300 lines long. Do you want to see the whole script?

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

Re: problem printing an image

Post by Klaus » Wed Jan 20, 2010 11:30 am

Hi jwk,
Do you want to see the whole script?
Erm, not really :D
Just post the (printing) relevant parts.


Best

Klaus

jwkrussel
Posts: 7
Joined: Thu Jan 14, 2010 9:35 pm

Re: problem printing an image

Post by jwkrussel » Wed Jan 20, 2010 8:14 pm

Here is the part of the script where the lines are drawn and text fields are positioned and their properties are set.

John

set visible of stack "lineage" to true
choose line tool
drag from horiz[0],vert[0][1] to horiz[1],vert[0][1]
create field
set width of last fld to w[0]
set height of last fld to fldh
set topleft of last fld to horiz[0]-4,vert[0][1]-10
set textFont of last fld to "New York"
set textSize of last fld to 9
set textAlign of last fld to left
set margins of last fld to 5
set dontWrap of last fld to true
set lockText of last fld to true
set opaque of last fld to false
set showBorder of last fld to false
set textHeight of last fld to 11
linefind ancestors[0][1],cnum,lnum
put line lnum of fld "Name" of card cnum of stack IndDB into line 1 of last fld
if linlin=1 and abs(line lnum of fld "Ancestry" of card cnum of stack "IndDB")=6 then
put "("&line lnum of fld "Name" of card cnum of stack IndDB&")" into line 1 of last fld
end if
put line lnum of fld "DOB" of card cnum of stack IndDB into dob
put line lnum of fld "DOD" of card cnum of stack IndDB into dod
if dod is not empty then
put "-" into hyp
else
put empty into hyp
end if
put dob&hyp&dod into line 2 of last fld
if placeflag=1 then put line lnum of fld "PoBi" of card cnum of stack IndDB into line 3 of last fld
repeat with i=1 to genct
put number of words of the keys of anccode into d
repeat with j=1 to d
if p[j] is not empty then
drag from horiz,vert[j] to horiz[i+1],vert[j]
else
drag from horiz,vert[j] to horiz[i+1]-3,vert[j]
end if
create field
set width of last fld to w
set height of last fld to fldh
set topleft of last fld to horiz-4,vert[i][j]-10
set textFont of last fld to "New York"
set textSize of last fld to 9
set textAlign of last fld to left
set margins of last fld to 5
set dontWrap of last fld to true
set lockText of last fld to true
set opaque of last fld to false
set showBorder of last fld to false
set textHeight of last fld to 11
if ancestors[i][j] is not empty then
linefind ancestors[i][j],cnum,lnum
put line lnum of fld "Name" of card cnum of stack IndDB into line 1 of last fld
if linlin=1 and abs(line lnum of fld "Ancestry" of card cnum of stack "IndDB")=6 then
put "("&line lnum of fld "Name" of card cnum of stack IndDB&")" into line 1 of last fld
end if
put line lnum of fld "DOB" of card cnum of stack IndDB into dob
put line lnum of fld "DOD" of card cnum of stack IndDB into dod
if dod is not empty then
put "-" into hyp
else
put empty into hyp
end if
put dob&hyp&dod into line 2 of last fld
if placeflag=1 then put line lnum of fld "PoBi" of card cnum of stack IndDB into line 3 of last fld
end if
end repeat
repeat with j=1 to d-1 step 2
drag from horiz[i],vert[i][j] to horiz[i],vert[i][j+1]
end repeat
end repeat

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

Re: problem printing an image

Post by Klaus » Thu Jan 21, 2010 9:17 am

Well, that LOOKS OK, but of course we cannot test this.
What does the "drag from... to ..." mean? I do not see a change of the tool!?

Please post the printing part of your script now.

jwkrussel
Posts: 7
Joined: Thu Jan 14, 2010 9:35 pm

Re: problem printing an image

Post by jwkrussel » Thu Jan 21, 2010 7:20 pm

The second line of the previously posted script is "choose line tool" so the drag commands draw the lines.

Here is the print script.

on mouseUp
hide button "Hide"
if visible of scrollbar "topscroll" then
put 1 into topflag
hide scrollbar "topscroll"
else
put 0 into topflag
end if
if visible of scrollbar "sidescroll" then
put 1 into sideflag
hide scrollbar "sidescroll"
else
put 0 into sideflag
end if
hide button "Print"
ask file "Save as: "
set the printerOutput to ("file:" & it )
print this card
show button "Print"
show button "Hide"
if topflag=1 then show scrollbar "topscroll"
if sideflag=1 then show scrollbar "sidescroll"
end mouseUp



Of course, most of the time the card is bigger than one page, so I don't get the whole card in the output file but that doesn't change the problem--sometimes the lines appear and sometimes they don't. The same is true if I use the menu print card command or if I alter the above script to send the output to a printer. I've tried this on two different machines with two different printers, and the result is the same.

John

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

Re: problem printing an image

Post by Klaus » Fri Jan 22, 2010 2:27 pm

Hi John,

hmm, sorry, everything looks OK, so I dont have a clue what's going on there?!
Since something GETS printed only means that your script do what you are supposed to do.
So I don't think there is something wrong with the scripts!

Hint:
You can:
...
print this card INTO x1,y1,x2,y2
## To make the output fit into a given (paper) rect
...

And you can also set "the printpaperoutput" as long as you printer drivers supply this size.


Best

Klaus

jwkrussel
Posts: 7
Joined: Thu Jan 14, 2010 9:35 pm

Re: problem printing an image

Post by jwkrussel » Fri Jan 22, 2010 5:54 pm

Klaus,

Thanks for taking a look at it. I know about the rectangles you mentioned but I didn't see much point in coding that if the printing wasn't going to work anyway.

John

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: problem printing an image

Post by BvG » Fri Jan 22, 2010 6:01 pm

the drag tool can be wonky at times, and is one of the oldest pieces of rev (legacy, so to say). So I tend to avoid it. maybe you can draw your lines using graphics instead?

example:

Code: Select all

--note: this code can't work, so adjust for what you actually want to do
repeat for each line theLine in the keys of horiz
put horiz[theLine],vert[theLine] & return &  horiz[theLine + 1],vert[theLine] & return & return after thePoints
end repeat
set the points of graphic "all my lines" to thePoints
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

jwkrussel
Posts: 7
Joined: Thu Jan 14, 2010 9:35 pm

Re: problem printing an image

Post by jwkrussel » Tue Jan 26, 2010 6:43 pm

BvG:

Thanks. That works perfectly. Problem solved.

John

Post Reply