I was trying to manipulate guides like those in the attached file. With the current version of PowerPoint guides can be defined for
the presentation (shown on all slides), stored in presentation.xml p:presentation/p:extLst/p:ext/p15:sldGuideLst
masters, stored in slideMaster1.xml p:sldMaster/p:extLst/p:ext/p15:sldGuideLst
slide layouts, stored in slideLayout1.xml p:sldLayout/p:extLst/p:ext/p15:sldGuideLst
I tried the following code. It seems to work with the guides from viewProps.xml which partially correspond to those in presentation.xml.
using (var p = new Presentation("Guides.pptx"))
{
var guides = p.ViewProperties.SlideViewProperties.DrawingGuides;
Console.WriteLine(string.Join(Environment.NewLine, guides.Select(g => $"{g.Orientation} {g.Position}")));
}
But it lists a horizontal guide that doesn’t actually show in PowerPoint. Also, it doesn’t give access to guides configured on the master or layout level.
Can you help me to get access to the actual guides?
To access the actual guides configured at the master or layout level in a PowerPoint presentation using Aspose.Slides, you need to directly access the slide masters and layouts instead of relying solely on the ViewProperties of the presentation.
Here’s how you can retrieve the guides from the slide masters and layouts:
using (var presentation = new Presentation("Guides.pptx"))
{
// Accessing guides from slide masters
foreach (var slideMaster in presentation.Masters)
{
var masterGuides = slideMaster.DrawingGuides;
Console.WriteLine($"Master Guides for {slideMaster.Name}:");
foreach (var guide in masterGuides)
{
Console.WriteLine($"{guide.Orientation} {guide.Position}");
}
}
// Accessing guides from slide layouts
foreach (var slideMaster in presentation.Masters)
{
foreach (var layout in slideMaster.Layouts)
{
var layoutGuides = layout.DrawingGuides;
Console.WriteLine($"Layout Guides for {layout.Name}:");
foreach (var guide in layoutGuides)
{
Console.WriteLine($"{guide.Orientation} {guide.Position}");
}
}
}
}
This code iterates through each slide master and its layouts, retrieving the drawing guides defined at those levels. This should provide you with the actual guides you are looking for.
If you encounter discrepancies, ensure that the guides are correctly defined in your PowerPoint file, as the Aspose.Slides library reflects the content of the file as it is structured.
slideMaster.Layouts should be slideMaster.LayoutSlides.
Then compiling results in
error CS1061: ‘IMasterSlide’ does not contain a definition for ‘DrawingGuides’ and no accessible extension method ‘DrawingGuides’ accepting a first argument of type ‘IMasterSlide’ could be found (are you missing a using directive or an assembly reference?)
error CS1061: ‘ILayoutSlide’ does not contain a definition for ‘DrawingGuides’ and no accessible extension method ‘DrawingGuides’ accepting a first argument of type ‘ILayoutSlide’ could be found (are you missing a using directive or an assembly reference?)
@co213,
Thank you for contacting free support. I have reviewed your requirements. It seems Aspose.Slides does not provide for managing drawing guides on masters and slide layouts.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESNET-45176
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The presentation file contains the following drawing guides:
the vertical line for presentation slides
the horizontal line for presentation slides
the horizontal line for the slide master
the horizontal line for the “Title Slide” layout
the horizontal line for the “Title and Content” layout
Please note that the horizontal line for presentation slides and the one for the slide master share the same position.
Thanks for your response @andrey.potapov. I understand that you can’t promise support for managing the additional guides any time soon. I’ll try to find a workaround. When support is ready I’ll be happy to make use of it.
The presentation slides guides behavior is funny for me. When I delete the horizontal it comes back the next time the file is opened. Anyways, I won’t blame that on Aspose.