Export long texts to PDF?

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

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Export long texts to PDF?

Post by stam » Fri Apr 22, 2022 7:37 pm

Hi all,
I'm in the process of converting FileMaker Pro apps to LC and the nearly at the end of doing this for one of my more heavily used apps, which needs to export PDF as its final output.

The length is variable and can span several pages, which is quite easy to accommodate for in FMP with layouts designed for printing with fields that shrink/shift on preview/printing depending on content length.

I'm not clear on what the workflow would be to create a PDF of fields with formattedHeight longer than the card they are on?

I looked at the lesson https://lessons.livecode.com/m/4071/l/2 ... g-livecode but this isn't quite what i need... it only prints what is visible on the screen.

Is there a simpler way to export/print to PDF fields of variable length that may span the equivalent of several cards?
Or would i have to paginate this myself, create new cards on the fly (i guess based somehow on the formattedHeight of the field on each page) and then print all cards to PDF as per the less above? (seems rather tedious...)

Grateful for your suggestions!
Stam

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

Re: Export long texts to PDF?

Post by Klaus » Fri Apr 22, 2022 7:46 pm

Hi Stam,

I would:
1. Hide the scrollbars of the field
2. put "Page 1" into fld "pagination"
3. print the card
3a. print break
4. scroll the fields content via script and
5. put "Page 2" into fld "pagination"
6. print the card
6a. print break
etc...
You get the picture. :-)

Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export long texts to PDF?

Post by richmond62 » Fri Apr 22, 2022 8:14 pm

SShot 2022-04-22 at 22.12.10.png
-
Simple stuff: so will not keep Klaus happy:

Code: Select all

on mouseUp
   ask file "Save as:" with "Print.pdf"
   put it into tFileName
   if tFileName is empty then exit to top
   set the printerOutput to "file:" & tFileName
   revShowPrintDialog false, false
   revPrintField the long name of fld "GUFF"
end mouseUp
Probably only works on a Macintosh.
Attachments
PDF Xport.livecode.zip
Stack.
(2.36 KiB) Downloaded 65 times

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Export long texts to PDF?

Post by stam » Fri Apr 22, 2022 8:36 pm

Thank you both!

@Richmond - i had looked at revPrintField but didn't realise i could use it to create PDF by setting the printerOutput to a file.pdf -- thank you hilighting this!
Unfortunately it's not a simple matter of just printing one field though, this is would be a formal letter representing the output of tertiary centre medical multidisciplinary discussion, so has to have several elements - a complex header than represent the hospital and the department, footers etc; plus needs some fancy formatting/layout which means ideally including multiple fields in various locations - it's just the 'middle' bit that would print in a stream.
Or can revPrintField be used to create just a section in the PDF?

@Klaus - that seems very usable! I'll probably still have to create an additional card as needed on the fly as the first page is very different from subsequent pages but it seems more doable now -- thank you!

great forum ;)
regards
Stam

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Export long texts to PDF?

Post by stam » Fri Apr 22, 2022 8:45 pm

Also, looking at the documentation on PrinterOutput:
The printerOutput can be one of the following values. The default value depends on the printer driver - Windows Vista uses XPS format. - UNIX uses PostScript format. - Mac OS X uses PDF format. - Older Windows versions use a system-specific format.
Does this means that if used on Windows it won't produce PDF? (sadly this is the target platform, as the NHS is 99.9% Microsoft orientated - and yes there is much pain in that...)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export long texts to PDF?

Post by richmond62 » Fri Apr 22, 2022 8:56 pm


dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Export long texts to PDF?

Post by dunbarx » Fri Apr 22, 2022 9:04 pm

Stam.

I use the "open printing to pdf" command:

Code: Select all

 get the deskTop folder -- or wherever...
         open printing to pdf it & "/" & yourJob & ".pdf"
         print yourCard from "8,10" to "564,646" --or, er, wherever
         close printing
Also, however many ancillary fields are required, they should not impact the central issue. These can be populated as required, and the successive data in the main field loaded and printed as the others have said.

Craig

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Export long texts to PDF?

Post by stam » Fri Apr 22, 2022 9:07 pm

richmond62 wrote:
Fri Apr 22, 2022 8:56 pm
Windows Vista?

Surely not . . . even the NHS.

Um?

https://lessons.livecode.com/m/4071/l/2 ... g-livecode

http://lists.runrev.com/pipermail/use-l ... 41532.html
Thanks Raymond - but I already included the same lesson in my OP ;)

Re: NHS IT
Just about… it’s actually just over 3 years ago we jumped from Windows XP to Windows 10.
Not a small endeavour for an NHS Trust with over 22,000 employees…
I was not kidding when I said pain is a familiar sensation plaguing NHS IT…

I presume however that the XPS format applies to “windows” in general - or is this different for windows 10/11?

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

Re: Export long texts to PDF?

Post by jacque » Sat Apr 23, 2022 6:26 pm

Klaus' suggestion is the recommended way. See the pageHeights property in the dictionary to know how much to scroll the field on each iteration of the loop.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export long texts to PDF?

Post by richmond62 » Sat Apr 23, 2022 6:54 pm

Klaus' suggestion
1. Hide the scrollbars of the field
2. put "Page 1" into fld "pagination"
3. print the card
3a. print break
4. scroll the fields content via script and
5. put "Page 2" into fld "pagination"
6. print the card
6a. print break
One of the things that I have always found annoying is finding a backup of
some text someone wrote in about 1995 that is a PDF WITHOUT an embedded text layer . . .

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export long texts to PDF?

Post by richmond62 » Sat Apr 23, 2022 7:14 pm

Code: Select all

on mouseUp
   revShowPrintDialog false, true
   revPrintField the name of fld "fRESULT"
end mouseUp
-
DWP.jpg

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export long texts to PDF?

Post by richmond62 » Sat Apr 23, 2022 7:46 pm

SShot 2022-04-23 at 21.44.20.png

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Export long texts to PDF?

Post by stam » Sun Apr 24, 2022 1:37 am

Not sure what the 'red' post is about... no one questions whether revPrintField works on all desktop platforms... the question i raised was if this will work to export to directly to PDF, as this would rely on setting the printerOutput to a file - as i understand the documentation, on Windows (albeit 'vista') the file format for printerOutput would appear to be XPS, as opposed to PDF on macOS. If that's not true of more modern Windows OS/LiveCode versions then even better - but still no good for my needs, as i aim to export a dynamic layout, not a single field of text.
As was explained in the OP...

I am more than fully aware both win and mac can 'print to pdf' from the printer setup dialog (on Windows you'd need to select a 'print to pdf' driver), but i don't want my users to have to do that.
This is in fact the very method i've had to use with my FileMaker Pro standalone, as the export to PDF feature wasn't available in standalones for FMP and in any case standalones have now been deprecated and removed from FMPA.

I just want my users to be able to export a PDF file directly. Using the print dialog to do this was was always a lame way to do this... I can't tell you how often this is a point of confusion for non-IT savvy users...
Therefore for me, open printing to pdf is the way to go for this project.

Anyway lots to get my teeth into! Thanks to all for the swift and amazing help!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export long texts to PDF?

Post by richmond62 » Sun Apr 24, 2022 8:14 am

https://youtu.be/1x3mZ1nLql8

Kevin tells it like it is,

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Export long texts to PDF?

Post by richmond62 » Sun Apr 24, 2022 8:17 am

Does anyone have a valid download link for this?

Script Reporter-EditedBN_2.livecode

https://sites.google.com/a/pgcps.org/li ... -printouts

[Before anyone jumps: NO, it is only of tangential interest to the original question.]

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”