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;

        }
5 REPLIES 5

@cnshum 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader