Page 1 of 1

Printing to pdf has a bug

Posted: Sat Nov 19, 2011 7:20 pm
by Happyrever
The following code will print to a paper printer or adobe pdf with no problem, but will not work properly with the Livecode pdf generator.

The case is where there are text fields and an image area printed by a single enclosing rectangle.
During each loop, the text and image fields are propogated and then the enclosing rectangle is printed.
To ensure the image is in place before any enclosing rectangle is printed, I introduced answer and the variable with the current loop count.
The result with the Livecode pdf generator was that only two images of the three pages were visible in the pdf, everything else was fine.
After removing the answer code and the parts to print to pdf and adding answer printer, the result was perfect to paper or adobe.
Similar code to print a page at a time, using livecode "to pdf " also gave perfect results.

Global WorkFolder,TemplateNumber,tFileID,tSelLine,TCurrentPage,TotalPages,VarDeleteLine5,VarDeleteLine7,VarDeleteLine8,VarDeleteLine29
global VarDeleteLine30,VarDeleteLine43,VarDeleteLine44,VarDeleteLine61,VarDeleteLine62
on mouseUp
Local TmpFileNm,NumLines,tempvar
local tHeaderRect,tBodyRect,tFooter1Rect,tFooter2Rect
set the dashes of graphic "FrontBorder"on card 1 to 200,0 --Needed to correct a dases when printing
set the dashes of graphic "Border"on card 2 to 200,0 --Needed to correct a dases when printing
--print routine
reset printing
answer printer --only added to print to paper or adobe during testing
set the formatforprinting of this stack to true
set the printmargins to 50,35,10,10
set the printpaperorientation to "landscape"
set the printcolors to true
--set the printcardborders to true
get the printRectangle
set the printscale to 0.75
open printing --to pdf "Album.pdf" -- Commented out when using adobe or paper
print card 1 from the topLeft of graphic "FrontBorder" on card 1 to the bottomRight of graphic "FrontBorder" on card 1
repeat with tempvar = 1 to TotalPages
put tempvar into tSelLine
call "mouseup" of button "Generate page" on card 2
--answer tempvar -- Only used with livecode to make sure the image had fully appeared on screen before printing
print card 2 from the topLeft of graphic "OuterRect" on card 2 to the bottomRight of graphic "OuterRect" on card 2
end repeat
close printing
--launch document "Album.pdf"-- Commented out when using adobe or paper
set the formatforprinting of this stack to false
--end of print routine
end mouseUp

If anyone wants to see the problem in the context of the application then I can send the stack. Just ask