-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Bug when using 25.7.0
When i try to add any images i get this crash
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.
at System.Xml.XmlWellFormedWriter.CheckNCName(String ncname)
at System.Xml.XmlWellFormedWriter.WriteStartElement(String prefix, String localName, String ns)
at DocumentFormat.OpenXml.OpenXmlUnknownElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.Save(Stream stream)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.SaveToPart(OpenXmlPart openXmlPart)
at DocumentFormat.OpenXml.Presentation.Slide.Save(SlidePart openXmlPart)
at Openize.Slides.Facade.PresentationDocumentFacade.AppendSlide(SlideFacade slideFacade)
at Openize.Slides.Presentation.AppendSlide(Slide slide)
at Api.Controllers.PdfController.GetPpt(Int32 id) in C:\Users\j.jeantet\RiderProjects\proposition-amelioration\Api\Controllers\PdfController.cs:line 89
at lambda_method2(Closure, Object, Object[])
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
My code :
var myobject= myobjectService.GetById(id, true);
var output = Path.GetTempFileName();
var presentation = Presentation.Create(output);
var Slide = new Slide();
var imagePath = Path.Join(Directory.GetCurrentDirectory(), $"myobject_{id}.png");
var imageBytes = Convert.FromBase64String(myobject.Photo);
FileIO.WriteAllBytes(imagePath, imageBytes);
var width = 0;
var height = 0;
// in the real code i get the size of the image here
var image = new Image(imagePath)
{
Name = "ImageX",
X = 180.0,
Y = 128.0,
Width = width,
Height = height
};
Slide.AddImage(image);
var Logo = new Image(Path.Combine(Directory.GetCurrentDirectory(), "logo.png"))
{
Name = "Logo",
Height = 4.27.CmToPixels(),
Width = 1.98.CmToPixels(),
X = 0.18.CmToPixels(),
Y = 0.13.CmToPixels()
};
Slide.AddImage(Logo);
presentation.AppendSlide(Slide);
presentation.Save();