Subscript/superscript

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Subscript/superscript

Postby Bas » Wed May 03, 2006 12:32 pm

Hello,
Do you know of a way to print superscript or subscript?
In my VB code I use this function:
Code: Select all
Public Function SubScript(ByVal OnOff As Boolean)
    If OnOff = True Then
        VP1.FontSize = VP1.FontSize - 2
        Call VP1.VpePrint(VRIGHT, VP1.nTop + 10, "")
    Else
        VP1.FontSize = VP1.FontSize + 2
        Call VP1.VpePrint(VRIGHT, VP1.nTop - 10, "")
    End If
End Function
.... for example in a code like this:
Code: Select all
Call VP1.VpePrint(VRIGHT, VTOP, "x")
SubScript(True)
Call VP1.VpePrint(VRIGHT, VTOP, "1")
SubScript(False)
Call VP1.VpePrint(VRIGHT, VTOP, " = 100 meters")

... to print x1 = 100 meter (with "1" subscripted/indiced to "x")

But in this way, the distance between "x" and "1" keeps changing when zooming in the VPE printout.
Also, when creating a PDF file from VPE, it looks different then the way you saw it on the VPE printout.

Does anyone know of a better way to achieve this?

Thanks,
Bas

[edit]
BTW: This behaviour is totaly random.
Somtimes the subscripted letter is 1 centimeter off (1:1 zoom).
And somtimes it fits perfectly....
[/edit]
Bas
 
Posts: 18
Joined: Mon Nov 07, 2005 3:35 pm
Location: Hellevoetsluis

Postby IDEAL Software Support » Wed May 03, 2006 2:51 pm

Basically your code is correct.

I think the problem is that you must set the offset bigger, because the indice is printed in a smaller font (therefore it is positioned higher than the normal text!).

Try + 20, i.e.: Call VP1.VpePrint(VRIGHT, VP1.nTop + 20, "")

It might happen that the positioning of text is not 100% accurate in the preview at lower zoom levels, due to pixel misalignment and rounding errors. But at a zoom factor of 300% the text should be aligned correctly, since this equals approximately a 300 DPI device.

Relevant in the end is, how it looks on the real printout of a printer and this will not differ from the PDF output. Note that VPE uses internally a virtually Ultra-High-Resolution (UHR) device where text is rendered on. Afterwards it is transformed to the real output device. Due to the transformation to very low resolution devices (like the screen at a zoom factor of 100%), it may happen that text is misaligned. This was a design decision to gain maximum performance and in 99.9% of all cases the text alignment in the preview is fine.

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

Postby Bas » Wed May 03, 2006 3:01 pm

Thanks for the info..

But my problem is not in the vertical-axis (height), but in the horizontal-axis.

In some zoom-levels the "1" is correctly alligned to the "x".
And in other zoom-levels, ït looks like there are 5 spaces between the "x" and the "1".

Bas
Bas
 
Posts: 18
Joined: Mon Nov 07, 2005 3:35 pm
Location: Hellevoetsluis

Postby IDEAL Software Support » Wed May 03, 2006 3:22 pm

Yes, this can happen and is normal.

Explanation: The first text object in front of the indice is rendered at different zoom levels in a way that not each character is positioned as it would on a high resolution device. Instead the whole string is rendered at once, just looking for correct word breaks (if text is spawning over multiple rows), and correct alignment of text which is laid out justified. So the text might become very small at specific zoom levels, which explains the gap. But on high resolution devices there is no such problem. The PDF document on the screen as well as the printer output and the VPE preview with a zoom factor of at least 300% will all look fine.

Regards
Thorsten Radde
IDEAL Software GmbH
Last edited by IDEAL Software Support on Wed May 03, 2006 3:39 pm, edited 1 time in total.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Postby IDEAL Software Support » Wed May 03, 2006 3:37 pm

After thinking about the problem a second time, I can provide a solution:

Use for the text in front of the indice:

Code: Select all
Doc.TextAlignment = ALIGN_JUSTIFIED_AB


Text will be aligned justified. In contrast to ALIGN_JUSTIFIED which aligns the last line left aligned, the last line of the text will also be aligned justified - if it is not ending with a CR / LF character.

This solves the problem.

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

Postby Bas » Wed May 03, 2006 3:57 pm

Thanks, that worked for me!
Very smooth printout now!
:P
Bas
 
Posts: 18
Joined: Mon Nov 07, 2005 3:35 pm
Location: Hellevoetsluis

Postby IDEAL Software Support » Tue Mar 13, 2007 10:45 am

By the way: VPE v4.0 will support superscript and subscript in the RTF parser (Professional Edition and higher).

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 9 guests

cron