Hi,
Hi Sandeep,
Hi,
Hi Sandeep,
Any update on this? Is there any workaround for this?
Hi Sandeep,
At least let me know some workaround to achieve this.
Hi Sandeep,
We have investigated the issue. We have plan to improve the TextParagraph to support WrapLines feature. However as workaround you can consider following code. TextParagraph has some functions to get the same behavior as WrapLines produce.
//The example demonstrates how to
create text paragraph object and append it to the Pdf page<o:p></o:p>
Document doc = new Document();
Page page = doc.Pages.Add();
// create text paragraph
TextParagraph paragraph = new TextParagraph();
// set the paragraph rectangle
double left = page.PageInfo.Margin.Left;
double right = page.PageInfo.Width - page.PageInfo.Margin.Right;
double top = page.PageInfo.Height - page.PageInfo.Margin.Top;
paragraph.Rectangle = new Aspose.Pdf.Rectangle(left, top - 50, right, top);
// set word wrapping options
paragraph.FormattingOptions.WrapMode = TextFormattingOptions.WordWrapMode.ByWords;
paragraph.VerticalAlignment = VerticalAlignment.Top;
// append text fragment(s)
TextFragment textFragment = new TextFragment("In process to move from Aspose.Pdf.Generator to Aspose.Pdf I need to Move from Text to TextFragment. I am not sure how i can wrap lines in TextFragment. I am not sure how i can wrap lines in TextFragment");
paragraph.AppendLine(textFragment);
// append the paragraph to the Pdf page with the TextBuilder
TextBuilder textBuilder = new TextBuilder(page);
textBuilder.AppendParagraph(paragraph);
// save Pdf document
doc.Save(myDir + "wrapline_DOM.pdf");
If you change FormattingOptions.WrapMode, you can make single line paragraph. It produces the same behavior as 'WrapLines = 1'. See resultant wrapline_DOM_1.pdf.
paragraph.FormattingOptions.WrapMode = TextFormattingOptions.WordWrapMode.NoWrap;
</o:p>
<o:p> </o:p>
<o:p></o:p>
But if you need several lines, you must change Rectangle property to trim unnecessary lines. For example if rectangle height will be near double font size it saves two lines, It produces the same behavior as ‘WrapLines = 2’.
paragraph.Rectangle = new
Aspose.Pdf.Rectangle(left, top - 20, right,
top);<o:p></o:p>
Best Regards,
Hi,
Hi Sandeep,
The issues you have found earlier (filed as PDFNEWNET-37507) have been fixed in Aspose.Pdf for .NET 16.10.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi Sandeep,
//WrapLines in plain text:<o:p></o:p>
string outFile = myDir+"37507.pdf";
Document doc1 = new Document();
Page page1 = doc1.Pages.Add();
TextFragment title = new TextFragment("In process to move from Aspose.Pdf.Generator to Aspose.Pdf I need to Move from Text to TextFragment. I am not sure how i can wrap lines in TextFragment. I am not sure how i can wrap lines in TextFragment");
title.WrapLinesCount = 1;
//title.WrapLinesCount = 2;
page1.Paragraphs.Add(title);
doc1.Save(outFile);
//WrapLines in Table:
outFile = myDir+"37507_3.pdf";
// Load source PDF document
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
// Add page
Page page = doc.Pages.Add();
// Initializes a new instance of the Table
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
// Set the table border color as LightGray
table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// Set the border for table cells
table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// Create a loop to add 10 rows
for (int row_count = 1; row_count < 10; row_count++)
{ // Add row to table
Aspose.Pdf.Row row = table.Rows.Add();
// Add table cells
TextFragment fragment = new TextFragment("Very long text in column (" + row_count + ", 1)");
fragment.WrapLinesCount = 1;
Aspose.Pdf.Cell cell = new Aspose.Pdf.Cell();
cell.Paragraphs.Add(fragment);
row.Cells.Add(cell);
row.Cells.Add("Column (" + row_count + ", 2)");
row.Cells.Add("Column (" + row_count + ", 3)"); }
// Add table object to first page of input document
page.Paragraphs.Add(table);
doc.Save(outFile);
Hi,
I am trying to convert some really old code from the Generator.Text to Text.TextFragment
The code was this:
Dim loText As New Pdf.Generator.Text(loSt.ReadToEnd()) With {.WrapLines = True}
The code is now this:
Dim loText As New Pdf.Text.TextFragment(loSt.ReadToEnd())
But I am unclear how the WrapLinesCount works as it is no longer a boolean. The above example has =1 (and =2 commented out) but no indication how to just let it wrap as required.
I don’t know how many I want. I just want it to be wrapping. Do I need to set anything?
Thanks, Julie
Are you adding text inside table cells? Would you kindly share the complete code snippet that you are using to add text along with an expected output PDF. Please share the complete text as well. We will test the scenario in our environment and address it accordingly.