-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Adding an image to a slide fails with the error:
System.ArgumentException:
'Invalid name character in 'creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main"
id="{4C9EFE4F-2DDB-7B29-01C3-5A94A8DA92D4}" />'.
The ' ' character, hexadecimal value 0x20, cannot be included in a name.'
I cloned the repository and compiled my code against it. I was able to fix the issue by commenting out 2 lines in FileFormat.Slides.Facade.ImageFacade.cs
in the GeneratePicture
method:
------------------ 8< ---- snip ---- >8 ------------------
D.NonVisualDrawingPropertiesExtension nonVisualDrawingPropertiesExtension1 = new D.NonVisualDrawingPropertiesExtension() { Uri = "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}" };
//
// Removing these two lines made the error go away and PowerPoint did not complain about anything in the resulting presentation
//
//OpenXmlUnknownElement openXmlUnknownElement1 = new OpenXmlUnknownElement("<a16:creationId xmlns:a16=\"http://schemas.microsoft.com/office/drawing/2014/main\" id=\"{4C9EFE4F-2DDB-7B29-01C3-5A94A8DA92D4}\" />");
//nonVisualDrawingPropertiesExtension1.Append(openXmlUnknownElement1);
nonVisualDrawingPropertiesExtensionList1.Append(nonVisualDrawingPropertiesExtension1);
------------------ 8< ---- snip ---- >8 ------------------
I don't know enough to know if that was a good idea or a bad idea, but it worked for me.
Minimal reproduction case:
using DocumentFormat.OpenXml.Spreadsheet;
using FileFormat.Slides;
Presentation presentation = Presentation.Create(@"C:\temp\test_add_image.pptx");
Slide slide = new();
var image = new Image(@"C:\Temp\test_img.jpg")
{
X = 0,
Y = 0,
Width = 200.0,
Height = 200.0
};
slide.AddImage(image);
presentation.AppendSlide(slide);
presentation.Save();
Windows 10
.Net 8.0
FileFormat.Slides version 25.1.0 from nuget and repeatable from source
-Cam
Metadata
Metadata
Assignees
Labels
No labels