We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Migrating Slides 5 to 14 - Problems with Slides.Notes and Slides.Link

I’ve inherited the source code for a conversion program to generate PPT and found that some of the namespaces no longer exist in Aspose.

I am no longer able to find the namespaces Aspose.Slides.Link and Aspose.Slides.Notes. I assume they are no longer supported?

If that is the case, is there somewhere I can find documentation on how to migrate the methods and properties of the two namespaces from the older version to the newer version, e.g.

Link Methods: AddLink(), ClearLink() and AddLink() (on PictureFrame)
Link Properties: Begin, End, Links (on TextFrame)
Notes Properties: Paragraphs


Your help appreciated!

Hi Tobias,

Thank you for considering Aspose.

Please share the sample code you are using with the legacy version to give us a better idea of your requirement and we will share the converted code with you as per your requirement.

Thanks & Regards,

Hi!


Below is some of the code that references the old Link (and Notes) class. Thank you for helping out on this!




private Aspose.Slides.Link getTextLink()
{
Aspose.Slides.Link link = null;
if (this.LinkObjectType == LinkObjectType.Text)
{
link = this.TextFrame.Links.AddLink();
link.Begin = this.StartFromChar;
link.End = this.EndAtChar;
}
return link;
}


private Aspose.Slides.Link getImageLink()
{
Aspose.Slides.Link link = null;
if (this.LinkObjectType == LinkObjectType.Image)
{
this.PictureFrame.ClearLink();
link = this.PictureFrame.AddLink();
}
return link;
}


internal static void CreateLinks(PPT ppt)
{
foreach (LinkTracker trackedLink in Links)
{
Aspose.Slides.Link link = null;
if (trackedLink.LinkObjectType == LinkObjectType.Text)
link = trackedLink.getTextLink();
else if (trackedLink.LinkObjectType == LinkObjectType.Image)
link = trackedLink.getImageLink();

if (link != null)
{
//Internal topic link?
bool wasInternal = false;
if (trackedLink.LinkActionType == AuthorIt.PPTExporter.Translation.LinkType.Internal)
{//Internal
string topicID = getTopicIDFromLink(trackedLink.HRef);
if (topicID != string.Empty)
{//we got an ID from the file
Aspose.Slides.Slide slide = Slide.GetForTopicID(ppt.AsposePresentation, topicID);

if (slide != null)
{//And a slide
link.SetInternalHyperlink(slide);
wasInternal = true;
}
}
}

if (!wasInternal)//External
setExternalLink(link,trackedLink.HRef);
}

}
}

private static void setExternalLink(Aspose.Slides.Link link, string linkRef)
{
//Is the path an internal file link (link to resource in the root of the AuthorIt output directory)
if (!Path.IsPathRooted(linkRef)
&& Path.GetFileName(linkRef) == linkRef.Trim().Replace("\", “”).Replace("/", “”)
&& !InternalFileLinks.Contains(linkRef.ToLower()))
InternalFileLinks.Add(linkRef.ToLower());

link.SetExternalHyperlink(linkRef);
}

internal static PortionRawFormat GetForNote(Aspose.Slides.Notes notes)
{
PortionRawFormat pFormat = new PortionRawFormat();
if (notes.Paragraphs.Count > 0 && notes.Paragraphs[0].Portions.Count > 0)
{
Aspose.Slides.Portion portion = notes.Paragraphs[0].Portions[0];
pFormat = GetForPortion(portion);
}
return pFormat;
}

internal TextContent(Aspose.Slides.Notes notes)
{
_notes = notes;
_textContentType = mode.Notes;
_portionDefaultFormat = PortionRawFormat.GetForNote(notes);

}

Hi Tobias,

Thank you for sharing the code for reference.

You can use following properties to manipulate the hyperlinks with PictureFrame.

public Hyperlink HLinkClick
public IHyperlink HyperlinkMouseOver
public Hyperlink HLinkMouseOver
public IHyperlinkManager HyperlinkManager

Following is a sample code for your reference:

Sample Code:
using (Presentation pres = new Presentation())

{

//Get the first slide

ISlide sld = pres.Slides[0];

//Instantiate the ImageEx class

System.Drawing.Image img = (System.Drawing.Image)new Bitmap(“d:\data\Test.png”);

IPPImage imgx = pres.Images.AddImage(img);

//Add Picture Frame with height and width equivalent of Picture

IPictureFrame picf = sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);

//Set Hyperlink for the portion text

IHyperlinkManager HypMan = picf.HyperlinkManager;

HypMan.SetExternalHyperlinkClick(“https://www.aspose.com/”);

//Write the PPTX file to disk

pres.Save(“d:\data\RectPicFrame.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);

}

Similarly, for ITextFrames, you may check the following documentation link.

Regarding the Notes Paragraph property, you can see the following sample code for your reference:

Sample Code:

Presentation pres = new Presentation();

ISlide slide = pres.Slides[0];

INotesSlide note = slide.AddNotesSlide();

IAutoShape ashp = (IAutoShape)note.Shapes[1];

IParagraph para = ashp.TextFrame.Paragraphs[0];

para.Text = “Notes text here”;

pres.Save(“D:\Data\NotesSlide.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,