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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - formatting a column of currency
  FAQ FAQ  Forum Search   Register Register  Login Login

formatting a column of currency

 Post Reply Post Reply
Author
Message
glennh View Drop Down
Beginner
Beginner


Joined: 12 Sep 12
Location: denver, co
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote glennh Quote  Post ReplyReply Direct Link To This Post Topic: formatting a column of currency
    Posted: 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!
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
glennh View Drop Down
Beginner
Beginner


Joined: 12 Sep 12
Location: denver, co
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote glennh Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jan 13 at 9:59PM
Herzlichen Dank, Werner!

I'll review that information, I appreciate it!
Back to Top
glennh View Drop Down
Beginner
Beginner


Joined: 12 Sep 12
Location: denver, co
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote glennh Quote  Post ReplyReply Direct Link To This Post 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. 
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store