Creating a PDF file using some fields on multiple cards

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Creating a PDF file using some fields on multiple cards

Post by mikemc » Thu Jun 18, 2015 1:23 am

I would like to create a pdf file using some fields from multiple cards that are in a the same stack
Is there a way to do this that is not to complicated. Can Quartam PDF library do this I went to the site
and the version was very dated and from my download I could not tell if you could work with individual fields.
I know this must be possible I just don't know how to get there. Please point me in the right direction, Thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Creating a PDF file using some fields on multiple cards

Post by dunbarx » Thu Jun 18, 2015 1:29 am

Hi.

All you are asking for are simple and straightforward in LC.

But what do you want to do? Do you know how to get data from fields on remote cards? How do you want to assemble that data into a usable form? In other words, you need to be a little more specific with your request.

Craig Newman

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Creating a PDF file using some fields on multiple cards

Post by mikemc » Thu Jun 18, 2015 1:54 am

The PDF file would be very simple eg.

A Title Line
A txt field from one of my cards here

Assorted txt fields printed here A Number From a field printed here
Assorted txt fields printed here A Number from a field printed here

A txt field from a different card printed here

Assorted txt fields printed here A Number From a field printed here
Assorted txt fields printed here A Number from a field printed here

etc...
Thats the basic idea just a simple report in pdf format

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Creating a PDF file using some fields on multiple cards

Post by dunbarx » Thu Jun 18, 2015 2:16 pm

Hmmm.

So if you have a stack with lots of cards, each with lots of fields on them, does the following help?

Code: Select all

put field "remoteField" of card "remoteCard" after pdfDataToPrint
or
put field "remoteField" of card "remoteCard" after fld "pdfDataToPrint"
If that answers your main question, then it is simply a matter of formatting the information in the variable pdfDataToPrint. As you extract the info in each remote field, you might append tabs or other separating characters or strings to format in the way you wish. Doing so in a field might allow you to see the formatted text as it builds. Once you have that down pat, storing in a variable would be faster.

Or am I missing this entirely?

Craig

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Creating a PDF file using some fields on multiple cards

Post by bangkok » Thu Jun 18, 2015 3:09 pm

I believe your PDF report will contain several pages.

Let's say that 1 page = 1 card. each card contain fields, layout etc.

Code: Select all

open printing to pdf tMyPDFFile
   
   repeat with i = 1 to 3
      go cd ("page"&i)
      print  this cd from 0,0 to 590,940  --- that would be a regular A4 paper size
   end repeat

   close printing
Other method : you have only 1 card, with 1 field and you want to put inside this field a large amount of data. Your PDF file will therefore contain several pages. Lets' say you want to print 62 lines per page. Here you have to manage the content, and use "print break"

Code: Select all

open printing to pdf tMyPDFFile
  put 1 into tStart
   put 62 into tEnd
   repeat with i = 1 to 4 --- the total number of pages
      put line tStart to tEnd of tBigData into fld "myfield"
      print  card "myreport" from 0,0 to  590,940 
      add 62 to tStart
      add 62 to tEnd
print break  ---that will create a new "page" in the PDF
next repeat
This example is quite dirty, but it's the general idea.

mikemc
Posts: 60
Joined: Sun May 10, 2015 5:42 pm

Re: Creating a PDF file using some fields on multiple cards

Post by mikemc » Thu Jun 18, 2015 4:21 pm

Thanks, I tried the basic idea now I will just have to get the formatting down :D

Post Reply