Free Support Forum - aspose.com

System.NotSupportedException when saving to pdf/xps

Hi,

I’m trying to save a document to pdf. When the document contains text, I get a “System.NotSupportedException” (exception details are attached at the end of this post). The same happens when I save as Xps. An empty document or a document with just images (like in the ImageToPdf example) is saved correctly.

I’m using Visual Studio 2008 with .Net 3.5SP1 on a 64 bit Vista computer. The version of Aspose.Words is 7.0.0

System.NotSupportedException was unhandled
Message=“Unknown name table format.”
Source=“Aspose.Words”
StackTrace:
bij 䍓.䐈.䐧()
bij 䍓.䐈.䐝(String Ӽ)
bij 䍓.䐈.䐻(String 䐼)
bij 䍓.䐈.get_ਮ()
bij 䍓.䐈.䐢(String せ)
bij 䍓.䐈.䎉(String せ, FontStyle ঈ, Boolean 䐜)
bij 䍓.䐈.ਚ(String せ, FontStyle ঈ, Boolean 䐜)
bij 䊠.䍂…ctor(䋮 context, String familyName, FontStyle requestedStyle)
bij 䊠.䎓…ctor(䋮 context, String familyName, FontStyle requestedStyle)
bij 䊠.䍂.䍏(䋮 ೉, String せ, FontStyle ਪ, Boolean 䍐)
bij 䊠.䎂.ਚ(String せ, FontStyle ঈ, Boolean 䍐)
bij 䊠.䖿.䗇(⑽ 䖪)
bij 䊠.䖤.䂳(⑽ 䖪)
bij 䊠.䊶.VisitGlyphs(⑽ glyphs)
bij ⑪.⑽.Accept(⑸ visitor)
bij ⑪.⑵.Accept(⑸ visitor)
bij ⑪.⒕.Accept(⑸ visitor)
bij ⑪.⑵.Accept(⑸ visitor)
bij ⑪.⒕.Accept(⑸ visitor)
bij ⑪.⑵.Accept(⑸ visitor)
bij ⑪.⒕.Accept(⑸ visitor)
bij ⑪.⑵.Accept(⑸ visitor)
bij ⑪.⑹.Accept(⑸ visitor)
bij 䊠.䊶.␮(⑷ Ԉ)
bij Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, Stream stream, PdfOptions options)
bij Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, String fileName, PdfOptions options)
bij Aspose.Words.Document.SaveToPdf(String fileName)
bij AsposeWordsTest1.Window1.Button_Click(Object sender, RoutedEventArgs e) in C:\Users\Jaap\Documents\Visual Studio 2008\Projects\AsposeWordsTest1\AsposeWordsTest1\Window1.xaml.cs:regel 48
bij System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bij System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
bij System.Windows.Controls.Button.OnClick()
bij System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
bij System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
bij System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bij System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
bij System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
bij System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
bij System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bij System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
bij System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
bij System.Windows.Input.InputManager.ProcessStagingArea()
bij System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
bij System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
bij System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
bij System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bij System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bij MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bij MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
bij System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
bij System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
bij System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
bij MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bij MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
bij System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
bij System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
bij System.Windows.Application.RunInternal(Window window)
bij AsposeWordsTest1.App.Main() in C:\Users\Jaap\Documents\Visual Studio 2008\Projects\AsposeWordsTest1\AsposeWordsTest1\obj\Debug\App.g.cs:regel 0
bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bij System.Threading.ThreadHelper.ThreadStart()
InnerException:

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Could you please attach your document here for testing? I will check the problem on my side and provide you more information.

Best regards,

The code to reproduce this is:

var document = new Document();
var builder = new DocumentBuilder(document);
builder.Writeln(“test”);
document.SaveToPdf(“test.pdf”);

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I cannot reproduce the problem on my side. I tested on both 32bit and 64bit OS. From stack trace, it seems, there could be a problem with font. By default, Aspose.Words uses Times New Roman font. Please, for testing, try to specify another font:

var document = new Document();

var builder = new DocumentBuilder(document);

builder.Font.Name = "Arial";

builder.Writeln("test");

document.SaveToPdf(@"C:\Temp\test.pdf");

If this code will work fine on your side, please attach your “Times New Roman” fonts here for testing.

Best regards,

Hi Andrew,

