Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link Par2: PDF class fix for large font on desktop 2009-02-20 -- Arnor Baldvinsson Here is information about how I fixed the PDF target class so that it will
not mess up the PDF generation on computers that don't use the default 96dpi
screen resolution. This involves adding a single method to the
PDFGeneratorClass class in ABPRPDF.INC and ABPRPDF.CLW:
Add to class declaration in ABPRPDF.INC (I put it in at the top of the
method list, around line 195):
AdjustDPIValues PROCEDURE(Long pValue),Long
!! AB 2009-02-19 Adjusts DPI values
In the classfile, ABPRPDF.clw, I added this:
PDFGeneratorClass.AdjustDPIValues PROCEDURE(Long pValue)!!,Long
!! AB 2009-02-19 Adjusts DPI values
HDcScreen UNSIGNED
IDPI Long
R Real
L Long
Code
R = 1
HDcScreen = GetDC(0)
If HDcScreen <> 0
IDPI = GetDeviceCaps(HDcScreen, 88)
L = ReleaseDC(0, HDcScreen)
R = IDPI/96
End
Return (pValue / R)
In PDFGeneratorClass.AddFontDescriptor method, you have code like this:
!SET the fonts Width
LOOP LOC:I=SELF.FontsNames.FirstChar TO SELF.FontsNames.LastChar
LOC:CharToTest=CHR(LOC:I)
IF GetTextExtentPoint32(LOC:DC,LOC:CharToTest, 1,LOC:CharSize)<>0 THEN
IF LOC:Subclasing THEN
IF SELF.FontsNames.CharWidth[LOC:I] THEN
SELF.FontsNames.CharWidth[LOC:I] = LOC:CharSize.eW
END
ELSE
SELF.FontsNames.CharWidth[LOC:I] = LOC:CharSize.eW
END
END
END
I changed both of the assignments to the CharWidth to:
SELF.FontsNames.CharWidth[LOC:I] = SELF.AdjustDPIValues(LOC:CharSize.eW)
In PDFGeneratorClass.GetTextWidth method, you have code like this:
IF SelectObject(LOC:DC, LOC:HFont) THEN
RV = GetTextExtentPoint32(LOC:DC,pText, LEN(pText),LOC:CharSize)
LOC:OLDMAPMODE=SetMapMode(LOC:DC,LOC:OLDMAPMODE)
DeleteObject(LOC:HFont)
RETURN LOC:CharSize.eW + (LOC:CharSize.eW/20)
END
I changed the RETURN to adjust the value:
RETURN SELF.AdjustDPIValues(LOC:CharSize.eW + (LOC:CharSize.eW/20))
This takes care of the font sizing problem in any DPI combination that I
threw at it:)
Thanks to Lee White for putting me on the right track with the DPI:)
Today is November 21, 2024, 7:35 am This article has been viewed 35270 times.
|
|