How to add System.Environment.Newline to a PortionEx Text

Hi…

I have hundreds of text that I need to replace. How can replace the text with a multi-line text with the Newline?


I have text like TITLE
I need to replace it with text that looks like this

MY DOCUMENT TITLE
March 3, 2012
DRAFT

thanks in advance

Hi Jon,


Please visit this documentation link for the explanation of Paragraphs and Portions that are used in Aspose.Slides. If there is single line feed unless carriage return is found; that line belongs to one paragraph. Inside one line or paragraph the whenever the text formatting is changed new para is created. This way if seems difficult to set the text to multiple line. But you can use the option of soft enter, “\v” in .NET and \u000b” in case of Java for setting the paragraph text. This way single paragraph will be used but with multiple lines. Please visit thread link 1 and link 2 for your kind reference. Please share, if I may help you further in this regard.

Many Thanks,

I’m still not clear on what I have to do.

Can you please provide an example.
thank you

Hi Jon,


Please use the code snippet below for your further guidance.

String path = “C:\Users\Mudassir\Downloads\”;
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation(path+“TITLE.ppt”);

//Accessing a slide using its slide position
Slide slide = pres.GetSlideByPosition (1);

TextFrame tf = null;
foreach (Shape shape in slide.Shapes)
{
tf = shape.TextFrame;
if (tf != null && tf.Text != “”)
{
if(tf.Text.Equals (“TITLE”))
{

//The following line of code will replace text on text frame level
//Replacing text with n multi lines with carriage return will have n paragraphs
// tf.Text = “MY DOCUMENT TITLE\n March 3, 2012\nDRAFT”;

//Use above or use below code


//The following line of code will replace text on paragraph level and all text
//even of multiple lines will be accomodated in multiple lines using soft enter
tf.Paragraphs [0].Text = “MY DOCUMENT TITLE\v March 3, 2012\vDRAFT”;
}
}
}
//Writing the presentation as a PPT file
pres.Write(path+“modified.ppt”);

Many Thanks,

thanks!!!