Community

FC11 : recognition if pdf file

Hello

 

A question about scripting in FC.

I have a image importation profile which imports attached files of emails : pdf essentially.

Nevertheless , today there are png and jpg files imported too. So I would like to delete these files by script before recognition.

My idea is : if the imageSource ends with pdf, it's ok ; in the other case KO, the file must be deleted.

Do you havec a sample of script in this mind ?

Thank you.

 

JA

0

Comments

1 comment

  • Avatar
    Jean-Alain MAILLARD

    Good afternoon,

    Finally, I've added a new workflow step in order to analyze the received files. This step is positioned before recognition.

    Then, this automatic step is linked to a script :

    using System;
    foreach(IDocument doc in Batch.Documents){
        IPage page=doc.Pages[0];
        String filePath = page.ImageSourceFileSubPath;

        if(!filePath.EndsWith(".pdf")) {
            Processing.ReportMessage("Erreur à l'entrée : " + filePath + " n'est pas un PDF. Il va être supprimé !");
            Batch.DeleteDocument(doc);
        } else{
            Processing.ReportMessage("Validation à l'entrée : " + filePath + " est pas un PDF. Il doit être conservé !");
        }
    }

    If it can help someone.

    Thanks a lot for all optimisation, too!

     

    0

Please sign in to leave a comment.