Solved

itextsharp and displaying fractions

Posted on 2014-02-28
6
391 Views
Last Modified: 2014-04-08
Can't figure this one out. I am creating a pdf dynamically that is displaying numbers of say 40.5, but I need it to display as 40 1/2 with the 1/2 to be the smaller font like Word does it when you type it in there. I've tried adding a new paragraph with the Unicode such as this:

 document.Add(New Paragraph("\u00bc", FontFactory.GetFont("sanserif", 8)))

But it just displays the "\u00bc" as text. Obviously I'm doing something wrong. I know I can use a chunk and raise the text up, but its still not what they want.

Searching is getting me nowhere and even on here it doesn't appear to have been asked ever. Anybody know?
0
Comment
Question by:lhbit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39896748
Try this:
document.Add(New Paragraph("40 " & Chr(&HBD), FontFactory.GetFont("sanserif", 8)))

Open in new window

Explanation: 1/2 is simply ascii character code BD (hex), no unicode required. Output pdf attached.
output.pdf
0
 

Assisted Solution

by:lhbit
lhbit earned 0 total points
ID: 39984436
Thanks, but for some reason when I use that it puts the letters Chr in the paragraph, however I finally figured out I could use the postscript feature and create the fraction myself.
0
 

Author Comment

by:lhbit
ID: 39984476
I've requested that this question be closed as follows:

Accepted answer: 0 points for lhbit's comment #a39984436

for the following reason:

Trying to get it to work any other way doesn't work for me from .net, so I'm only posting my solution to close the thread, but keep it in history for somebody else.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39984473
If the text Chr is in the paragraph, I suspect you haven't used my code correctly. The function Chr() is called, nowhere is the text "Chr" put in the paragraph in the code I posted.

I'm objecting because I posted a perfectly good and simple solution (a month ago) including an example of the output, whereas your accepted solution is actually a workaround which may be useful but not as fitting to your actual question compared to the solution I posted.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39984477
Objection: please see my previous post for objecting to the chosen closure.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question