printing blank page first occasionally

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

printing blank page first occasionally

Post by jalz » Thu May 11, 2017 8:30 pm

Hello all,

I've copied my printing script below. For the most part it works fine, however during some times it prints a blank page first and then the contents of my pages afterwards. This is infrequent, but I am wondering why its occurring. Can someone help me with any pointers please?

Code: Select all


global gPageOrientation, gMarginLeft, gMarginTop, gMarginRight, gMarginBottom


on mouseUp 
   
   lock screen
   
   put the number of this card into tStartCard 
   put "Portrait" into gPageOrientation
   set the printPaperOrientation to gPageOrientation
   put printPaperSize into tPageSize
   set itemdelimiter to comma
   
   if gPageOrientation is "Portrait" then
      put item 1 of tPageSize into tPageWidth
      put item 2 of tPageSize into tPageHeight
   else
      put item 1 of tPageSize into tPageHeight
      put item 2 of tPageSize into tPageWidth
   end if
   
   open printing with dialog
   
   set the printMargins to 0,0,0,0
   
   if the result is "Cancel" then exit mouseUp
   
   go to stack "Print"
   
   put the number of cards of stack "Print" into tTotalPages
   
   put 1 into tPageNo
   repeat until tPageNo > tTotalPages
      
      go to card tPageNo
      
      put the short name of this cd into tCardName
      put "Grp_" & tCardName into tGroupName 
      
      hide graphic "margin"
      put the vScrollbar of group tGroupName into tVScrollTF
      put the hScrollbar of group tGroupName into tHScrollTF
      
      if tVScrollTF is true then
         put the formattedHeight of group tGroupName into tGrpHeight
         put the vScroll of grp tGroupName into tVScrollPos
         set the height of group tGroupName to tGrpHeight
         set the top of group tGroupName to 0
      end if
      
      if tHScrollTF is true then
         put the formattedWidth of group tGroupName into tGrpWidth
         put the hScroll of grp tGroupName into tHScrollPos
         set the width of group tGroupName to tGrpWidth
         set the left of group tGroupName to 0
      end if
      
      
      set the vScrollbar of group tGroupName to false
      set the hScrollbar of group tGroupName to false
      
      
      print card tPageNo from 1,55 to  (tPageWidth - 1) , (tPageHeight + 54)
      
      add 1 to tPageNo
      show graphic "margin"
      
      
      set the rect of grp tGroupName to the rect of this cd
      set the vScrollbar of group tGroupName  to (the formattedHeight of group tGroupName  > the height of group tGroupName )  
      set the hScrollbar of group tGroupName  to (the formattedWidth of group tGroupName  > the width of group tGroupName ) 
      
      if tVScrollTF is true then
         set the vScroll of grp tGroupName to tVScrollPos
      end if
      
      if tHScrollTF is true then
         set the hScroll of grp tGroupName to tHScrollPos
      end if
      
      
   end repeat
   
   
   
   
   close printing -- sends job to printer
   
   go to card tStartCard
   
   unlock screen
   
end mouseUp





MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: printing blank page first occasionally

Post by MaxV » Mon May 15, 2017 11:46 am

Hi,
I cleaned your code:

########CODE to copy and paste#######
on mouseUp
lock screen

put the long id of this card into tStartCard

set the printPaperOrientation to "portrait"
put printPaperSize into tPageSize
set itemdelimiter to comma
put item 1 of tPageSize into tPageWidth
put item 2 of tPageSize into tPageHeight
set the printMargins to 0,0,0,0


open printing with dialog
if the result is "Cancel" then exit mouseUp

go to stack "Print"
put the number of cards of stack "Print" into tTotalPages
repeat with i=1 to tTotalPages

go to card i

put the short name of this cd into tCardName
put "Grp_" & tCardName into tGroupName

hide graphic "margin"
put the vScrollbar of group tGroupName into tVScrollTF
put the hScrollbar of group tGroupName into tHScrollTF

if tVScrollTF is true then
put the formattedHeight of group tGroupName into tGrpHeight
put the vScroll of grp tGroupName into tVScrollPos
set the height of group tGroupName to tGrpHeight
set the top of group tGroupName to 0
end if

if tHScrollTF is true then
put the formattedWidth of group tGroupName into tGrpWidth
put the hScroll of grp tGroupName into tHScrollPos
set the width of group tGroupName to tGrpWidth
set the left of group tGroupName to 0
end if


set the vScrollbar of group tGroupName to false
set the hScrollbar of group tGroupName to false


print card tPageNo from 1,55 to ( (tPageWidth - 1) , (tPageHeight + 54))

show graphic "margin"

set the rect of grp tGroupName to the rect of this cd
set the vScrollbar of group tGroupName to (the formattedHeight of group tGroupName > the height of group tGroupName )
set the hScrollbar of group tGroupName to (the formattedWidth of group tGroupName > the width of group tGroupName )

if tVScrollTF is true then
set the vScroll of grp tGroupName to tVScrollPos
end if

if tHScrollTF is true then
set the hScroll of grp tGroupName to tHScrollPos
end if

end repeat

close printing -- sends job to printer

go to card tStartCard

unlock screen

end mouseUp



#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-6#####

See if this correct your problem. :D
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”