Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

How do you stop words from being split across two lines

$
0
0
Dear Team

We have an issue in using Aspose.pdf. We need to convert HTML to PDF. The issue is words are getting split to next lines. Attaching the code & sample output for reference. Please help

Code

 

Dim pdf As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()

 

                       'set the license file

                       Dim lic AsNew Aspose.Pdf.License()

                        lic.SetLicense(System.Web.HttpContext.Current.Server.MapPath("AsposeLicense/Aspose.Total.lic"))

 

                       ' add the section to PDF document sections collection

                       Dim section As Aspose.Pdf.Generator.Section = pdf.Sections.Add()

 

                        section.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth

                        section.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight

 

 

 

                       Dim marginInfo As Aspose.Pdf.Generator.MarginInfo = New Aspose.Pdf.Generator.MarginInfo()

                        marginInfo.Top = 0

                        marginInfo.Bottom = 0

                       marginInfo.Left = 0

                        marginInfo.Right = 0

 

                       Dim marginInfotext As Aspose.Pdf.Generator.MarginInfo = New Aspose.Pdf.Generator.MarginInfo()

                        marginInfotext.Top = 95

                        marginInfotext.Bottom = 95

                        marginInfotext.Left = 35

                        marginInfotext.Right = 35

 

                        section.PageInfo.Margin = marginInfotext

 

                       Dim txt1 As Aspose.Pdf.Text.TextFragment = New Aspose.Pdf.Text.TextFragment()

                        txt1.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Justify

 

                       Dim graph1 As Aspose.Pdf.Generator.Graph = New Aspose.Pdf.Generator.Graph(section)

                        graph1.Margin.Top = 0

                        graph1.Margin.Bottom = 0

                        section.Paragraphs.Add(graph1)

                                             

                        Dim text As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text(section, sHtml)

                       

 

                        text.IsHtmlTagSupported = True

 

                        section.Paragraphs.Add(text)

                        section.IsSpaced = True

 

                       'set page size

                        pdf.PageSetup.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth

                        pdf.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight

 

                       

                        pdf.PageSetup.Margin = marginInfo

 

                        pdf.Save(sTempPDF)

 

 

HTML Source sHtml =

 

<html><body><table cellspacing="2.50cm" width="100%"><tbody><tr><td><p></p><p><br /></p><p style="margin-top: 0px;margin-bottom: 0px;">1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;an&nbsp;example&nbsp;of&nbsp;a&nbsp;decision,&nbsp;including&nbsp;special&nbsp;characters&nbsp;like&nbsp;"ô"&nbsp;and&nbsp;"í"&nbsp;and&nbsp;"ã"&nbsp;and&nbsp;other&nbsp;features&nbsp;(like&nbsp;parentheses)&nbsp;and&nbsp;a&nbsp;noun's&nbsp;possessive&nbsp;forms.&nbsp;--</p><p><br /></p><p style="margin-left: 0.5in;margin-top: 0px;margin-bottom: 0px">a.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Some&nbsp;parts&nbsp;of&nbsp;the&nbsp;text&nbsp;will&nbsp;need&nbsp;to&nbsp;be&nbsp;indented.</p><p><br /></p><p style="margin-left: 1in;margin-top: 0px;margin-bottom: 0px">i).&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;some,&nbsp;even&nbsp;further;</p><p><br /></p><p style="margin-top: 0px;margin-bottom: 0px;">2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;All&nbsp;paragraphs&nbsp;will&nbsp;also&nbsp;need&nbsp;a&nbsp;tab&nbsp;character&nbsp;between&nbsp;the&nbsp;number&nbsp;and&nbsp;text,&nbsp;which&nbsp;transfers&nbsp;to&nbsp;the&nbsp;IR&nbsp;intact,&nbsp;and&nbsp;paragraph&nbsp;breaks&nbsp;between&nbsp;each.</p><p></p><p><br /></p><p></p><p><br /></p></td></tr></tbody></table></body></html>

Thanks
Anish

Viewing all articles
Browse latest Browse all 3131

Trending Articles