Create a PDF with LiveCode server

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: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Create a PDF with LiveCode server

Post by PaoloMazza » Tue Jun 28, 2016 2:17 pm

Hi all,
do I need use Qartam to create a PDF with LiveCode server or I can trigger the "open printing to pdf" command in a LiveCode stack?
Can I use the on-rev.com server with LiveCode server 6.5 ?
Best regards,
Paolo Mazza
Paolo Mazza
Italy

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Create a PDF with LiveCode server

Post by PaoloMazza » Wed Jun 29, 2016 10:49 am

I switched to LiveCode Server 7.1
I inserted the following code in my stack "printpdf.livercode" and when I trigger my command "stampaPdf" i get the OK message from the server.
However I can not see any PDF file in the folder. Why?
I set the permissions of the folder to 777. This stack works fine locally. Any idea?


function PrintPdf myfilename myoptions
 reset printing
 set the formatforprinting of this stack to "false"
set the printPaperSize to "842,595" # e.g. for A4: 595,842
 set the printMargins to 0,0,0,0
open printing to PDF myfilename with options myoptions
 print this card
 close printing
 reset printing
end PrintPdf

on StampaPdf

go to card 1 of this stack

-- nome del file pdf
set itemdelimiter to "/"
put the filename of this stack into myfilename
put "document1.pdf" into last item of myfilename

put PrintPdf(myfilename,myoptions) into MessErr

if MessErr is empty then
put "OK"
else
put MessErr
end if

end StampaPdf
Paolo Mazza
Italy

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2161
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Create a PDF with LiveCode server

Post by [-hh] » Wed Jun 29, 2016 11:14 am

Edit. Was wrong, sorry.
Last edited by [-hh] on Wed Jun 29, 2016 11:33 am, edited 1 time in total.
shiftLock happens

Klaus
Posts: 11274
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Create a PDF with LiveCode server

Post by Klaus » Wed Jun 29, 2016 11:28 am

I don't see anything itemdelimiter related in the "printPDF" function!?

However:
1. The parameters should be separated by comma -> function PrintPdf myfilename, myoptions
2. The parameter "myoptions" is EMPTY, so it will resolve to the string "myoptions", but the engine exspects an ARRAY here.

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Create a PDF with LiveCode server

Post by PaoloMazza » Wed Jun 29, 2016 12:01 pm

My script works locally and create the pdf.
But in the server it does not work.
Paolo Mazza
Italy

Klaus
Posts: 11274
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Create a PDF with LiveCode server

Post by Klaus » Wed Jun 29, 2016 12:07 pm

What is still puzzling me is that I am not sure that Livecode Server actually
can work with stacks except for library stacks!?

Or did I miss that new "feature" of LC server?

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Create a PDF with LiveCode server

Post by PaoloMazza » Wed Jun 29, 2016 1:30 pm

Hi Klaus,

I changed the script according to your suggestions, but still the following script do not work using the on-rev LiveCode Server ; I get the OK message but not any pdf shows up in the folder.

function PrintPdf myfilename, myoptions
 reset printing
 set the formatforprinting of this stack to "false"
set the printPaperSize to "842,595" # e.g. for A4: 595,842
 set the printMargins to 0,0,0,0
open printing to PDF myfilename with options myoptions
 print this card
 close printing
 reset printing
end PrintPdf

on StampaPdf

go to card 1 of this stack

-- nome del file pdf
set itemdelimiter to "/"
put the filename of this stack into myfilename
put "attestato.pdf" into last item of myfilename

-- opzioni pdf
put "xxx" into myoptions["Title"]
put "xx" into myoptions["Author"]

-- stampa PDF
put "ANNARITA DE BAGGIS" into field "nome" of card 1
put "Padova, 27 maggio 2014" into field "giorno" of card 1
put "nata a Roma il 17/11/1969" into field "nascita" of card 1

put PrintPdf(myfilename,myoptions) into MessErr

if MessErr is empty then
put "OK"
else
put MessErr
end if

end StampaPdf

I think Livecode Server can actually work with stacks. As an example I was able to create a new text file using the following script:
set itemdelimiter to "/"
put the filename of this stack into INDIRIZZO
put "prova.txt" into last item of INDIRIZZO
put "file:" & INDIRIZZO into INDIRIZZO
put "HKJHJ" into URL INDIRIZZO
put "ok"
exit to top

All the best,

Paolo
Paolo Mazza
Italy

Klaus
Posts: 11274
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Create a PDF with LiveCode server

Post by Klaus » Wed Jun 29, 2016 1:33 pm

Hm, LC Server is a scripting engine like PHP, could you please show your .lc or .rev script that you are calling with your browser?

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Create a PDF with LiveCode server

Post by PaoloMazza » Wed Jun 29, 2016 1:39 pm

<?lc

go stack "printpdf.livecode"

send "StampaPdf" to stack "printpdf.livecode"

?>

I get "OK" from the server.
Paolo Mazza
Italy

Klaus
Posts: 11274
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Create a PDF with LiveCode server

Post by Klaus » Wed Jun 29, 2016 1:43 pm

Very strange!? The dictionary does NOT list "server" in the supported platforms for "go stack ..." nor "open printing to PDF..."!
So I highly doubt this is possible at all!

PaoloMazza
Posts: 27
Joined: Wed Nov 15, 2006 11:27 am

Re: Create a PDF with LiveCode server

Post by PaoloMazza » Wed Jun 29, 2016 1:45 pm

See this lesson

http://lessons.livecode.com/m/4070/l/36 ... ode-server

They use:
go stack "<path to stack>"
Paolo Mazza
Italy

Klaus
Posts: 11274
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Create a PDF with LiveCode server

Post by Klaus » Wed Jun 29, 2016 1:48 pm

Buongorno Paolo,
PaoloMazza wrote:...They use:
go stack "<path to stack>"
yes, as a synonym for "start using stack xyz".
But they also write:
...
However, visual and graphical commands are not supported (e.g. export snapshot).
...
This is of course a bit sparse but I, personally, count printing to these limitations.
#
Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”