Hello,
I have a strange problem when using Aspose.Slides Dll on certain customer environments (in this case a Windows 2003 Server SP1). I want to copy a single slide from an existing presentation into a new PowerPoint presentation. The code looks like this:
private static PresentationEx CopySlideInNewPresentation(SlideEx slide)
{
PresentationEx presentation = CreateEmptyPresentation();
presentation.Slides.AddClone(slide);
return presentation;
}
as soon as .AddClone(slide) is called an excecption is thrown “Illegal characters in path” (see complete stacktrace below). The error seems to be related to certain settings in the target system as the same code runs without problems on other Windows 2003 Servers. The software runs within a windows service (as local system).
I suspect that a path setting (maybe userprofile?) is wrong but because of the obfuscated/encrypted stacktrace I’m not able to find the cause of this issue. Please can you give me some more details on possible causes of the exception below?
Thank you in advance for your assistance.
Kind regards,
Roland Domagalski
Windows Temp Folder : C:\WINDOWS\TEMP<br>SplitPresentationIntoSlides(C:\Programme\Foursoft\PresentationWorks_V1.0.0-SNAPSHOT\fileupload\Testfoliensatz_.pptx)
Exception: Illegales Zeichen im Pfad.
bei System.IO.Path.CheckInvalidPathChars(String path)
bei System.IO.Path.IsPathRooted(String path)
bei ..(IDictionary fileNames)
bei ..()
bei ..()
bei ..(String familyName, FontStyle style)
bei .e.(String familyName, FontStyle style, String altFamilyName)
bei .e.(String familyName, Single sizePoints, FontStyle style, String altFamilyName)
bei .…ctor(String fontFamily, Int32 charSet, Single emSize, FontStyle style)
bei ..(Single dpi)
bei ..(String text, textParam)
bei ..( begin, end, PortionEx portion, [] textParamsUsed)
bei ..( begin, end, PortionEx portion, Single& height, Single& descent)
bei ..()
bei .…ctor(ParagraphFormatEx[] cumulativeStyle, ParagraphExCollection paragraphs, Single width, Single height, Int32 columnCount, Single columnSpacing, Boolean wrapText, TextAnchorTypeEx anchor, Boolean anchorCenter, BaseSlideEx slide, FloatColor defaultColor, FontsEx defaultFonts, FontCollectionIndexEx defaultFontIndex, Single fontCoef, Single spacingReduction, rc)
bei Aspose.Slides.Pptx.TextFrameEx.(Single width, Single height, e cellTextStyle, rc)
bei Aspose.Slides.Pptx.TableEx.(e[,] cellTextStyles, rc)
bei Aspose.Slides.Pptx.TableEx.()
bei Aspose.Slides.Pptx.ShapesEx.( saveContext)
bei Aspose.Slides.Pptx.GroupShapeEx.( saveContext)
bei Aspose.Slides.Pptx.BaseSlideEx.( saveContext)
bei Aspose.Slides.Pptx.SlideEx.( saveContext)
bei Aspose.Slides.Pptx.PresentationEx.(BaseSlideEx source)
bei Aspose.Slides.Pptx.SlidesEx.(SlideEx slide, LayoutSlideEx layout)
bei Aspose.Slides.Pptx.SlidesEx.(SlideEx slide, MasterSlideEx master)
bei Aspose.Slides.Pptx.SlidesEx.(SlideEx slide)
bei Aspose.Slides.Pptx.SlidesEx.AddClone(SlideEx slide)
bei Util.CopySlideInNewPresentation(SlideEx slide, String filename)
Hi Roland,
Thanks for inquiring Aspose.Slides.
I have observed the sample code and stack trace shared by you. The sample code seems OK. Please try using Aspose.Slides for .NET 7.7.0 on your end and if there is still an issue then please share the sample presentation with us so that I may perform my investigation to help you further. For more insight on slide cloning, please visit this documentation link.
Many Thanks,
Hi Mudassir,
thank you very much for your immediate response. I will try to use the updated library to test again next week on our customer’s server.
Just wondering, could there be an issue in relation to fonts? The customer has some special fonts (typesetting and logo) that are used within the PowerPoint presentation. It might (I’ll check that next week) be the case that are Fonts are registered on the server but maybe the filename is wrong or corrupt within windows registry?
best regards,
Roland
Hi Roland,
Thanks for your feedback. I will wait for further response from your end when you will perform the testing with new version on your end. The issue may be related to some fonts as mentioned by you and I may request you to please also share the mentioned and used fonts if you are able to reproduce the issue on your end along with other information requested by me in my last post. Aspose.Slides does support true type fonts and support for Open type font is currently unavailable.
Many Thanks,
Hi Mudassir,
we have just tested it again with the latest release of Aspose .NET library (7.7.0) but the same exception is thrown when trying to copy the slide.
I will attach the exception again in a file and the .pptx-file that caused that issue. The method reads the file:
C:\Programme\Foursoft\PresentationWorks_V1.0.0-SNAPSHOT\fileupload\FoliensatzOhneLayout.pptx
and creates for each slide in the presentation a separate file under:
C:\Programme\Foursoft\PresentationWorks_V1.0.0-SNAPSHOT\sliderepository<>.pptx
(where UUID is generated - filename e.g. "7730c4e6-56da-426b-ab74-9fa98f8886a7.pptx"
both directories exist and are read/writable by the service.
I’ve already tried to save the empty presentation before cloning the slide - which works -but with not effect on the exception.
Would you please take a look at the presentation if you can see a reason why the exception is thrown here? Is it possible that the server of the customer is missing Windows Registry entries or is otherwise misconfigured? Btw. there is no Microsoft Office installation on the server - but I guess this should not be a reason for the problem.
Thank you again for your help!
Kind regards
Roland Domagalski
Hi Roland,
I have worked with the presentation file shared by you using Aspose.Slides for .NET 7.7.0 in Windows 7 x64 environment. I have used the following code on my end and have not been able to reproduce the issue on my end. For your kind reference I have also attached the generated presentations. It seems you have some fonts related or some path realated issue. Can you please try using the sample code on some other machine and using a drive where by there is no write access issue.
public static PresentationEx CopySlideInNewPresentation(SlideEx slide)
{
PresentationEx presentation = new PresentationEx();
presentation.Slides.AddClone(slide);
return presentation;
}
//Function Calls
PresentationEx src=new PresentationEx(path+“FoliensatzOhneLayout.pptx”);
PresentationEx dest = CopySlideInNewPresentation(src.Slides[0]);
dest.Write(path + “FoliensatzOhneLayout_Cloned1.pptx”);
dest = CopySlideInNewPresentation(src.Slides[1]);
dest.Write(path + “FoliensatzOhneLayout_Cloned2.pptx”);
Many Thanks,
Hi Mudassir,
thank you for your help. I tried it again in some other environments and everythings works as aspected. So I wrote a little program for the customer which checked every Value of Windows Registry Key:
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>DE</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><span style=“font-size: 11pt; font-family: “Calibri”,“sans-serif”;”>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Fonts
The result was that the server actually had an invalid entry (the name was " " - a single space char, the value was something like “¤÷?”). This was the cause of the exception because after deletion everything works here now also fine.
Thank you again for you assistance - it was not very clear for me at the beginning that cloning a slide could be influenced by such a strange font entry in the server’s registry.
Kind regards
Roland
<!–[if gte mso 10]>
<![endif]–>
Here ist the code snipplet I used to check the registry - if anyone is interested:
using System;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.IO;
using System.Runtime.InteropServices;
namespace CheckRegistry
{
class Program
{
[DllImport(“shfolder.dll”, CharSet = CharSet.Auto)]
private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
public static string GetFontsPath()
{
StringBuilder sb = new StringBuilder(260);
SHGetFolderPath(IntPtr.Zero, 0x0014, IntPtr.Zero, 0, sb);
return sb.ToString();
}
static void Main(string[] args)
{
string registryKey = @“SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts”;
RegistryKey fontKeys = Registry.LocalMachine.OpenSubKey(registryKey, false);
bool isRegistryKeyOk = true;
if (fontKeys != null)
{
foreach (string keyname in fontKeys.GetValueNames())
{
try
{
string fontfile = fontKeys.GetValue(keyname).ToString();
string filename = Path.Combine(GetFontsPath(), fontfile);
// call method that caused exception to test
bool isRooted = System.IO.Path.IsPathRooted(filename);
}
catch (Exception e)
{
isRegistryKeyOk = false;
}
}
}
Console.WriteLine(string.Format(“isRegistryKeyOk = {0}”, isRegistryKeyOk));
Console.ReadLine();
}
}
}
Hi Roland,