PDF printing without printing

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Zood
Posts: 37
Joined: Mon Apr 24, 2017 7:17 pm

PDF printing without printing

Post by Zood » Tue Mar 27, 2018 11:15 pm

Hello all,

I am using the Open printing to pdf tPDFPath function, yet not without some issues
My goal: Save a piece of a card as a pdf-file without printing a physical sheet, so nothing gets sent to my printer.

A piece of my code:

Code: Select all

on mouseUp
   Ask file "Where do you want to store the file?"
   if "." is not in it then
      put it & ".pdf" into tPDFPath
   else put it into tPdfPath
   
   if the result is "Cancel" then
      go to previous card
      exit mouseUp
   end if
   
   set the visible of field "Number" of card "PrintCard" to true
   set the printmargins to 0,0,0,0
   set the printpaperorientation to portrait 
   open printing to pdf tPdfPath
   
   put the number of lines in field "PrintField" into tLines
   put field "PrintField" into tTotal
   put tLines / 32 into tTotalPrintNumbers2
   add 0.5 to tTotalPrintNumbers2
   put round(tTotalPrintNumbers2) into tTotalPrintNumbers
   put empty into tCounter
   if tLines > 32 then
      repeat until tTotaal < 32
         add 1 to tCounter
         put line 1 to 32 of tTotaal & CR & "Blz " & tCounter & " v/d " & tTotalPrintNumbers into field "PrintField"
         print card "PrintCard" from 317,-90 to 912,752
         delete line 1 to 32 of tTotaal
      end repeat
   else
      print card "PrintCard" from 317,-90 to 912,752
   end if
   close printing
   launch document tPdfPath
   go to previous card
end mouseUp
The PDF is created just fine, is launched just fine and everything is fine: I am happy!
just 1 thing: My printer also prints a copy of the pdf I have just created, that is the fault.
As I am using the "Print to pdf tPDFpath", should it not send anything to my printer?

Also funny: It only prints something when I try it on my windows standalone, on my Macbook nothing gets printed

Any help is useful!

Thanks in advance

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 258
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: PDF printing without printing

Post by thatkeith » Wed Mar 28, 2018 8:08 am

That does seem strange. From the Dictionary:
The open printing to pdf command starts a print loop that outputs
directly to a PDF file rather that the currently configured printer.
Have you tried simplifying your code as much as possible purely for testing purposes? A simple "hello PDF world" kind of thing?
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
360 VR media specialist

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 171
Joined: Thu Apr 18, 2013 2:48 pm

Re: PDF printing without printing

Post by livecodeali » Wed Mar 28, 2018 8:17 am

What version are you using? There was a bug in 9 recently with the loading of revPdfPrinter which is possibly what you are seeing: https://quality.livecode.com/show_bug.cgi?id=20814

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6258
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: PDF printing without printing

Post by dunbarx » Wed Mar 28, 2018 3:39 pm

Do test with v.8.

I have had no issues at all with "open printing to pdf".

Craig Newman

Zood
Posts: 37
Joined: Mon Apr 24, 2017 7:17 pm

Re: PDF printing without printing

Post by Zood » Wed Mar 28, 2018 8:23 pm

Currently using 9.0.0 DP11 but will try with V8, I will let you know!

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 171
Joined: Thu Apr 18, 2013 2:48 pm

Re: PDF printing without printing

Post by livecodeali » Wed Mar 28, 2018 8:38 pm

It’s fixed in 9 RC 1 also, if you want to stick with 9.

Post Reply

Return to “Talking LiveCode”