Page 1 of 1
Create a PDF with LiveCode server
Posted: Tue Jun 28, 2016 2:17 pm
by PaoloMazza
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
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 10:49 am
by PaoloMazza
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
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 11:14 am
by [-hh]
Edit. Was wrong, sorry.
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 11:28 am
by Klaus
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.
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 12:01 pm
by PaoloMazza
My script works locally and create the pdf.
But in the server it does not work.
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 12:07 pm
by Klaus
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?
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 1:30 pm
by PaoloMazza
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
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 1:33 pm
by Klaus
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?
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 1:39 pm
by PaoloMazza
<?lc
go stack "printpdf.livecode"
send "StampaPdf" to stack "printpdf.livecode"
?>
I get "OK" from the server.
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 1:43 pm
by Klaus
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!
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 1:45 pm
by PaoloMazza
Re: Create a PDF with LiveCode server
Posted: Wed Jun 29, 2016 1:48 pm
by Klaus
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