Printing to PDF stops after some pages

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

Printing to PDF stops after some pages

Post by Martin-HC » Mon Mar 10, 2025 4:24 pm

I have a stack of about 12 cards (each card contains 7 fields with 54 lines of text each) that I want to print to a pdf. That works fine up to page 7. On the eighth page, the data that is printed to the pdf stops somewhere halfway. I can send the same file directly to a printer and then all 12 pages are printed completely.

Is there a limit to the amount of data that you can write to a pdf? Or is something else going on?
After each page I use the command "print break"; my script is basically this:

open printing to pdf tPDFPath
put 36,36,559,806 into tRect
repeat with i=1 to the number of cards
print card i into tRect
print break
end repeat
close printing

scott_morrow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 38
Joined: Tue Jun 27, 2006 8:35 pm
Contact:

Re: Printing to PDF stops after some pages

Post by scott_morrow » Tue Mar 11, 2025 9:33 am

If you are experiencing this on mobile then one explanation could be that an emoji is encountered in the text being printed. (Bug 22982 was reported and confirmed in 2020 but has not been addressed.) When this happens using print card and close printing the result is "printing failed" and the field containing the emoji only renders to the point where the emoji is encountered.
Elementary Software
...now with 20% less chalk dust!

Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

Re: Printing to PDF stops after some pages

Post by Martin-HC » Tue Mar 11, 2025 10:35 am

No, I'm experiencing this on Win10 and in the IDE environment. No special characters are being used, just plain text.

Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

Re: Printing to PDF stops after some pages

Post by Martin-HC » Wed Mar 12, 2025 5:02 pm

Martin-HC wrote:
Mon Mar 10, 2025 4:24 pm
I have a stack of about 12 cards (each card contains 7 fields with 54 lines of text each) that I want to print to a pdf. That works fine up to page 7. On the eighth page, the data that is printed to the pdf stops somewhere halfway. I can send the same file directly to a printer and then all 12 pages are printed completely.

Is there a limit to the amount of data that you can write to a pdf? Or is something else going on?
After each page I use the command "print break"; my script is basically this:

open printing to pdf tPDFPath
put 36,36,559,806 into tRect
repeat with i=1 to the number of cards
print card i into tRect
print break
end repeat
close printing
Has anyone an idea how this can happen?

I use this app to create account statements for clients. Most clients get away with a few A4 pages, but clients with a high turnover sometimes need as much as 12 pages. I can't however go beyond 8 pages.
The length of the text that I'm exporting/printing to PDF is 16 kb at most.

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

Re: Printing to PDF stops after some pages

Post by Klaus » Wed Mar 12, 2025 5:10 pm

Hi Martin,

maybe a little WAIT will help?

Code: Select all

...
open printing to pdf tPDFPath
put 36,36,559,806 into tRect
repeat with i=1 to the number of cards
print card i into tRect
print break
wait 50 millisecs with messages
end repeat
close printing
...
Just guessing...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Printing to PDF stops after some pages

Post by bn » Wed Mar 12, 2025 6:28 pm

There seems to be something going on with printing PDFs running Windows 64 bit

https://quality.livecode.com/show_bug.cgi?id=23088

Since I do not have a Windows computer I can not test.

Kind regards
Bernd

Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

Re: Printing to PDF stops after some pages

Post by Martin-HC » Thu Mar 13, 2025 7:39 am

Klaus wrote:
Wed Mar 12, 2025 5:10 pm
Hi Martin,

maybe a little WAIT will help?

Code: Select all

...
open printing to pdf tPDFPath
put 36,36,559,806 into tRect
repeat with i=1 to the number of cards
print card i into tRect
print break
wait 50 millisecs with messages
end repeat
close printing
...
Just guessing...
Hi Klaus,
Thanks, I already tried wait 1 second after the print break but that did not work. However, when I use your 'wait 50 milliseconds with messages' (I did not know about the 'with messages' statement) it instantly worked and I got a complete pdf. Problem solved! :D

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

Re: Printing to PDF stops after some pages

Post by Klaus » Thu Mar 13, 2025 1:42 pm

Hi Martin,
Martin-HC wrote:
Thu Mar 13, 2025 7:39 am
Hi Klaus,
Thanks, I already tried wait 1 second after the print break but that did not work. However, when I use your 'wait 50 milliseconds with messages' (I did not know about the 'with messages' statement) it instantly worked and I got a complete pdf. Problem solved! :D
SUPER! :D

Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Printing to PDF stops after some pages

Post by FourthWorld » Thu Mar 13, 2025 5:29 pm

Good to have a workaround, but needing to add a wait is odd. That detail seems useful to add to the bug report.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Printing to PDF stops after some pages

Post by dunbarx » Thu Mar 13, 2025 5:29 pm

Nice job, Klaus.

But is this something that the team ought to know about? Of course it was not the length of time that mattered, but the "with messages". This must have come up before, since even I make PDF's out of LC data.

Craig

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

Re: Printing to PDF stops after some pages

Post by Klaus » Thu Mar 13, 2025 5:44 pm

I added a note to the above mentioned bug report.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Printing to PDF stops after some pages

Post by FourthWorld » Thu Mar 13, 2025 6:17 pm

Klaus wrote:
Thu Mar 13, 2025 5:44 pm
I added a note to the above mentioned bug report.
Thank you, Klaus. This is an odd one, but I'm sure the team will be able to pin it down.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 324
Joined: Sat Aug 16, 2008 9:48 am
Contact:

Re: Printing to PDF stops after some pages

Post by SWEdeAndy » Fri Mar 14, 2025 12:19 pm

Well, I'm happy this solved it for Martin-HC's case, but I'm afraid it's not a complete workaround for all cases. As can be gleaned from the last sentence of my last comment on that bug report: "I've tried putting in a "wait x secs with messages" to give some breathing space, but that has not prevented the crashing."...

That was early 2024 and my workaround is still to build a 32-bit app instead of 64-bit, as the problem (at least for me) only occurs with 64-bit LC/standalone.

But the fact that wait with messages seems to affect the problem at least partly is of course interesting. I will at some point, when time allows, go back into that code and see where exactly I did put the 'wait with messages'. I believe finding a reliable workaround is a better bet than waiting for a bugfix in LC Classic anyway, these days...
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com

Post Reply