Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
formatting a column of currency |
Post Reply
|
| Author | |
glennh
Beginner
Joined: 12 Sep 12 Location: denver, co Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
Topic: formatting a column of currencyPosted: 13 Jan 13 at 12:52AM |
|
I'm working on a table of financial transactions. typical kind of format:
date description amount balance In an attempt to keep things simple (maybe a bit of laziness), I'm making 4 strings with a CRLF delimiting each line then using the FitTextBox function to draw the data. My biggest problem here is that I'm losing the white space at the beginning of my lines. Say my first two lines are like this: -$123.45 $ 45.67 I'm losing the space before the dollar sign on the second line when using FitTextBox. Is there any way around this? A secondary issue is that I'm using the helvetica font which is proportional. My numbers don't line up well, so I've been making my currency column use the Courier font, but I'm not crazy about the way that looks with two different fonts being used on one (pseudo) line. Any help/advice on either of these issues would be appreciated. Thanks! |
|
![]() |
|
edvoigt
Senior Member
Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
Quote Reply
Posted: 16 Jan 13 at 7:59PM |
|
Hi Gleen,
you want a nice looking solution. Everything has a price in coffee and time. For deeper knowledge look on my answer in this post: http://www.quickpdf.org/forum/tquickpdf0813drawtext_topic2074_post8841.html and something more here: http://www.quickpdf.org/forum/word-wrapping_topic2040_post8977.html This only to show you some background. The best idea is to look deeper in the reference guide. But now my idea. There are different stages of accuracy. Lets start with the wished font (not Courier). We look only to realize one line correct, more later. We need the position of decimalseparator as given. Then we play with QP.SetTextAlign. With QP.SetTextAlign(1) we may draw the separator. If we know the width of the separator-sign (QP.Charwidth), it is easy to draw the both part of the string with SetTextAlign(0) respectivly SetTextAlign(2). If you know how much is the lineheight (see in my answers above). you may draw the next line in the same manner. May it's good enough for your purposes. But you'll see, that the digits are not in columns, because the font ist of variable pitch. A 8 is bigger than a 1. With more work you may set every glyph step by step alone to simulate fixed pitch. Cheers, Werner |
|
![]() |
|
glennh
Beginner
Joined: 12 Sep 12 Location: denver, co Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
Posted: 16 Jan 13 at 9:59PM |
|
Herzlichen Dank, Werner!
I'll review that information, I appreciate it!
|
|
![]() |
|
glennh
Beginner
Joined: 12 Sep 12 Location: denver, co Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
Posted: 16 Feb 13 at 11:54PM |
|
Following back on this. Turns out this wasn't that difficult at all. I just used right alignment with drawtext and the currency amounts lined up great.
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store