Currently the DocumentInfo property is for export purposes only and meta information about documents is stripped when importing.
According to the PDF specification (ISO 32000), the document info dictionary (often called "metadata" or "Info" dictionary) can include the following standard fields:
• Title: The document’s title.
• Author: The name of the person who created the document.
• Subject: The subject of the document.
• Keywords: Keywords associated with the document.
• Creator: The application that created the original document.
• Producer: The application that converted the document to PDF.
• CreationDate: The date and time the document was created.
• ModDate: The date and time the document was last modified.
• Trapped: Indicates whether the document has been trapped (a printing term).
These fields are stored in the PDF’s Info dictionary and are used by PDF viewers for display, search, and indexing.
The issue is not reproducible in Q1 2025 (2025.1.205).
In Q2 2025 we introduced the MarkedContent in a RadFixedDocument.
Error message:
Unable to cast object of type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.PdfInt' to type 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.MarkedContents.StructAttributeObject'.
This is the code for reproducing the incorrect PDF document. If the step with changing the font is commented, the document is exported properly:
//Step 1: Create an instance of XlsxFormatProvider to import the Excel file
XlsxFormatProvider xlsxFormatProvider = new XlsxFormatProvider();
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider pdfFormatProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
Workbook workbook;
using (FileStream input = new FileStream("Input.xlsx", FileMode.Open))
{
workbook = xlsxFormatProvider.Import(input, TimeSpan.FromSeconds(10));
}
//Step 2: Export the workbook to PDF RadFixedDocument to modify fonts
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider spread_pdf_provider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
RadFixedDocument fixedDocument = spread_pdf_provider.ExportToFixedDocument(workbook, TimeSpan.FromSeconds(10));
foreach (var page in fixedDocument.Pages)
{
foreach (var content in page.Content)
{
if (content is TextFragment text)
{
// Replace the font with Helvetica or HelveticaBold based on the original font style
text.Font = text.Font.Name.ToLower().Contains("bold")
? FontsRepository.HelveticaBold
: FontsRepository.Helvetica;
}
}
}
//Step 3: Save the modified RadFixedDocument back to PDF
string outputFileName = "ExportedWorkbook.pdf";
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider fixed_pdf_provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
using (FileStream output = new FileStream(outputFileName, FileMode.Create))
{
fixed_pdf_provider.ExportSettings.DocumentUnhandledException += ExportSettings_DocumentUnhandledException;
fixed_pdf_provider.ExportSettings.FontEmbeddingType = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.FontEmbeddingType.Subset;
fixed_pdf_provider.Export(fixedDocument, output, TimeSpan.FromSeconds(10));
}
Process.Start(new ProcessStartInfo() { FileName = outputFileName, UseShellExecute = true });
Introduced in version 2025.4.1104.
Works OK in the previous version.
StackTrace:
at Telerik.Windows.Documents.Utilities.Guard.ThrowExceptionIfTrue(Boolean condition, String message)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.IndirectObject.get_Content()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExportContext.BeginExportIndirectObject(IndirectObject indirectObject, Int64 offset)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Types.IndirectObject.Write(PdfWriter writer, IPdfExportContext context)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.WritePendingIndirectObjects(IPdfExportContext context, PdfWriter writer)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.WriteFontsFromContext(PdfWriter writer, IPdfExportContext context)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.Export(IRadFixedDocumentExportContext context, Stream output)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.<>c__DisplayClass21_0.<ExportOverride>b__0()
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution[E](Action operation)
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFixedDocument document, Stream output, CancellationToken cancellationToken)
at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output, Nullable`1 timeout)