Vedachalam Mahadevan
03/17/2025, 6:17 AMCeligo AI
03/17/2025, 6:17 AMAI generated answer (using internal Slack threads):Based on the Slack conversations, it seems that reading a PDF and converting it into text, a JavaScript Object, or JSON within a SuiteScript routine is quite challenging. The complexity of PDFs makes it difficult to parse them directly in SuiteScript. One of the users mentioned the use of
pdf-parse
, a cross-platform library that can parse PDFs. However, it's important to note that this library is designed to work with Node.js, not SuiteScript. It internally uses pdf.js
, which is designed to work in the browser or on Node.js, and there's a chance it might work in SuiteScript. However, binary operations are barely workable in SuiteScript, and you would need to know how to use require Configuration
and how to shim in missing globals.
Another user suggested using an OCR (Optical Character Recognition) solution, as PDFs come in many varieties, including Excel/XML generated or scanned. There are many third-party solutions available that can perform OCR, and then the OCR results can be fed to the ERP. The choice of solution would depend on the number of templates (varieties), what varieties (computer generated or scanned), and the budget.
In SuiteScript 2.0/2.1, you can print a PDF on a suitelet using the writeFile
method on the response
object, as shown in the following code snippet:
javascript
context.response.writeFile({
file: myFileObj,
isInline: true
});
However, this does not parse the PDF content, it only allows you to write the file to the response.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
03/17/2025, 6:18 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849842787
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823866
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823738515
Celigo AI
03/17/2025, 6:18 AM