Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

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: 14
Joined: Thu Jun 15, 2017 10:54 pm

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: 3099
Joined: Tue Sep 06, 2016 8:30 am

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: 14
Joined: Thu Jun 15, 2017 10:54 pm

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: 3099
Joined: Tue Sep 06, 2016 8:30 am

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: 14
Joined: Thu Jun 15, 2017 10:54 pm

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: 3099
Joined: Tue Sep 06, 2016 8:30 am

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: 3099
Joined: Tue Sep 06, 2016 8:30 am

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: 3099
Joined: Tue Sep 06, 2016 8:30 am

Sun Oct 29, 2017 2:47 pm

Is this fix available yet in the free version?

Also, I noticed that the issue is not only that it separates the currency symbol from the number, but it also separates the number itself.
For example, "$150.00" the "$150." Is at the end of one line and the ".00" will be start on the next line.

yyp
 
Posts: 14
Joined: Thu Jun 15, 2017 10:54 pm

Mon Oct 30, 2017 2:42 am

Dear yyp,

Sorry that we don't have the plan to update free version, so the fix is not included in free version now.
As for the dot issue, after testing, I have noticed it would split "$150.00" into "$150." and "00" when page break, and posted it to our Dev team. Once there is any progress, we will let you know.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Oct 30, 2017 5:42 pm

The issue is not only when "page break" but also when "line break".

(Do you ever plan on updating the free version?)

yyp
 
Posts: 14
Joined: Thu Jun 15, 2017 10:54 pm

Tue Oct 31, 2017 1:49 am

Dear yyp,

Thanks for your response. Yes, the issue also will happen when line break. And we will inform you when there is any progress.
In addition, sorry that we will not update the free version. If there is any question, please let us know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Mar 19, 2019 7:02 am

Dear yyp,

Glad to inform you the issue is solved in Spire.PDF Pack(Hot Fix) Version:5.3.8.
Our website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDF/

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF