PxPlus User Forum

Twitter Twitter Twitter

Author Topic: PDF viewer cutting off bottom of text  (Read 1031 times)

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
PDF viewer cutting off bottom of text
« on: May 25, 2021, 02:33:04 PM »
When I print to the PDF viewer using a scaled font, it sometimes cuts off the bottom of lowercase letters that hang below the line such as g, y, j. It appears to do this whenever I provide the bottom right corner of the text area. I've tried various alignments and sizes for the text area with no change in the results. Below is a sample program and PNG of the output.

Am I doing something improperly? This does not happen when the output is a *WINPRT* device. Including the Microsoft Print to PDF or the Adobe PDF printer.  I believe it is something happening inside *PDF*.

BTW, I am specifying the bottom right corner because I want the text to be cut-off if it is too long for the print area.

Best Regards,
Jeff


Code: [Select]
BEGIN
Cols_Reqd = 102, loop = 0, font$ = "Arial"
OPEN (UNT)"*PDF*;VIEW;MARGINS=500:500:500:500"; prn=LFO

! Scale the font
PRINT (prn)'Font'(font$,-12),'DF',
WHILE (MXC(prn)<Cols_Reqd AND ++loop<5)
PRINT (prn)'Font'(font$, MXC(prn)/Cols_Reqd),'DF', ! Scale the font
WEND

s$="These dangling letters are jetting below the line yet are cut off."
x = 50, l = 1
PRINT (prn)'Text'(@X(1),@Y(l),@X(x),@Y(l),STR(l)+": "+s$,"T"),
l+=2
PRINT (prn)'Text'(@X(1),@Y(l),@X(x),@Y(l+2),STR(l)+": "+s$,"T"),
l+=2
PRINT (prn)'Text'(@X(1),@Y(l),@X(x),@Y(l+3),STR(l)+": "+s$,"T"),
l+=2
PRINT (prn)'Text'(@X(1),@Y(l),@X(x),@Y(l+4),STR(l)+": "+s$,"T"),
l+=2
PRINT (prn)'Text'(@X(1),@Y(l),STR(l)+": "+s$),
END

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: PDF viewer cutting off bottom of text
« Reply #1 on: May 25, 2021, 04:02:25 PM »
The issue is your logic that is looping around fiddling with the font size. 

If we delete line 7 and 9 and replace line 8 with a direct computation it works fine:

0007 ! WHILE (MXC(prn)<Cols_Reqd AND ++loop<5)
0008 PRINT (prn)'FONT'(font$,0-INT(12*MXC(prn)/Cols_Reqd)),'DF', ! Scale the font
0009 ! WEND

Fonts only come in specific sizes based on resolution of the device and when you start repetitive rounding of percentages in your WHILE/WEND loop the result is not correct.

Basically the change in the logic simply picks a good starting point font (12) then uses that to compute a size based on how many columns that font size yielded versus the desired number of columns.


Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
Re: PDF viewer cutting off bottom of text
« Reply #2 on: May 25, 2021, 06:40:14 PM »
Thank you Mike! I will give that a try.

By the way, I had copied that font scaling code from the PxPlus manual at https://manual.pvxplus.com/PXPLUS/file_handling/_winprt_windev_printing.htm

Regards,
Jeff

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
Re: PDF viewer cutting off bottom of text
« Reply #3 on: May 26, 2021, 10:16:50 AM »
I made the suggested changes to the application and all is working perfectly now. In fact, it also resolved some other text and line placement issues I was having.

Thanks again Mike!

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: PDF viewer cutting off bottom of text
« Reply #4 on: May 26, 2021, 10:24:53 AM »
Glad to hear it all worked out.

Also, thanks for mentioning where you got the logic from. We will adjust it.

Part of the problem you were having is that PDF's work in Points (1/72 of an inch), whereas WINPRT works in Pixels which range from 1/300 of an inch to over 1/1500 of an inch.  As such the impact of rounding is less pronounced whereas the loss of 1 point (1/72 of an inch) when printing typically 8 lines per inch means a loss of 1/9 of the character height which can be visual.

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com