Page 1 of 1

Printing to PDF stops after some pages

Posted: Mon Mar 10, 2025 4:24 pm
by Martin-HC
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

Re: Printing to PDF stops after some pages

Posted: Tue Mar 11, 2025 9:33 am
by scott_morrow
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.

Re: Printing to PDF stops after some pages

Posted: Tue Mar 11, 2025 10:35 am
by Martin-HC
No, I'm experiencing this on Win10 and in the IDE environment. No special characters are being used, just plain text.

Re: Printing to PDF stops after some pages

Posted: Wed Mar 12, 2025 5:02 pm
by Martin-HC
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.

Re: Printing to PDF stops after some pages

Posted: Wed Mar 12, 2025 5:10 pm
by Klaus
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...

Re: Printing to PDF stops after some pages

Posted: Wed Mar 12, 2025 6:28 pm
by bn
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

Re: Printing to PDF stops after some pages

Posted: Thu Mar 13, 2025 7:39 am
by Martin-HC
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

Re: Printing to PDF stops after some pages

Posted: Thu Mar 13, 2025 1:42 pm
by Klaus
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

Re: Printing to PDF stops after some pages

Posted: Thu Mar 13, 2025 5:29 pm
by FourthWorld
Good to have a workaround, but needing to add a wait is odd. That detail seems useful to add to the bug report.

Re: Printing to PDF stops after some pages

Posted: Thu Mar 13, 2025 5:29 pm
by dunbarx
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

Re: Printing to PDF stops after some pages

Posted: Thu Mar 13, 2025 5:44 pm
by Klaus
I added a note to the above mentioned bug report.

Re: Printing to PDF stops after some pages

Posted: Thu Mar 13, 2025 6:17 pm
by FourthWorld
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.

Re: Printing to PDF stops after some pages

Posted: Fri Mar 14, 2025 12:19 pm
by SWEdeAndy
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...