Print to PDF: Right side of text is truncated

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

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Print to PDF: Right side of text is truncated

Post by ittarter » Wed Jan 03, 2018 6:04 pm

Hello,

I'm using a pretty simple line to print formatted text as a PDF:

Code: Select all

revPrintText (tData),,tab & "<%pageNumber%> of <%numPages%>"
However, I have problems with the right side of some text being blocked (maybe by the border?) or truncated. See the final letter 'e' in the attached image.

Why is this happening? It seems to only happen on certain fonts (e.g. Calibri, Verdana) but not others (e.g. Tahoma, Times New Roman)
Attachments
Untitled.png

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Print to PDF: Right side of text is truncated

Post by Klaus » Wed Jan 03, 2018 6:29 pm

I think this is a text field in Livecode, right? Then try to make it wider.
Looks like the fields border is cutting off the right part of the text.

Are you on windows? Windows uses different fonts for priniting and onscreen display,
that may explain this inconvenience.

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: Print to PDF: Right side of text is truncated

Post by ittarter » Wed Jan 03, 2018 7:37 pm

I'm not printing the card, I'm using revPrintText, but anyway the dontwrap of the field that has the text is true so it shouldn't cut anything off anyway.

I am indeed on Windows. Maybe it relates to how Windows uses different fonts for printing an on-screen display. I didn't know Windows did that. How confusing. I only have one Verdana in my Windows fonts folder, so I wonder what font it uses for display vs printing.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Print to PDF: Right side of text is truncated

Post by richmond62 » Wed Jan 03, 2018 8:50 pm

a pretty simple line to print formatted text as a PDF
I'd be very interested to know HOW that is printing to PDF when revPrintText
normally feeds straight to a printer.

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

Re: Print to PDF: Right side of text is truncated

Post by dunbarx » Wed Jan 03, 2018 9:27 pm

Richmond makes a point. The "open printing to PDF" command even requires a different library than ordinary print gadgetry.

Craig Newman

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: Print to PDF: Right side of text is truncated

Post by ittarter » Fri Jan 05, 2018 12:24 pm

Well, it's not creating an image and pasting that onto a PDF -- the text in the PDF can be hilited/copied/etc.

It sounds like there's a more popular way to make a PDF in LC? I believe I remember seeing that LC can create a PDF by snapshotting a card, but with varying numbers of pages for my documents, I thought that it would take me much longer to configure, so I opted for what I thought would be workable for the time being.

If I do the snapshotting option, will the resulting text still be able to be hilited/copied or will it be a pure graphic PDF?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Print to PDF: Right side of text is truncated

Post by richmond62 » Fri Jan 05, 2018 1:06 pm

A snapshot will produce an image, not something with an embedded text layer.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Print to PDF: Right side of text is truncated

Post by richmond62 » Fri Jan 05, 2018 4:39 pm

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
I have a horrible feeling this will only work on a Macintosh.
Printy.png
PRINTY.livecode.zip
(1.36 KiB) Downloaded 234 times
printerOutput.png
printerOutput.png (11.45 KiB) Viewed 10076 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Print to PDF: Right side of text is truncated

Post by richmond62 » Fri Jan 05, 2018 6:35 pm

Printed out a PDF to Linux (Xubuntu 17.10 64-bit) with no trouble at all.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Print to PDF: Right side of text is truncated

Post by richmond62 » Fri Jan 05, 2018 10:31 pm

One of my pupils who runs Windows 10 has just used that stack to produce a PDF.

So, obviously this does not make much sense in this context:
Screen Shot 2018-01-05 at 11.30.34 pm.png

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Print to PDF: Right side of text is truncated

Post by SparkOut » Fri Jan 05, 2018 11:35 pm

Not able to test right now, but check out the formatForPrinting property

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Print to PDF: Right side of text is truncated

Post by Klaus » Fri Jan 05, 2018 11:39 pm

SparkOut wrote:
Fri Jan 05, 2018 11:35 pm
...but check out the formatForPrinting property
Which is a STACK property, not sure if this really affects "revPrintText..."

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Print to PDF: Right side of text is truncated

Post by SparkOut » Sat Jan 06, 2018 9:41 am

Windows renders text for screen and print with different metrics. Setting the stack property formatForPrinting to will adjust the screen rendering (and probably look ugly on screen) but then when you print, it should correctly output (unless there is a different problem). After printing, you can set the stack property false again.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Print to PDF: Right side of text is truncated

Post by richmond62 » Sat Jan 06, 2018 10:37 am

I don't really understand what all the fuss is about. Here is what the PDF printed from
my stack on Windows looks like:
print2PDFwindows.png
Printy.png
No other code needed.

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: Print to PDF: Right side of text is truncated

Post by ittarter » Sat Jan 06, 2018 1:54 pm

richmond62 wrote:
Sat Jan 06, 2018 10:37 am
I don't really understand what all the fuss is about. Here is what the PDF printed from
my stack on Windows looks like:

print2PDFwindows.pngPrinty.png

No other code needed.
Can revPrintField do footers? In the dictionary there's talk of reading special expressions like <%pageNumber%>, but I don't see any syntax to set up header/footer text.

If that's the case, then I think I'll just use a different font and continue using revPrintText.

Post Reply