VpeRenderWrite without text break

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

VpeRenderWrite without text break

Postby Bengt » Sun Sep 30, 2007 9:20 pm

I print a lot of similar documents with varying headlines. The headline must be on one line. Fontsize should be 40 if possible, but if it doesn't fit in one line, fontsize should be reduced.

I use VPE for Visual DataFlex from StarZen. To calculate the biggest possible font size, I try to run a loop and decrement fontsize until the length of the headline is short enough. My statements are:

Get DoVpeRenderWrite VLEFTMARGIN VTOPMARGIN VFREE VFREE sText to iTest
Get DoVpeGet VRENDERWIDTH to iTextWidth

The problem is that if the headline is to long it will be printed on two lines and iTextWidth will not be the length of the total headline but the length of one of the two lines. After reading the VPE manual, I thought iTest would be >0 if a textbreak occur, buit even in that case, iTest is zero.

Is there a solution to this problem?

Bengt
Bengt
 
Posts: 89
Joined: Fri Jan 27, 2006 5:29 pm

Postby IDEAL Software Support » Mon Oct 01, 2007 2:24 pm

RenderWrite() does not return whether a line break occured, but if a page break occured.

To check, if a line break occured, simply render the letter "X" with the same font size.

Code: Select all
VPE.RenderWrite(0, 0, VFREE, VFREE, "X")
int nLineHeight = VPE.nRenderHeight


If your call to RenderWrite("headline") returns a height which is bigger than nLineHeight * 1.1, then you have a line break. (The multiplication with 1.1 is for safety, due to round-off errors.)

Regards
Thorsten Radde
IDEAL Software GmbH
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 38 guests