Illegal characters in path

A call like Document.GetPageInfo(pageIndex); ou Document.RenderToScale(pageIndex, gfx, 0, 0, scale);

throws a system exception “illegal characters in path”

Works fine when compiled in vs2008 and frameword 3.5 but throws compiler in vs2010 framework 4.0

I’ve tried the last version and the problem remains…

Thanks

Pedro

Hi

Thanks for your request. Could you please attach the document you are getting problem with? I will investigate the problem on my side and provide you more information.
Best regards,

In any document that i tested in my machine. (Windows Vista)

Thanks

Hi

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (9.7.0) for testing.
You can download the latest version from here:
https://releases.aspose.com/words/net
Best regards,

Well actually the problem still exists in the current version of aspose.words but its not an easy one to reproduce. I’ve managed to isolate the problem and fix it because it was a problem in my system.

When in aspose.words “you” read all the fonts in the system from the registry and then try to see if its a filename or a complete file path, some entries in the registry had some junk \0\0\0 characters after the file name.

I think it would be nice not to “trust” in the registry and and validate the font path in a try block…

aspose.words code is something like this (then it fills some IDictionary with the paths):

string str = Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "Fonts");
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", false)) 
{
    if (key != null)
    {
        foreach(string str2 in key.GetValueNames())
        {
            string path = (string) key.GetValue(str2);
            if (Path.IsPathRooted(path))
            {
                path = Path.Combine(str, path);
            }
        }
    }
}

Hi there,
Thanks for this additional information.
It’s great you have done some investigation into this, are you able to attach the font files that appear to be causing the problem on your side here?
Thanks,

Hello.

I found exactly the same problem on one of our client’s PC.
“illegal characters in path”

I created the small test app using the code above and I’m getting the same error while calling Path.IsPathRooted(path).

I checked the Fonts key in the registry and found out the most of the values look like this when you check the binary data

0000 52 00 4F 00 4D 00 41 00 R.O.M.A.
0008 4E 00 2E 00 46 00 4F 00 N…F.O.
0010 4E 00 00 00 00 00 00 00 N…
0020 6F 00 00 00 o …

I don’t know why it happens, but we got one of our client with Win XP that has almost all the fonts saved with extra 00 at the end.
When you look at values as string they appear to be normal.
I can go though all value and re-save, it fixes the problem.

Hi
Thank you for additional information. Have you tried simply specify folder where Aspose.Words should look for fonts. Theoretically in this case, Aspose.Words should not read the registry and this should fix your problem:
https://reference.aspose.com/words/net/aspose.words.fonts/fontsettings/
hope this helps.
Best regards,

alexey.noskov:
Hi
Thank you for additional information. Have you tried simply specify folder where Aspose.Words should look for fonts. Theoretically in this case, Aspose.Words should not read the registry and this should fix your problem:
https://reference.aspose.com/words/net/aspose.words.fonts/fontsettings/
hope this helps.
Best regards,

I fixed the problem by re-saving all font keys in the registry.
I’m not setting the font folder in my code, I’m not playing with fonts at all. I’m just trying to load the Word document using Aspose.Word and Aspose.Words crashes. Luckily I found where the problem is (thanks to topic starter) and was able to manually fix it for our client.
But the problem is in Aspose.Words code and I believe that there is already enough info to locate and fix it.

Hi
Thank you for additional information. I logged your request into our defect database. We will check our code.
Best regards,

The issues you have found earlier (filed as WORDSNET-5564) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hello.

I found exactly the same problem on one of our client’s PC.
“illegal characters in path”

I created the small test app using the code above and I’m getting the same error while calling Path.IsPathRooted(path).

I checked the Fonts key in the registry and found out the most of the values look like this when you check the binary data

0000 52 00 4F 00 4D 00 41 00 R.O.M.A.
0008 4E 00 2E 00 46 00 4F 00 N…F.O.
0010 4E 00 00 00 00 00 00 00 N…
0020 6F 00 00 00 o …

I don’t know why it happens, but we got one of our client with Win XP that has almost all the fonts saved with extra 00 at the end.
When you look at values as string they appear to be normal.
I can go though all value and re-save, it fixes the problem.

Hello
when illegal character in path than the length of the path is become long so to remove
illegal character from the path you can use -long–path…tool for solving this types of
problem.


Hi Andrewop,

Thanks for the additional information. Did you manage to fix the issue on your side or are you still in need of assistance?

Best regards,