We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Reading contents of Word, PDF file

cnshum
Tera Contributor

i have this use case where i need to read the contents of CV/resume uploaded by users and pass it to a LLM to extract the skills. Currently, I am only able to do so using a txt file (refer to the below code).  But when i use this code on a pdf or word file, the contents are all weird symbols. Can anyone point me in the right direction?

code:

extractSkillsFromCV: function() {
        var tableSysId = this.getParameter('sysparm_tableSysId');
        var grAttach = new GlideRecord("sys_attachment");
        grAttach.addEncodedQuery("table_sys_id=" + tableSysId);
        grAttach.query();
        if(grAttach.next()){

            var document;
            var attach = new GlideSysAttachment().getContentStream(grAttach.sys_id);
            var reader = new GlideTextReader(attach);
            var ln = ' ';
            while ((ln = reader.readLine()) != null) {
                document += ln + "\n";

            }

            return document;

        }
0 REPLIES 0