Unable to import PDF in 2024.4.1112 that did import in 2024.3.806

2 Answers 81 Views
PdfProcessing
Rob
Top achievements
Rank 2
Iron
Iron
Veteran
Rob asked on 12 Dec 2024, 03:12 PM

Hello,

I've been using Telerik.Web.Pdf to automate filling in the following EPA form from their website: EPA Form 3540-1- Notice of Arrival of Pesticides and Devices | US EPA

This has worked well until the 2024.4.1112 update.  Now using the standard import method:

var provider = new PdfFormatProvider();
using Stream stream = System.IO.File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources\\EPA-3540-1.pdf"));
var document = provider.Import(stream, TimeSpan.FromSeconds(10));

I get a Telerik.Windows.Docments.Fixed.Exceptions.NotSupportedActionException, with message "Action is not supported: Named"

I don't see any PDFImportSettings I can play with to possibly disable (Javascript?) and process as with the .3.806 version.  Are there any suggestions for me to try?

2 Answers, 1 is accepted

Sort by
1
Accepted
Yoan
Telerik team
answered on 17 Dec 2024, 12:32 PM

Hello Rob,

I am following up with some additional feedback on this case.

After further investigation and discussion with the team, we decided to log in a feature request on your behalf regarding the support of "Named Actions" by the PdfProcessing library. You can find the newly created task in our Feedback Portal - PdfProcessing: Add support for Named Actions. As a sign of appreciation for bringing this to our attention, I have also updated your Telerik Points.

If you are interested in this feature, please know that you can cast your vote for the task in order to increase its priority in our backlog and subscribe to it so you can track its progress by receiving notifications about potential status updates.

Thank you once again.

Regards,
Yoan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Rob
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 17 Dec 2024, 01:54 PM | edited

The other possibility I'd suggest is a PDFImportSetting that allows stripping (or ignoring) any actions and/or javascript.

I would expect most people importing a PDF are doing the same task - automating filling in the form, and Actions/Javascript is not required.  That said, I don't know how much work there is to support named actions, that could be easier, but the ImportSetting would also have the bonus of preventing importing in case of any other unsupported features or corrupt actions/javascript.

Yoan
Telerik team
commented on 18 Dec 2024, 12:09 PM

Hello Rob

Thank you for the provided feedback. Please also accept my apologies if there has been a misunderstanding however we already have a similar StripJavaScriptActions setting for the Export Settings of the PdfFormatProvider. It allows the user to specify whether or not the JavaScript actions should be stripped from the PDF document on export. I believe this should fit your requirements, however not hesitate to let me know if you have any further questions or feedback.

Regards,

Yoan

Rob
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 18 Dec 2024, 01:46 PM

Thank you Yoan,

I'm aware of the export setting, unfortunately I'm unable to strip on export since before I get there, the PDF fails with the "unsupported Named" crash on import. 

Best,

Rob

Yoan
Telerik team
commented on 19 Dec 2024, 01:22 PM

Hi Rob,

Please accept my apologies for the assumption and any misunderstanding on my part.

I truly appreciate your suggestion and understand the point you’re making. I have passed it along to the rest of the team for further discussion, and I can assure you that your feedback will be taken into consideration moving forward.

In the meantime, I hope the "Exception Handling" workaround I suggested has been helpful, as it’s currently the only alternative I can offer.

Thank you again for your understanding, and please don’t hesitate to reach out if you have any further questions or concerns.

Best,

Yoan

 

 

0
Yoan
Telerik team
answered on 16 Dec 2024, 09:18 AM

Hello Rob,

To avoid such exceptions you can utilize the Exception Handling mechanism of PdfProcessing. Since R2 2020 the library introduces two events as part of its exception-handling mechanism. This functionality allows exceptions to be intercepted and managed during document import or loading.

The following examples can also be seen in the above-linked article:

#1 Using the DocumentUnhandledException event while loading the entire document

public RadFixedDocument ImportDocument() 
{ 
    PdfFormatProvider provider = new PdfFormatProvider(); 
    provider.ImportSettings.ReadingMode = ReadingMode.AllAtOnce; 
    provider.ImportSettings.DocumentUnhandledException += ImportSettings_DocumentUnhandledException; 
    var document = provider.Import(File.ReadAllBytes("SampleDoc.pdf")); 
    return document; 
} 
 
private void ImportSettings_DocumentUnhandledException(object sender, DocumentUnhandledExceptionEventArgs e) 
{ 
    MessageBox.Show("The document is corrupted and cannot be loaded: " + e.Exception.Message); 
    e.Handled = true; 
} 

#2 Using the DocumentUnhandledException event while loading on demand

public void LoadDocument() 
{ 
    PdfFormatProvider provider = new PdfFormatProvider(); 
    provider.ImportSettings.ReadingMode = ReadingMode.OnDemand; 
    var document = provider.Import(File.ReadAllBytes("SampleDoc.pdf")); 
    document.DocumentUnhandledException += Document_DocumentUnhandledException; 
} 
 
private void Document_DocumentUnhandledException(object sender, DocumentUnhandledExceptionEventArgs e) 
{ 
    MessageBox.Show("The document is corupted and some pages cannot be loaded: " + e.Exception.Message); 
    e.Handled = true; 
} 

I hope this helps.

Regards,
Yoan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
PdfProcessing
Asked by
Rob
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Yoan
Telerik team
Share this question
or