Export a pdf from Runrev

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trailboss
Posts: 121
Joined: Sat Dec 13, 2008 4:55 pm

Export a pdf from Runrev

Post by trailboss » Sat Apr 13, 2013 6:59 pm

I can export a field in the form of rtf, txt, doc., and even html from runrev.

like this:

on mouseUp
set the defaultFolder to specialFolderPath("desktop")
put the rtfText of fld "Narrative" into url "file:Finished Narrative.rtf"
launch document "Finished Narrative.rtf"
end mouseUp

Piece of cake. But when I try to make a pdf, it doesn't work. Is there a way? I've looked at what's posted here and I don't dig.

Hoping it's easy, I remain

Faithfully yours,
Tom

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Export a pdf from Runrev

Post by Simon » Sat Apr 13, 2013 9:49 pm

Hi Tom,
Have you looked up:
open printing to pdf
in the dictionary?

It's how you make a pdf formatted file. Little more complicated than just "put into url..." but not that much.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

trailboss
Posts: 121
Joined: Sat Dec 13, 2008 4:55 pm

Re: Export a pdf from Runrev

Post by trailboss » Sun Apr 14, 2013 1:52 am

Simon (or anyone),

You know I was trying the lesson on this at:

http://lessons.runrev.com/s/lessons/m/4 ... g-livecode

I uploaded their stack but whenever I executed the printcards handler my runrev Studio complained that it couldn't find the handler. I tried it with the new free open source LIVECODE and it saved the file! Nice.

Two questions remain:
1. I'd like to make a royalty-free standalone with my Studio version. This doesn't seem to work in Studio. Is there another way to make it work there?
2. You mentioned the dictionary. The dictionary for the new open source LiveCode has got PLENTY more on this pdf creating stuff. I looked, and I think I get somewhere fairly fast with that. But, again, I want to make a Studio version...
3. Is there a nice easy lesson somewhere?

(Don't get me wrong; I want to get the benefit of royalty-free standalones because I twice paid for the Studio version, but I will pay the runrev people whatever. They deserve all the bread coming to them.)

Many thanks,

Tom

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Export a pdf from Runrev

Post by Simon » Sun Apr 14, 2013 3:01 am

Hi Tom,
Sorry, I don't know the limitations of Studio.
In the standalone setting "select inclusions for the standalone..." can you see if you can select PDF printer? If you can I would think that Studio should work.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

trailboss
Posts: 121
Joined: Sat Dec 13, 2008 4:55 pm

Re: Export a pdf from Runrev

Post by trailboss » Sun Apr 14, 2013 6:22 am

Simon,
Thanks for the tip. I checked. No PDF in my Studio version but there's a check button in the new LiveCode, so that says it all.
Tom

lowland
Posts: 2
Joined: Tue Mar 06, 2012 8:23 pm

Re: Export a pdf from Runrev

Post by lowland » Wed Jul 03, 2013 12:13 am

Hi did you ever get this to work I am working with windows any suggestions would be great

Stephen

trailboss
Posts: 121
Joined: Sat Dec 13, 2008 4:55 pm

Re: Export a pdf from Runrev

Post by trailboss » Fri Jul 05, 2013 5:20 pm

Stephen,

Here's what I did by cannibalizing around. Excuse the commented out lines. Give it a try.

1. I made a stack called PdfMaker and put a field on it called PdfField on its card 1:

on mouseUp
global pdfname
put "Finished Document.pdf" into pdfname
open stack "MyPdfStack"
go cd 1 of stack "MyPdfStack"
close stack "MyPdfStack"
end mouseUp

2. I made a substack called "MyPdfStack" with the following stack script.
The stack has four cards with a field on each one called page1 (for the first card) and page2, page3, and page4 on the other three.


ON OPENSTACK

set the loc of this stack to the screenLoc
put cd fld "PdfField" of cd 1 of stack "PDFmaker" into cd fld "page1" of cd 1 of stack "MyPdfStack"

printcards


end OPENSTACK

ON OPENstack
set the loc of this stack to the screenLoc
put cd fld "PdfField" of cd 1 of stack "PDFmaker" into cd fld "page1" of cd 1 of stack "MyPdfStack"

printcards


end OPENstack

on printCards
## Path to the pdf file we want to create
put specialFolderPath("desktop") & "/Finished Document.pdf" into tPDFPath

open printing to pdf tPDFPath
if the result is "Cancel" then
## The user has cancelled printing
exit printCards
else
print card 1 of this stack into 0,0,575,800
--print bookmark "1 Introduction" with level 1 at 4,2
--print bookmark "1.1 Welcome" with level 2 at 4,96

if not (fld page2 of cd 2 is empty) then
print break
print card 2 of this stack into 0,0,575,800
print link to url "http://lessons.runrev.com" with rect 408,34,518,52
end if

if not (fld page3 of cd 3 is empty) then
print break
print card 3 of this stack into 0,0,575,800
print link to url "http://lessons.runrev.com" with rect 408,34,518,52
end if
if not (fld page4 of cd 4 is empty) then
print break
print card 4 of this stack into 0,0,575,800
print link to url "http://lessons.runrev.com" with rect 408,34,518,52
end if
print break
## Print bookmarks
--print bookmark "1.2 Where to begin" with level 2 at 4,2
--print bookmark "1.3 System Requirements" with level 2 at 4,96
--print bookmark "1.3.1 All Operating Systems" with level 3 at 4,273
--print bookmark "1.3.2 Requirements for Windows System" with level 3 at 4,414
--print bookmark "1.3.3 Requirements for Linux Systems" with level 3 at 4,605
end if
Answer "Your PDF document is entitled 'Finished Document.pdf' and it will be saved on the desktop and launched."

--launch document specialFolderPath("desktop") & "/Finished Narrative.pdf"
launch document tPDFPath
close printing

end printCards

Post Reply

Return to “Talking LiveCode”