Page 1 of 3

Export long texts to PDF?

Posted: Fri Apr 22, 2022 7:37 pm
by stam
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

Re: Export long texts to PDF?

Posted: Fri Apr 22, 2022 7:46 pm
by Klaus
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

Re: Export long texts to PDF?

Posted: Fri Apr 22, 2022 8:14 pm
by richmond62
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.

Re: Export long texts to PDF?

Posted: Fri Apr 22, 2022 8:36 pm
by stam
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

Re: Export long texts to PDF?

Posted: Fri Apr 22, 2022 8:45 pm
by stam
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...)

Re: Export long texts to PDF?

Posted: Fri Apr 22, 2022 8:56 pm
by richmond62

Re: Export long texts to PDF?

Posted: Fri Apr 22, 2022 9:04 pm
by dunbarx
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

Re: Export long texts to PDF?

Posted: Fri Apr 22, 2022 9:07 pm
by stam
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?

Re: Export long texts to PDF?

Posted: Sat Apr 23, 2022 6:26 pm
by jacque
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.

Re: Export long texts to PDF?

Posted: Sat Apr 23, 2022 6:54 pm
by richmond62
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 . . .

Re: Export long texts to PDF?

Posted: Sat Apr 23, 2022 7:14 pm
by richmond62

Code: Select all

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

Re: Export long texts to PDF?

Posted: Sat Apr 23, 2022 7:46 pm
by richmond62
SShot 2022-04-23 at 21.44.20.png

Re: Export long texts to PDF?

Posted: Sun Apr 24, 2022 1:37 am
by stam
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!

Re: Export long texts to PDF?

Posted: Sun Apr 24, 2022 8:14 am
by richmond62
https://youtu.be/1x3mZ1nLql8

Kevin tells it like it is,

Re: Export long texts to PDF?

Posted: Sun Apr 24, 2022 8:17 am
by richmond62
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.]