Some PDF files are showing the following error during the watermark merging process. Please find the error below and kindly advise.
Error:
at Telerik.Windows.Documents.Utilities.Guard.ThrowExceptionIfNull[T](T param, String paramName) at Telerik.Windows.Documents.Fixed.Model.RadFixedDocument.Merge(RadFixedDocument source) at FinalPdfGenerator.CommitteePdfGeneratorService.CreateClonedDocument(RadFixedDocument document, RadFixedDocument existingDocument, Notes note) in C:\Users\JayaprakashS\Xencia\IndianBank\CodeMerge_01Oct24\LatestReviewIBCode_IBUAT_05Jun25\FinalPdfGenerator\CommitteePdfGeneratorService.cs:line 129
at FinalPdfGenerator.CommitteePdfGeneratorService.GenerateFirstPage(Notes e_Note) in C:\Users\JayaprakashS\Xencia\IndianBank\CodeMerge_01Oct24\LatestReviewIBCode_IBUAT_05Jun25\FinalPdfGenerator\CommitteePdfGeneratorService.cs:line 215
at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Operators.Text.ShowText.Execute(IContentStreamInterpreter interpreter, IPdfContentImportContext context, PdfString text) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Operators.Text.ShowTextArray.Execute(IContentStreamInterpreter interpreter, IPdfContentImportContext context) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.InterpreterBase`1.<>c__DisplayClass8_0.<Execute>b__0() at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution[E](Action operation, Action`1 onException) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.InterpreterBase`1.Execute() at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.ContentStream.ParseContentData(Byte[] data, IRadFixedDocumentImportContext context, IResourceHolder resourceHolder, IContentRootElement contentRoot, ContentStreamKeywordCollection keywordCollection) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.Page.CopyPageContentTo(IRadFixedDocumentImportContext context, RadFixedPage fixedPage) 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 FinalPdfGenerator.CommitteePdfGeneratorService.LoadExistingDocument(String file) in C:\Users\JayaprakashS\Xencia\IndianBank\CodeMerge_01Oct24\LatestReviewIBCode_IBUAT_05Jun25\FinalPdfGenerator\CommitteePdfGeneratorService.cs:line 727
at FinalPdfGenerator.CommitteePdfGeneratorService.GenerateFirstPage(Notes e_Note) in C:\Users\JayaprakashS\Xencia\IndianBank\CodeMerge_01Oct24\LatestReviewIBCode_IBUAT_05Jun25\FinalPdfGenerator\CommitteePdfGeneratorService.cs:line 215
at Telerik.Windows.Documents.Utilities.Guard.ThrowExceptionIfNull[T](T param, String paramName) at Telerik.Windows.Documents.Fixed.Model.RadFixedDocument.Merge(RadFixedDocument source) at FinalPdfGenerator.CommitteePdfGeneratorService.CreateClonedDocument(RadFixedDocument document, RadFixedDocument existingDocument, Notes note) in C:\Users\JayaprakashS\Xencia\IndianBank\CodeMerge_01Oct24\LatestReviewIBCode_IBUAT_05Jun25\FinalPdfGenerator\CommitteePdfGeneratorService.cs:line 129
at System.Runtime.CompilerServices.RuntimeHelpers.AllocateUninitializedClone(Object obj) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.SimpleFontObject.GetToUnicodeOverride(CharCode code) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontObject.GetCharactersOverride(PdfString str) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Operators.Text.ShowText.Execute(IContentStreamInterpreter interpreter, IPdfContentImportContext context, PdfString text) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Operators.Text.ShowTextArray.Execute(IContentStreamInterpreter interpreter, IPdfContentImportContext context) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.InterpreterBase`1.<>c__DisplayClass8_0.<Execute>b__0() at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.ExceptionHandling.ExecutionHandler.TryHandleExecution[E](Action operation, Action`1 onException) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.InterpreterBase`1.Execute() at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.ContentStream.ParseContentData(Byte[] data, IRadFixedDocumentImportContext context, IResourceHolder resourceHolder, IContentRootElement contentRoot, ContentStreamKeywordCollection keywordCollection) at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.Page.CopyPageContentTo(IRadFixedDocumentImportContext context, RadFixedPage fixedPage) 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 FinalPdfGenerator.CommitteePdfGeneratorService.LoadExistingDocument(String file) in C:\Users\JayaprakashS\Xencia\IndianBank\CodeMerge_01Oct24\LatestReviewIBCode_IBUAT_05Jun25\FinalPdfGenerator\CommitteePdfGeneratorService.cs:line 727
Code:
private RadFixedDocument CreateClonedDocument(RadFixedDocument document, RadFixedDocument existingDocument, Model.Notes note)
{
RadFixedDocument clonedDocument = new RadFixedDocument();
try
{
foreach (RadFixedPage currentPage in existingDocument.Pages)
{
Watermark(currentPage, note.strNoteStatus, 0, 0, FirstVal);
Watermark(currentPage, note.noteNumber, 0, 65, SecVal);
}
clonedDocument.Merge(GenerateFirstPage(note));
clonedDocument.Merge(existingDocument);
clonedDocument.Merge(GenerateSignaturePage((int)note.noteId));
clonedDocument.Merge(CommentAuditLogPage((int)note.noteId));
int pageNumber = 0;
foreach (RadFixedPage currentPage in clonedDocument.Pages)
{
pageNumber++;
Footer(currentPage, pageNumber, clonedDocument.Pages.Count);
}
}
catch (Exception ex) {
AddLogs(_dbContext, "ECommittee Pdf Genarator", ex.StackTrace, ex.InnerException?.ToString());
}
return clonedDocument;
}
Hello Ilangovan,
Thank you for reaching out.
I'm sorry to hear you're experiencing unexpected results. I'm happy to assist you with this case, but at the moment, I believe I don't have enough information and context about this issue, to be able to reproduce it on my side and provide you with concrete details.
It looks like the provided code snippet uses two documents and a Model.Notes object. However, I don't have access to these documents or any information about the structure or data inside Model.Notes. Without this context, it's difficult for me to investigate the issue thoroughly.
To help me better understand the situation and assist you more effectively, could you please share a small sample project that reporduces the exception and includes:
This will help me reproduce the behavior on my end, look deeper into the issue, and provide you with accurate feedback and possible solutions.
NOTE: Please remember that this is a public Q&A forum, and anything shared here will be visible to others. If you have any privacy concerns, feel free to remove or replace any sensitive information with dummy data—just make sure the issue can still be reproduced.
Thank you in advance for your cooperation. I look forward to your reply!
Regards,
Yoan