odttf file does not conform to the expected file format specification

128 Views Asked by At

This code produce the error on specific document

XpsDocument docReader = new XpsDocument(d.XPSFilename.FullName, FileAccess.Read);
...
XpsDocumentWriter docWriter = PrintQueue.CreateXpsDocumentWriter(pq);
...
docWriter.Write(docReader.GetFixedDocumentSequence());  // L574

How to fix it - document looks valid in all viewers?

Caught general exception in AddJobToPrintQueue
'pack://file:,,,c:,dist,b126405b-14a3-27f4-9564-83ca6cb89dc7/Documents/1/Resources/Fonts/6AD92D16-EBC6-11F7-A6B1-63FA277E94F9.odttf' file does not conform to the expected file format specification.
   at MS.Internal.TrueTypeSubsetter.ComputeSubset(Void* fontData, Int32 fileSize, Uri sourceUri, Int32 directoryOffset, UInt16[] glyphArray)
   at MS.Internal.FontFace.TrueTypeFontDriver.ComputeFontSubset(ICollection`1 glyphs)
   at System.Windows.Media.GlyphTypeface.ComputeSubset(ICollection`1 glyphs)
   at System.Windows.Xps.Serialization.FEMCacheItem.SubSetFont(ICollection`1 glyphs, Stream stream)
   at System.Windows.Xps.Serialization.FEMCacheItem.Commit()
   at System.Windows.Xps.Serialization.XpsFontSubsetter.CommitFontSubsetsSignal(FontSubsetterCommitPolicies signal)
   at System.Windows.Xps.Serialization.XpsSerializationManager.ReleaseXmlWriter(Type writerType)
   at System.Windows.Xps.Serialization.FixedPageSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
   ....
   at System.Windows.Xps.Serialization.DocumentSequenceSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
   at System.Windows.Xps.Serialization.XpsSerializationManager.SaveAsXaml(Object serializedObject)
   at System.Windows.Xps.XpsDocumentWriter.SaveAsXaml(Object serializedObject, Boolean isSync)
   at System.Windows.Xps.XpsDocumentWriter.Write(FixedDocumentSequence fixedDocumentSequence)
   at EQXPSJobSubmitterConsole.Program.PrintWithDocumentWriter(PrintQueue pq, ThreadDetails d, PrintTicket deltaPrintTicket) in 
   
   Program.cs:line 574
1

There are 1 best solutions below

0
user2347380 On

I found the eproblem: This font was not in directory: /Documents/1/Resources/Fonts/6AD92D16-EBC6-11F7-A6B1-63FA277E94F9.odttf

Looks like a bug - it shoold complain about missed bug - not about incorrect one.