I tried your suggestion. Unfortunately this doesn’t solve the problem.

Best regards,
Jaap-Willem

Thank you for additional information. Could you please attach your “Times New Roman” and “Arial” fonts here for testing? I will investigate the issue and provide you more information.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Best regards,

Hi,

I have attached my ‘Times New Roman Standard’ and my ‘Arial Standard’ fonts as found in the ‘c:\windows\fonts’ folder.

Regards,
JaapWillem

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Unfortunately, I still cannot reproduce the problem on my side.

Best regards,

Hi,

I have tested it on 4 other machines in our shop. Three of them worked ok, but the other one also crashes. I do not see any simularities that both crashing machines share that can explain the problem.

My Machine
Desktop
64 bit
Windows Vista - Dutch
Office 2007 - Dutch

Other Machine
Laptop

32 bit

Windows Vista - English

Office 2007 - Dutch

First I thought maybe it’s the dutch version of Office 2007. So I tested it on another machine (Windows XP) with Office 2007. But on this machine it works OK.

Regards,
Jaap-Willem


Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I still think that the reason of the problem is fonts. Do you have any additional fonts installed on these PCs? Could you please compare lists of fonts on PCs where code works fine and on PCs where code fails? If you will find some difference, please send me additional fonts, which are installed on PCs where code fails.

Best regards,

Hi Andrew,

What could be wrong with my fonts? All other programs on my PC work correctly. There are more than 450 fonts installed on my PC and I have no idea where to look for.

I have tried to use different font in Apose Words, but all fail.

Regards,
Jaap-Willem

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. During converting document to PDF and XPS Aspose.Words reads font files and creates subsets of fonts, which are used in PDF and XPS. This is needed to reduce size of output files.

Do you use Aspose.Words in evaluation mode? If so, Aspose.Words adds evaluation watermark at the top of your document. This watermark text is “Times New Roman” text. You can request a 30-day Temporary License to test Aspose.Words without evaluation limitations. Please refer to

http://www.aspose.com/corporate/purchase/faqs/temporary-license.aspx

Could you please attach all “Times New Roman” fonts, which are installed on your side, i.e. Times New Roman Italic, Bold, etc.

Best regards,

Hi Andrew,

Thanks for your clarification. Reading your explanation do I understand it correctly that Aspose.Words only reads one of the Times New Roman fonts, create a subset and embeds this subset in the PDF file?

I have attached all my ‘times new roman’ fonts.

Best regards,
Jaap-Willem

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Aspose.Words reads all font files which are used in the document and creates subsets of these fonts. Regarding the problem, I still cannot reproduce it on my side. Did you try using Aspose.Words with temporary license?

Best regards,

Hi Andrew,



No I did not try the temporary license. As an alternative to go through the whole PO process, can you
create a simple application that just creates a new document, adds a
paragraph and save it to pdf. This way I can test if a licenced
application works correctly.



Regards,

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please request a 30-day Temporary License to test Aspose.Words without evaluation limitations as described here

http://www.aspose.com/corporate/purchase/faqs/temporary-license.aspx

And please apply license as described here:
http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/applying-a-license.html

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/when-to-apply-a-license.html

And try using your code. I cannot send you my license due the license agreement.

Best regards,

Hi Andrew,


Sorry but I am not allowed to go through an order process, so I can not request a temporary license. I’m not asking you for your license, but for a small compiled sample application.

Regards,
Jaap-Willem

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. What do you mean? Temporary license is absolutely free, you do not need to pay anything to get it.

Best regards,

Hi Andrew,


The documentation about the temporary license made it seem that I had to make an order and then not pay. After looking at the actual 'purchase' page I discovered that I could request a key by using the 'Get pricing information' option.

Anyway, I have requested and installed the key, but the code still fails. I can see the license is installed correctly because in a saved docx file I don't see the evaluation text.

After your comment about embedding subfonts, I tried saving to pdf as shown below:
document.SaveToPdf(0, 1, "test.pdf", new PdfOptions() { IsEmbedTrueTypeFontsForAsciiChars = false });
Unfortunately this doesn't solve the problem.

I have attached a sample project that fails on my developer machine and on a machine of a collegue. Maybe this gives you a clue about the problem.

Regards,
Jaap-Willem

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Your sample test project works without any issues on my side. So, I still cannot reproduce the problem.

Best regards,