Page 1 of 1

Open Printing to PDF

Posted: Thu Nov 24, 2016 3:29 am
by maxs
I'm using the Open Printing to PDF "MyPDF" command, yet nothing seems to happen and the rest of the script stops working.

Does it make a PDF of the card?

How does this work? Does if create a pdf the can be accessed by a printer?

Max

Re: Open Printing to PDF

Posted: Thu Nov 24, 2016 12:24 pm
by Klaus
Hi Max,

especially on iOS you need to open printing to a PDF file where you have write permissions!
...
Open Printing to PDF "MyPDF.pdf"
...
will try to save the PDF in the current folder which maybe the ENGINE folder where you do not have write permissions!
Try something like this:
...
put specialfolderpath("documents") & "/Yourpdf.pdf" into tPDFFile
open printing to PDF tPDFFile
...

Best

Klaus

Re: Open Printing to PDF

Posted: Wed Jan 04, 2017 10:55 am
by maxs
Thank you Klaus,

Thanks for the help. How do I access or find the file on the Ipad after it's created? Max

Re: Open Printing to PDF

Posted: Wed Jan 04, 2017 11:17 am
by Klaus
Hi Max,

been busy? :D

Not sure I understand your question, you created the file so you know where it is, not?

Code: Select all

...
put specialfolderpath("documents") & "/Yourpdf.pdf" into tPDFFile
## Creates the pathname to the PDF file
## Now do what you want with tPDFFile now.
...
Best

Klaus

Re: Open Printing to PDF

Posted: Wed Jan 04, 2017 8:24 pm
by maxs
Hi Klaus,

The documentation says
Starts a print loop that outputs directly to pdf rather that the currently configured printer.

It seems that I can print a card to a PDF file that is in a special "documents" folder. NO?
So where is the documents folder on the Ipad?

I seem to be completely misunderstanding this command.

Max

Re: Open Printing to PDF

Posted: Wed Jan 04, 2017 8:51 pm
by Klaus
Hi Max,
maxs wrote:It seems that I can print a card to a PDF file that is in a special "documents" folder.
yes, exactly! And logical, since you need to supplay a valid filename.
maxs wrote:So where is the documents folder on the Ipad?
Inside of your application package.
Due to "sandboxing" every app has its own "documents" folder.

Sorry, cannot provide more info since I don't develop for mobile nor do I own any mobile device.
Yes, no cell phone, that's me! :D


Best

Klaus

Re: Open Printing to PDF

Posted: Thu Jan 05, 2017 12:58 am
by Batninja
Hi here is my button script in an iPhone app that prints a sub stack as a pdf and then displays in the mergReader external

Code: Select all

on mouseUp
   --lock the screen as it seems you have to go to sub stack at least once to print it, I got glitches otherwise
   lock screen
   -- go to the stack to print
   go to stack "a4paper"
   --default margins are 72 points = 1 inch so reset to zero
   set the printMargins to 0, 0, 0, 0
   -- set the print path to the app documents folder
   put specialFolderPath("documents") & "/frame.pdf" into tFilePath
   --prepare the PDF document to the file path
   open printing to PDF tFilePath
   --specify the card to print and the area of the card (divide by 72 to get size)
   print card "pdfprint" of stack "a4paper" from 0,0 to 595,841
   --do the printing
   close printing
   --return to the main stack
   go to stack "PDFPrinter"
   -- all done
   unlock screen
   --use the mergReader external to display the pdf and offer printing email etc.
   mergReader tFilePath
end mouseUp
Notes:

1. PDF print by default only prints the visible potion of the card, so if using an A4 or US sized card you need to specify the print area (i.e. 595x841 px for A4) since the iPhone shows a smaller screen area

2. Best to use a sub stack because of 1.

3. The mergReader extension is great, remember to include both it and the PDF printer in the IOS application inclusions

4. The "documents" app file location is the only place you can save files to (you can include pdf's when building but they end up in the "engine" folder and as far as i can tell its best to leave that alone - this is set as tFilePath with a file name of "frame.pdf"

5. I seem only able to output US letter sized PDF's not A4 size (see previous post) - if this is the case then the solution is to specify a pdf size of 8.27 inches (A4 width) by 11 inches (US letter height) i.e. 595 px x 792 px

6. I'm not sure if specifying say a double sized PDF would result in a higher quality photo output when scaled down to actual page size.

Hope this helps

Roger

Re: Open Printing to PDF

Posted: Thu Jan 05, 2017 9:21 am
by maxs
ROger,

Thank you so much for this additional information.

Max

Re: Open Printing to PDF

Posted: Thu Jan 05, 2017 11:32 am
by jmburnod
Hi Max,
where is the documents folder on the Ipad?
As Klaus said every app has its own "documents" folder.
You can see it with iTunes if you set "file sharing" of your app to true in the standalone application setting.
Best regards
Jean-Marc

Re: Open Printing to PDF

Posted: Thu Jan 05, 2017 5:27 pm
by maxs
Thanks. This is very good to know. Max

Re: Open Printing to PDF

Posted: Fri Jan 27, 2017 5:43 am
by quailcreek
This is a thread that I went thru when I was doing something similar. It might give you some ideas.

http://forums.livecode.com/viewtopic.php?f=49&t=24391

Re: Open Printing to PDF

Posted: Sun Jan 29, 2017 7:07 pm
by maxs
Thanks Tom, there is alot of good stuff here.