Hello, I had many problems with version 2023.1.117, latest stable 2023.2.606 is unusable also due to issue with scanned documents etc, so I tried 2020.2.703-hotfix, but I am getting other set of issues.
Unfortunately I cannot share the documents, since they are confidential.
With some documents I am getting this error:
Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfName' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Objects.FormXObject'.
Loading Code:
PdfFormatProvider pdfFormatProvider = new();
RadFixedDocument document = pdfFormatProvider.Import(bytes);
And stack trace:
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.AppearanceConverter.ConvertFromDictionary(PostScriptReader reader, IPdfImportContext context, PdfDictionary dictionary)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.AppearanceConverter.Convert(Type type, PostScriptReader reader, IPdfImportContext context, IPdfPrimitive value)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.AppearanceConverter.ConvertFromIndirectReference(Type type, PostScriptReader reader, IPdfImportContext context, IndirectReference indirectReference)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.AppearanceConverter.Convert(Type type, PostScriptReader reader, IPdfImportContext context, IPdfPrimitive value)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.AppearancesConverter.TryImportAppearance(String key, PostScriptReader reader, IPdfImportContext context, PdfDictionary appearancesDictionary, Appearance& appearance)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.AppearancesConverter.ConvertFromDictionary(Type type, PostScriptReader reader, IPdfImportContext context, PdfDictionary dictionary)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Converters.Converter.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(Boolean shouldDecrypt)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Data.LoadOnDemandPropertyBase`1.GetValue(Boolean shouldDecrypt)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Annotations.AnnotationObject.get_Appearances()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Annotations.AnnotationObject.ToAnnotation(PostScriptReader reader, IRadFixedDocumentImportContext context, Double pageHeightInDip)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.Page.<>c__DisplayClass21_0.<CopyPageAnnotationsTo>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.Page.CopyPageAnnotationsTo(IRadFixedDocumentImportContext context, RadFixedPage fixedPage)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.<>c__DisplayClass59_2.<CopyAllPageProperties>b__2()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution[E](Action operation)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyAllPageProperties(PostScriptReader reader, IRadFixedDocumentImportContext context, List`1 contextPages, IList`1 pages)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPagePropertiesTo(PostScriptReader reader, IRadFixedDocumentImportContext context)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPropertiesTo(PostScriptReader reader, IRadFixedDocumentImportContext context)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.RadFixedDocumentImportContext.BeginImportOverride()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.BaseImportContext.BeginImport(Stream pdfFileStream)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.PdfImporter.Import(Stream input, IPdfImportContext context)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.<>c__DisplayClass18_0.<ImportOverride>b__0()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution[E](Action operation)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ImportOverride(Stream input)
at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Import(Stream input)
at Telerik.Windows.Documents.Common.FormatProviders.BinaryFormatProviderBase`1.Import(Byte[] input)
at Client.Wpf.Common.UserControls.PdfViewer.LoadBytesToPdfViewer(Byte[] bytes) in C:\Users\tomas.filip\source\repos\FiFi\Client.Wpf\Common\UserControls\PdfViewer.xaml.cs:line 65
at System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
at System.Reactive.ObserveOnObserverNew`1.DrainStep(ConcurrentQueue`1 q)
at System.Reactive.ObserveOnObserverNew`1.DrainShortRunning(IScheduler recursiveScheduler)
at System.Reactive.Concurrency.DispatcherScheduler.<>c__DisplayClass12_0`1.<Schedule>b__0()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
I'm trying to use the PdfFormatProvider to import a pdf. I've tried to import multiple different pdfs with the code below, but they all throw an exception with "System.InvalidOperationException: 'Import not supported.'" and no other info. Is this a bug or am I not calling the correct method to import a pdf?
var providerPDF = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider(); providerPDF.Import(File.ReadAllBytes(@"D:\TestDocs\TestImage.pdf"));
Hi,
I am trying to convert a HTML body to a PDF using HtmlFormatProvider and PdfFormatProvider.
It works well when I try to create a pdf with "normal" characters, but when I use characters like "åäö" the characters is either missing or replaced with other character.
I have found a similiar issue but that was due to the fact that the person was using .net core I am using .net framework.
Am I missing something when I am converting it to a PDF or is there a limitation with special characters like "åäö".
private string CreateAndStorePdf(string htmlBody)
{
Telerik.Windows.Documents.Extensibility.JpegImageConverterBase jpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = jpegImageConverter;
var provider = new HtmlFormatProvider();
var document = provider.Import(htmlBody);
var exportProvider = new PdfFormatProvider();
var fixedExportProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
var fileName = "_original.pdf";
try
{
using (var outputStream = new MemoryStream())
{
exportProvider.Export(fixedExportProvider.ExportToFixedDocument(document), outputStream);
outputStream.Seek(0, SeekOrigin.Begin);
var pdfBytes = new BinaryReader(outputStream).ReadBytes((int)outputStream.Length);
return fileName;
}
}
catch (Exception ex)
{
Log.Error(ex, "The pdf could not be created.");
return null;
}
}
Hello Support,
I am generating pdf using PdfFormatProvider. In this i am passing html data which should be converted into pdf. For that I have written below code.
HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider(); RadFlowDocument htmlDocument = htmlFormatProvider.Import(htmlContentValue); var anotherpara = sectionBody.Blocks.AddParagraph(); editor.MoveToParagraphStart(anotherpara); editor.InsertDocument(htmlDocument, options);
This works fine and also get pdf with expected value. But I would like to set spacing between two lines which I could not set or its not working. For that I have added below code.
I have also attached screenshot for it. like how its showing on pdf
editor.ParagraphFormatting.AutomaticSpacingAfter.LocalValue = false; editor.ParagraphFormatting.AutomaticSpacingBefore.LocalValue = false; editor.ParagraphFormatting.SpacingAfter.LocalValue = 0; editor.ParagraphFormatting.SpacingBefore.LocalValue = 0;
So could you please let me know fix for it.
I have read that there limitations to PDF files being imported, however, the file being imported was generated with FixedContentEditor, so, should be able to import?
using (Stream stream = Stream)I was working on some acroforms and wherever I needed a space I kept on getting a different letter (Ê). On debugging the problem seems to be in the TryGetCharCode function of OpenTypeFontSource
Version: 2019.3.917
Below is copy of function
public override bool TryGetCharCode(int unicode, out int charCode)
{
bool result = false;
ushort glyphId;
charCode = CMap.MISSING_GLYPH_ID;
if (this.TryGetGlyphId(unicode, out glyphId))
{
ushort uCharCode = CMap.MISSING_GLYPH_ID;
CMapTable table = this.CMap.GetCMapTable(3, 0);
if (table != null)
{
result = table.TryGetCharId(glyphId, out uCharCode);
}
table = this.CMap.GetCMapTable(1, 0);
if (table != null)
{
result = table.TryGetCharId(glyphId, out uCharCode);
}
charCode = uCharCode;
return result;
}
return false;
}
The font used has 2 cmap tables: one with platformid of 3 and encodingid of 1, the other with platformid 1 and encodingid 0. According to https://docs.microsoft.com/en-us/typography/opentype/spec/cmap platform id 3 and encoding 1 is correct for windows so not sure why the first call to getcmaptable looks for encodingid 0.
Second of all even if I change it to the following
CMapTable table = this.CMap.GetCMapTable(3, 1);
if there is a second cmap with platformid of 1 whatever the result of the call with regards to platformid 3, the result will be overridden
I can say that if I add some checks so that if the first call succeeds it doesn't attempt the 2nd I do get the expected behaviour in the pdf and get spaces
As a note the FontFamily property of the OpenTypeFontSource is "Arial"