[SOLVED] Is there a way to convert an entire card to pdf and email it?

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

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

[SOLVED] Is there a way to convert an entire card to pdf and email it?

Post by karmacomposer » Fri Jul 20, 2018 2:33 am

I saw Quartam's PDF Library add on, but when I looked at the demo, it seems to recreate a form.

I have a VERY COMPLEX form I am working on in LiveCode. The process is: the user will add data and then press the submit button, which will write the data to a database and email a client a copy of the form as a attached pdf.

Is Quartam's PDF Library good for this (taking a snapshot of the entire form and convert it to pdf) or do I have to re-create it item by item???

If not, is there a solution for this?

Thank you

Mike
Last edited by karmacomposer on Mon Jul 23, 2018 3:03 pm, edited 1 time in total.

ClipArtGuy
Posts: 206
Joined: Wed Aug 19, 2015 4:29 pm

Re: Is there a way to convert an entire card to pdf and email it?

Post by ClipArtGuy » Fri Jul 20, 2018 5:23 am

This lesson shows how to export a card to PDF:

http://lessons.livecode.com/m/4071/l/29 ... g-livecode

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Is there a way to convert an entire card to pdf and email it?

Post by karmacomposer » Fri Jul 20, 2018 6:05 pm

This does work:

Code: Select all

## Path to the pdf file we want to create
      put specialFolderPath("documents") & "/PDAForm.pdf" into tPDFPath
      
      open printing to pdf tPDFPath
      ## Print the card into the printable area
      print card 1 of this stack into 0,0,1000,1024
      
      close printing
But how can I print the entire card - grouped and all (it's longer than the card and has a scrollbar)?

Is there a command to just print the whole thing? Can I set it to print a standard 8.5 x 11 - sheet of paper size?

Mike

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Is there a way to convert an entire card to pdf and email it?

Post by karmacomposer » Fri Jul 20, 2018 6:23 pm

I have to enlarge the group and card to 953,1612,500,820 and then issue the export pdf command.

Mike

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Is there a way to convert an entire card to pdf and email it?

Post by karmacomposer » Fri Jul 20, 2018 7:25 pm

Here is what I have to enlarge the stack and group to for it to fit:

Code: Select all

Stack scale up to:

scale factor 0.6

Width: 1020
Height: 1571
Location: 1040, 836

Code: Select all

Scale group up to:

Width: 953
Height: 1628
Location: 505,836

Left: 29
Top: 22
Right: 982
Bottom: 1650
Here is the group before:

Code: Select all

Group before:

Width: 946
Height: 942
Location: 493,484

Left: 20
Top: 13
Right: 966
Bottom: 955
and here is the stack before:

Code: Select all

Scale Factor 1

Width: 985
Height: 976
Location: 701,526
Now to figure out how to code this?

I need to resize it up, print to pdf (already have that done) then resize it back.

Mike

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4673
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Is there a way to convert an entire card to pdf and email it?

Post by jacque » Sat Jul 21, 2018 9:02 pm

If you had only a single field, you could use the pageHeights property which was implemented to do what you want. But that property doesn't apply to groups, so you'll have to create your own list of page heights. See the dictionary to read about the method in general.

You'll need to manually create a list of scroll settings. If your group isn't going to change height, you'll only need to do that once during development. Scroll the group to where you want the page break and record the scroll. Do that repeatedly until you have a list of scroll settings. You can store the list in a custom property somewhere. Alternately you can calculate it in the script by adding the height of the group to the current scroll. The problem with that is that it's easy to cut lines in half, so you'll have to experiment.

Then you open printing for pdf, print the card, set the scroll of the group to the next line in your list, print the card again, and continue until the entire group has been printed. Then close printing, which is what actually sends the print job to the printer.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Is there a way to convert an entire card to pdf and email it?

Post by karmacomposer » Mon Jul 23, 2018 2:36 pm

@Jacque: That seems overly complicated. Can't I simply increase the stack, card and group to full height, take the pdf snapshot and then resize the group, card and stack back again?

Mike

mrcoollion
Posts: 333
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Is there a way to convert an entire card to pdf and email it?

Post by mrcoollion » Mon Jul 23, 2018 2:40 pm

Just an idea...

Maybe it is possible to make a screenshot of the complete card en print the screenshot...

Regards,

Paul

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Is there a way to convert an entire card to pdf and email it?

Post by karmacomposer » Mon Jul 23, 2018 3:01 pm

And that's exactly what I coded and it worked 100%

I resized the stack and the group, printed to pdf and then resized it back (height, width) using exact coordinates (left, right, top, bottom) - both the stack and the group.

Yeeehaawwwww

That's done!

Mike

Post Reply

Return to “Talking LiveCode”