Page 1 of 1
printing to pdf - issue multiple close printing commands
Posted: Mon Nov 04, 2013 5:51 pm
by jawall
Hi,
I need to issue multiple open pdf printing - close printing commands one after the other. Does not work.
Background:
My stack takes multiple folders dropped on it. For each folder the images in it are placed onto cards in my stack, printed to 1 pdf file, cards are deleted again, next folder same procedure, another pdf file.
It works if I drop 1 folder and thus the print routine is called once. No luck with more than 1 folder.
I tried:
waiting for some seconds after the "close printing" command, did not help.
Anyone has an idea how to do it?
Thank you
Jürgen
Re: printing to pdf - issue multiple close printing commands
Posted: Mon Nov 04, 2013 11:07 pm
by dunbarx
Not sure about this, but the dictionary, under "open printing to pdf" gives this as an example
Code: Select all
on printSomeCards
global cardsToPrint
open printing to pdf "test.pdf"
if the result is "Cancel" then exit printSomeCards
repeat with x = 1 to the number of lines of cardsToPrint
print card (line x of cardsToPrint)
end repeat
close printing -- send group of cards to printer
end printSomeCards
It seems that the print queue is set by using the "print card" command, not by stacking "open" and "close" print commands. Hope this helps...
Craig Newman
Re: printing to pdf - issue multiple close printing commands
Posted: Tue Nov 05, 2013 7:08 am
by jawall
Yes, you are right
"open printing" opens a printing queue
"print card" adds this card to the queue
"close printing" sends queue to the printer
That's also what I understand and do in my stack. Only in my example, I have to repeat this like in
Code: Select all
repeat with y = 1 to the number of droppedFolders
-- get all the file names in that folder and do some stuff
-- make 1 card for every image in that folder
repeat with i = 1 to the number of cards
--fill the cards with images, do some more stuff
end repeat
put the filename of image 1 of cd 1 & "_myPDF.pdf" into f -- just as an example
printIt f
--delete all the cards (but first) after each run so I can start over with the next dropped folder
end repeat
on printIt aPath
repeat with n = 1 to the number of cds
put the short name of cd n & return after printQueue
end repeat
open printing to pdf to aPath
repeat with x = to the number of lines of printQueue
print card line x of printQueue
print break
end repeat
close printing
end printIt
The made up example works with 1 dropped folder, but not with multiple folders
Re: printing to pdf - issue multiple close printing commands
Posted: Tue Nov 05, 2013 10:59 am
by bn
Hi Jürgen,
I tried with 2 folder with 2 images each and a stack with 2 cards one image object on each card. On card 1 is a field onto which I dropped the 2 folders with the two images. Card 1 also has one button. The script of the button is:
Code: Select all
on mouseUp
put the defaultFolder into tOldDefault
put field 1 into tFolders
repeat with i = 1 to the number of lines of tFolders
put line i of tFolders & "/" into tTheFolder
set the defaultFolder to tTheFolder
put the files into tFiles
--filter tFiles with "*.jpg"
repeat with j = 1 to the number of lines of tFiles
put (tTheFolder & line j of tFiles) into tFileName
set the filename of image 1 of card j to tFileName
end repeat
-- get all the file names in that folder and do some stuff
-- make 1 card for every image in that folder
-- repeat with i = 1 to the number of cards
-- --fill the cards with images, do some more stuff
-- end repeat
put the filename of image 1 of cd 1 & "_myPDF.pdf" into f -- just as an example
printIt f
--delete all the cards (but first) after each run so I can start over with the next dropped folder
end repeat
end mouseUp
on printIt aPath
repeat with n = 1 to the number of cds
put the short id of cd n & return after printQueue
end repeat
open printing to pdf aPath
repeat with x = 1 to the number of lines of printQueue
print card id line x of printQueue
print break
end repeat
close printing
end printIt
I tried to stick as close as posible to your example (without deleting cards)
This worked without a problem, in each of the two folders was a pdf with the two images of the folder.
So there might be another problem in your script. I would try to test your script with a simpler setUp and then build up from there. And I would try to look into the variables in the debugger.
Kind regards
Bernd
Re: printing to pdf - issue multiple close printing commands
Posted: Tue Nov 05, 2013 3:36 pm
by jawall
Hey Bernd,
you pointed me in the right direction, the problem was elsewhere (in the variables), but I could have sworn...
Why does it have to be that after about 20 years of scripting HyperCard, Livecode and others that the same old stupid mistakes keep happening? I guess it's a case of: "Same old stupid habits, same old fucking problems, same old me" (French, Frith, Kaiser, Thompson on "Live, Larf, Leave, Loaf)
Thank you both for your help!
Jürgen
Re: printing to pdf - issue multiple close printing commands
Posted: Tue Nov 12, 2013 12:40 pm
by aleezysam
I realise I can create a separate stack / card and show it, then have it dismiss itself after xxx seconds, but it seems like I would have to add lots of extra code to get the custom stack to show in a viable place, resize itself to the contents of the message etc etc and I'm just wondering if its possible at all to add code to have the existing answer dialog box close without user input.
Re: printing to pdf - issue multiple close printing commands
Posted: Tue Nov 12, 2013 1:27 pm
by bn
Hi aleezysam,
welcome to the Forum.
make a new stack with 1 button and 1 field
put this script into the button
Code: Select all
on mouseUp
put "close stack " & quote & "answer dialog" & quote into tMessage
send tMessage to stack "answer dialog" in 3 seconds -- change duration of dialogue before closing
get empty -- just to make shure it is empty
answer "test" with "Cancel" and "OK"
put it into field 1 -- it is either empty when the stack closes without user interaction or the text of the button the user clicked
end mouseUp
it should do the trick
Kind regards
Bernd