I have further investigated the requirements shared by you and like to share that in case of PPTX, Aspose.Slides allows to provide BookmarkID as string associated with any portion. This is a string field and you can set any name to it. I have created a sample application for your convenience as under. In addParas() method, I am creating a sample presentation and adding bookmark id for added portions. Then I opened the generated presentation in PowerPoint and made some changes in it by removing extra paragraph. Then I used the checkBookmarks() method to access the modified presentation and observed the Bookmark Ids. It seems to work exactly as required. Please share, if I may help you further in this regard.
public static void addParas()
{
//Instantiate a PresentationEx class that represents a PPTX file
PresentationEx pres = new PresentationEx();
//Accessing first slide
SlideEx slide = pres.Slides[0];
//Add an AutoShape of Rectangle type
int idx = slide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 50, 150, 300, 150);
AutoShapeEx ashp = (AutoShapeEx)slide.Shapes[idx];
//Access TextFrame of the AutoShape
TextFrameEx tf = ashp.TextFrame;
//Create Paragraphs and Portions with different text formats
ParagraphEx para0 = tf.Paragraphs[0];
PortionEx port01 = new PortionEx();
PortionEx port02 = new PortionEx();
para0.Portions.Add(port01);
para0.Portions.Add(port02);
ParagraphEx para1 = new ParagraphEx();
tf.Paragraphs.Add(para1);
PortionEx port10 = new PortionEx();
PortionEx port11 = new PortionEx();
para1.Portions.Add(port10);
para1.Portions.Add(port11);
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
tf.Paragraphs[i].Portions[j].Text = “Portion”+i.ToString() + j.ToString();
string id = tf.Paragraphs[i].Portions[j].BookmarkId;
tf.Paragraphs[i].Portions[j].BookmarkId = “Field_para_” +i.ToString()+“portion”+ j.ToString();
id = tf.Paragraphs[i].Portions[j].BookmarkId;
if (j == 0)
{
tf.Paragraphs[i].Portions[j].FillFormat.FillType = FillTypeEx.Solid;
tf.Paragraphs[i].Portions[j].FillFormat.SolidFillColor.Color = Color.Red;
tf.Paragraphs[i].Portions[j].FontBold = NullableBool.True;
tf.Paragraphs[i].Portions[j].FontHeight = 15;
}
else if (j == 1)
{
tf.Paragraphs[i].Portions[j].FillFormat.FillType = FillTypeEx.Solid;
tf.Paragraphs[i].Portions[j].FillFormat.SolidFillColor.Color = Color.Blue;
tf.Paragraphs[i].Portions[j].FontItalic = NullableBool.True;
tf.Paragraphs[i].Portions[j].FontHeight = 18;
}
}
}
//Write PPTX to Disk
pres.Write(“d:\Aspose Data\multiParaPort.pptx”);
}
public static void checkBookmarks()
{
PresentationEx pres = new PresentationEx(“d:\Aspose Data\multiParaPort_modified.pptx”);
SlideEx slide = pres.Slides[0];
AutoShapeEx ashp = (AutoShapeEx)slide.Shapes[0];
TextFrameEx tf = ashp.TextFrame;
int paraCount = tf.Paragraphs.Count;
ParagraphEx para = null;
PortionEx portion = null;
for (int i = 0; i < paraCount; i++)
{
para = tf.Paragraphs[i];
for (int j = 0; j < para.Portions.Count; j++)
{
portion = para.Portions[j];
Console.WriteLine(" Portion Text is :"+portion.Text);
Console.WriteLine(" Paragraph :" + i.ToString() + " Portion :" + j.ToString() + " has Bookmard ID :" + portion.BookmarkId);
}
}
}