How can I solve this following error

Product:

Product Version:

Please give a brief summary of your issue:
(Think of this as an email subject)
I am doing a text extraction work using apryse sdk. I am using java as the language. when I accessing the file it gives following error.

Exception in thread “main” java.lang.RuntimeException: Exception:
Message: Exception:
Message: MappingManager file not found: …/files/sample
Conditional expression: PathOps::Exists(filename)
Version : 10.5.0-f1b7f76eb0
Platform : Windows
Architecture : AMD64
Filename : MappingManager.cpp
Function : trn::Filters::MappingManager::Init
Linenumber : 166

 Conditional expression: PathOps::Exists(filename)
 Filename   : MappingManager.cpp
 Function   : trn::Filters::MappingManager::Init
 Linenumber : 166
 Error code : 0

at Main.main(Main.java:33)

Caused by: Exception:
Message: Exception:
Message: MappingManager file not found: …/files/sample
Conditional expression: PathOps::Exists(filename)
Version : 10.5.0-f1b7f76eb0
Platform : Windows
Architecture : AMD64
Filename : MappingManager.cpp
Function : trn::Filters::MappingManager::Init
Linenumber : 166

 Conditional expression: PathOps::Exists(filename)
 Filename   : MappingManager.cpp
 Function   : trn::Filters::MappingManager::Init
 Linenumber : 166
 Error code : 0

at com.pdftron.pdf.PDFDoc.PDFDocCreate(Native Method)
at com.pdftron.pdf.PDFDoc.<init>(PDFDoc.java:167)
at Main.main(Main.java:14)

and this is the code I developed

PDFNet.initialize(“demo:nisanga1995511@gmail.com:7ca872c40200000000a553466810be64dd08c13ff390336a5abbf5dfe7”);
String input_path=“…/files/”;
boolean example3_wordlist = true;

    try(PDFDoc doc = new PDFDoc(input_path+"sample")){
        doc.initSecurityHandler();
        Page page = doc.getPage(1);
        if(page==null){
            System.out.println("Page not found");
        }
        TextExtractor txt = new TextExtractor();
        txt.begin(page);

        if(example3_wordlist){
            TextExtractor.Word word;
            for(TextExtractor.Line line= txt.getFirstLine();line.isValid(); line=line.getNextLine()){
                for(word=line.getFirstWord();word.isValid();word=word.getNextWord()){
                    System.out.println(word.getNextWord());
                }
            }
        }
        txt.destroy();
    } catch (PDFNetException e) {
        throw new RuntimeException(e);
    }
    PDFNet.terminate();
}

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:

1 Like

Hi,

The exception you are seeing is because the SDK is failing to open the input file. This is normally caused by an incorrect path to the input file. You are designating the input file with the following code:

try(PDFDoc doc = new PDFDoc(input_path+“sample”)){…}

If you use an invalid file name here you will see the exception you are reporting. Should “sample” be the actual file name? I.E. “sample.pdf”?

1 Like