Hello!
I get exceptions when open some files using method Import() in PdfFormatProvider.
I prepared 1 such file to you for tests: http://u.pc.cd/3TlctalK
Version of libraries which I use is 2020.3.915
I noticed, that exceptions appears for files with outlines.
There is DestinationConverter object and its method ConvertFromArray where that exception appears.
Here is exception message:
Unable to cast object of type "Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfReal" to type "Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfName".
Here is a StackTrace:
in Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExceptionHandler.TryHandle(Exception exception)
in Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ImportOverride(Stream input)
in PdfViewer.States.AppStateExtensions.ReadDocumentForTelerik(String filePath)
My method:
internal
static
RadFixedDocument ReadDocumentForTelerik(
string
filePath)
{
if
(filePath ==
null
)
throw
new
ArgumentNullException(nameof(filePath));
using
(Stream stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
var provider =
new
PdfFormatProvider();
provider.ImportSettings = PdfImportSettings.ReadOnDemand;
return
provider.Import(stream);
}
}
Using:
var doc = ReadDocumentForTelerik(@
"C:\Outline_Down.pdf"
);
I found another exception
Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfReal' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfInt'.
Here is StackTrace:
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Stack`1.Peek()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.Parser.PostScriptReader.PushToken(IPdfPrimitive primitive)
at Telerik.Windows.Documents.Data.StateMachine.State`1.ExecuteActionIfNotNull(Action`1 action, TArgs arguments)
at Telerik.Windows.Documents.Data.StateMachine.StateMachine`1.GoToState(State`1 state, TArgs arguments)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.Parser.PostScriptReader.ReadAllPrimitivesToToken(IPdfImportContext context, PdfElementType tokenType)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.Parser.PostScriptReader.Read[T](IPdfImportContext context, PdfElementType tokenType)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.BaseImportContext.ReadUsedIndirectObject(CrossReferenceEntry entry)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.BaseImportContext.ReadIndirectObject(IndirectReference reference)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.PrimitiveWrapperConverter.Convert(Type type, PostScriptReader reader, IPdfImportContext context, IPdfPrimitive value)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Data.PdfPropertyBase`1.PrepareValue(PostScriptReader reader, IPdfImportContext context, IPdfPrimitive value)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Data.LoadOnDemandPropertyBase`1.GetValueFromSource()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Data.LoadOnDemandPropertyBase`1.GetValue()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Utilities.PdfObjectsExtensions.GetInheritableProperty[T,V](ITreeNode`1 node, Func`2 getPropertyFromNodeValue, V defautValue)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Forms.FieldPropertiesImporter.InitializeSignatureFieldProperties(SignatureField signatureField)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.<>c__DisplayClass53_0.<CopyFormFieldsTo>b__0()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution[E](Action operation)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPropertiesTo(PostScriptReader reader, IRadFixedDocumentImportContext context)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution[E](Action operation)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ImportOverride(Stream input)
Document has several digital signatures inside.
But with
pdfFormatProvider.ImportSettings.UseOldRendering = false
is working.
Hi Janez,
The stack trace is not sufficient to determine the reason for this exception, so in order to investigate the case we will need to examine the document causing the exception. Could you open a private ticket thread and send it to us?
I must assure you we treat all client files in a strictly confidential manner and for testing purposes only.