Ver 7 Problem Writing near right margin

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Ver 7 Problem Writing near right margin

Postby Brent Rose » Tue Jul 22, 2014 9:44 am

I have a problem with wrapping (happening when it shouldn't) when writing left aligned text near the right edge of the page.

The following code outputs the same text 3 ways, all of which should appear as a single line:

1. This right aligned text fully abuts the right side of the A4 page as expected.

2. This left aligned version with R = VFREE writes OK as well.

3. This is the same left aligned version pushed a little further right - and it now wraps to a second line. Clearly, it should actually fit on a second line...

Code: Select all
  with VPEngine1 do
  begin
    GridMode := InBackground;
    GridVisible := True;


    OpenDoc;
    SetFont('Arial', 10);

    //1: this aligns the text with the right page edge without wrapping
    TextAlignment := ALIGN_RIGHT;
    Write(17, 2, 21, 3, 'Some Sample Text');

    //2: this should fit without wrapping
    TextAlignment := ALIGN_LEFT;
    Write(16, 3, VFREE, 4, 'Some Sample Text');

    //3: this should fit without wrapping
    TextAlignment := ALIGN_LEFT;
    Write(17, 4, VFREE, 5, 'Some Sample Text');


    Preview;
  end;
Brent Rose
 
Posts: 50
Joined: Wed Mar 21, 2012 8:13 pm

Re: Ver 7 Problem Writing near right margin

Postby Brent Rose » Tue Jul 22, 2014 9:06 pm

Confirming that this behaviour also exists for Ver 6.

However, it seems that using a width designation instead (ie a negative value) rather than VFREE actually provides the expected (non-wrapping) result... as below.

Code: Select all
    TextAlignment := ALIGN_LEFT;
    Write(17, 4, -10, 5, 'Some Sample Text');
Brent Rose
 
Posts: 50
Joined: Wed Mar 21, 2012 8:13 pm

Re: Ver 7 Problem Writing near right margin

Postby IDEAL Software Support » Wed Jul 23, 2014 11:49 am

This is not a bug, it is a feature. Please see the help file titled "Programmer's Manual", chapter "Programming Techniques", subchapter "Dynamic Positioning", sections "Dynamic Text" and "Page Margins".

By default, VPE creates page margins, which are 2cm away from each side of a page. The margins have a special purpose: the are only in effect when working with VFREE, i.e. the rught and / or bottom coordinate of a text object is computed dynamically. In this case VPE wraps text at the margins.

In the first example, you are not using VFREE, hence the text extends over the right margin up to the right page border.

In the second example, you are using VFREE, but the computed right coordinate ends *exactly* at the right margin, which is 19cm in your case (because you are using the A4 default paper format, which is 21cm x 29.7cm).

In the third example, you are using VFREE and the right coordinate ends dynamically at the page margin (i.e. 19cm) and is wrapped around to the next line.

The fourth example, when using a width instead of a coordinate, is the same like the first example (no dynamic coordinate).

If the page margins cause unwanted behavior, set them to the page dimensions, i.e. call the method SetOutRect(0, 0, PageWidth, PageHeight).
IDEAL Software Support
 
Posts: 1621
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 11 guests