keep currency symbol on same line

Technical support for Spire.PDF

Moderator: iceblue support

keep currency symbol on same line

Postby yyp » Thu Jun 15, 2017 11:05 pm

I'm working on taking the text of a letter and creating a simple pdf.
The text goes something like this:
"I would like to take this opportunity to thank you for your generous contribution of $500.00."

Now, when the pdf is created, the currency symbol "$" is at the end of the line, and the "500.00" comes up on the start of the following line.

Here is the code that demonstrates the issue. Any help is greatly appreciated.

Dim doc As New PdfDocument
Dim page As PdfPageBase = doc.Pages.Add

Dim letterWidth As Single = 468
Dim letterHeight As Single = 468
Dim LetterText as String = "I would like to take this opportunity to thank you for your generous contribution of $500.00."

Dim font As New System.Drawing.Font("Calibri", 12, FontStyle.Regular)
Dim ttf As New PdfTrueTypeFont(font, True)
Dim brush As New PdfSolidBrush(Color.Black)

Dim format As New PdfStringFormat
format.LineSpacing = 12
format.ParagraphIndent = 36

Dim textLayout As New PdfTextLayout
textLayout.Break = PdfLayoutBreakType.FitPage
textLayout.Layout = PdfLayoutType.OnePage

Dim textWidget As New PdfTextWidget(LetterText, ttf, brush)
textWidget.StringFormat = format

Dim bounds As New Rectangle(x, y, letterWidth, letterHeight)

textWidget.Draw(page, bounds, textLayout)

doc.SaveToFile(PdfDest)
doc.Close()
yyp
 
Posts: 8
Joined: Thu Jun 15, 2017 10:54 pm

Re: keep currency symbol on same line

Postby Betsy.jiang » Fri Jun 16, 2017 3:24 am

Dear yyp,

Thanks for your inquiry.
Please change the letterWidth to a larger value, then it will be on same line.
Code: Select all
int letterWidth = 500;

If there is any issue, please let us know.

Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1425
Joined: Tue Sep 06, 2016 8:30 am

Re: keep currency symbol on same line

Postby yyp » Fri Jun 16, 2017 4:57 am

Hi Betsy,

Thank you for your response, but your suggestion that I change the letterWidth is really not viable.

My application allows the user to specify the Left and Right margins. I use those values to automatically calculate the letterWidth.
It just so happens that 468 is 6.5 inches. When using a Letter size page (8.5 x 11) and setting 1 inch margins, you get 6.5 in letterWidth.

My application also allows the user to create their own Letters. So the letterText is also not fixed (so changing to a different letterWidth which will work for one letterText may not work for a different letterText.

There is something wrong in that the rendering engine does not consider the dollar sign to be of the same word as the numbers that follow. This is the issue.

Please address the real issue as to why the "$500.00" is being separated into two lines.

Thank!
yyp
 
Posts: 8
Joined: Thu Jun 15, 2017 10:54 pm

Re: keep currency symbol on same line

Postby Betsy.jiang » Fri Jun 16, 2017 8:31 am

Dear yyp,

Thanks for the prompt response.
Sorry to hear that the solution doesn't work for you. I noticed the issue that the symbol and the followed value is not on same line, and posted it to our Dev team, once there is any progress, we will inform you.
In addition, I found the width of the text "I would like to take this opportunity to thank you for your generous contribution of $500.00." is about 450 points. And you also set ParagraphIndent, so the rectangle width should be equal to text width add ParagraphIndent when you draw text. It will break when the rectangle width is not enough. And there are some solutions to keep the text on same line for your kind reference.
1. Reduce font size or increase font size
2. Change the rectangle width
Code: Select all
Dim bounds As New Rectangle(x, y, letterWidth + ParagraphIndent , letterHeight)


Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1425
Joined: Tue Sep 06, 2016 8:30 am

Re: keep currency symbol on same line

Postby yyp » Fri Jun 16, 2017 3:53 pm

Thank you for the reply. I'm looking forward to hear what the dev department say about this.

I'm totally ok with the letter text breaking into lines. In fact, the letterText I provided was just the start of a multi paragraph letter. The issue is, again, that it breaks between the currency symbol and the amount.

Changing the width, font, fontsize etc, is not an option as I explained, since these are all user defined settings.
yyp
 
Posts: 8
Joined: Thu Jun 15, 2017 10:54 pm

Re: keep currency symbol on same line

Postby Betsy.jiang » Mon Jun 19, 2017 3:51 am

Dear yyp,

Thanks for your feedback.
If there is any news from our Dev team, I will notify you.

Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1425
Joined: Tue Sep 06, 2016 8:30 am

Re: keep currency symbol on same line

Postby Betsy.jiang » Tue Jun 27, 2017 3:47 am

Dear yyp,

Thanks for waiting.
Now the issue is fixed in Spire.PDF Pack(Hot Fix) Version:3.9.181, welcome to test it.
Looking forward to your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1425
Joined: Tue Sep 06, 2016 8:30 am

Re: keep currency symbol on same line

Postby Betsy.jiang » Thu Jun 29, 2017 9:28 am

Dear yyp,

Did you test the hotfix ? Has your issue been resolved ?
Could you please give us some feedback at your convenience ?

Thanks,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1425
Joined: Tue Sep 06, 2016 8:30 am


Return to Spire.PDF

Who is online

Users browsing this forum: No registered users and 0 guests

cron