PDF Export - R1.2021 Version - method or operation is not implemented

1 Answer 19 Views
PdfProcessing
Angie
Top achievements
Rank 1
Angie asked on 11 Apr 2024, 10:32 PM

Hello, I have a PDF form where I am manipulating the fields.  When I try to use the example code I get the error - The method or operation is not implemented.  The current trial version works with this code, but I am using an old version.  Is this possible with the version I am using?

The form part seems to work ok, I just get the error on the final line.   Is there another way to save the file with the R1.2021 version?  Thank you!

File.WriteAllBytes(outputPath, pdfProvider.Export(document));

Full code from example:

 string inputPath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "PDFs\\ce_certificate.pdf";
 string fileName = "certificate_" + drCE["series_id"] + "_" + drCE["member_id"] + ".pdf";
 string outputPath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "PDFs\\CECertificates\\" + fileName;

 Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider pdfProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
 RadFixedDocument document = pdfProvider.Import(File.ReadAllBytes(inputPath));

 foreach (RadFixedPage page in document.Pages)
 {
     foreach (Annotation annotation in page.Annotations)
     {
         if (annotation.Type == AnnotationType.Widget)
         {
             Widget widget = (Widget)annotation;
             var field = widget.Field as TextBoxField;
             if (field != null)
             {
                 switch (field.Name)
                 {
                     case "member_name":
                         field.Value = drCE["full_name"].ToString();
                         break;
                     case "course_name":
                         field.Value = drCE["title"].ToString();
                         break;
                     case "ce_credits":
                         field.Value = drCE["total_credits"].ToString();
                         break;
                     case "completed_date":
                         field.Value = DateTime.Parse(drCE["complete_date"].ToString()).ToShortDateString();
                         break;
                 }
             }
         }
     }
 }


 //not implemented in our version
 //document.AcroForm.FlattenFormFields();

 //not implemented in our version
 File.WriteAllBytes(outputPath, pdfProvider.Export(document));

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 15 Apr 2024, 02:07 PM

Hello Angie,

First of all, in the code snippet, I noticed a flattening of Form Fields and wanted to point out that this functionality has only been available since the R2 2021 version of the DPL and you should keep that in mind when deciding which version to go with.

As for the described issue, I tried reproducing it into a sample project on my end by using a sample PDF form and referencing an R1 2021 DPL version, however, the application executes successfully and produces expected results. I am attaching the project for your disposal as well. 

It is possible that I am missing something, so feel free to share as much information and context as possible regarding this case that can help us reproduce and investigate it:

  • Exact Document Processing version
  • Project environment (NET Framework, NET Standard, NET Core)
  • Sample PDF document that reproduces the issue
  • Sample Project
  • Or you can modify the project I have attached so that it also reproduces the exception and send it back to us

With that in mind please know that this is a Q&A Forum which makes it a public thread and anything shared here will be available to anyone. You can always open a private ticket if you have any concerns.

Regards,
Yoan
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Angie
Top achievements
Rank 1
commented on 16 Apr 2024, 05:03 PM

Hi Yoan!  Thank you for the response and the example.  It does work fine, so there must be something different with my PDF file.  I did not create the file, but I did add the form fields.  I'm not too knowledgeable about PDFs in general. Oddly, the whole process does work fine with the current Telerik version. 

I'm attaching my PDF file. Any ideas on what's happening would be helpful!  Thank you!
Yoan
Telerik team
commented on 19 Apr 2024, 09:32 AM

Hello Angie,

Thanks for the provided document. I was able to achieve the same exception you are describing and I can confirm that it is caused on export by missing functionality concerning the fonts in the document. It looks like this functionality has been implemented further down the line which is why my advice to you would be to update to a more recent version where this case does not reproduce.

Thank you for your understanding.

Regards,

Yoan

Angie
Top achievements
Rank 1
commented on 19 Apr 2024, 03:37 PM

Thank you Yoan! I appreciate your help!  I will try to convince my boss to upgrade!  :-)
Tags
PdfProcessing
Asked by
Angie
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or