pdf - Google Doc OCR 阅读横向 PDF 颠倒
问题描述
目前正在尝试编写 PDF 提取器以从 PDF 中提取特定数据并输入到 Google 表格中。我可以使用下面的代码通过 gscript 将 PDF 文本提取到 Google Doc 中,但似乎因为 PDF 是横向的,所有文本都在反向转换?即 PDF 中 blob 的最后一行转换为 Google Docs 上的第一行文本。
任何人都知道是否有办法告诉谷歌方向或对其进行编码,以便在提取时将其固定在每个页面上?
function getTextFromPDF(fileID) {
var blob = DriveApp.getFileById(fileID).getBlob()
var resource = {
title: blob.getName(),
mimeType: blob.getContentType()
};
var options = {
ocr: true,
ocrLanguage: "en"
};
// Convert the pdf to a Google Doc with ocr.
var file = Drive.Files.insert(resource, blob, options);
// Get the texts from the newly created text.
var doc = DocumentApp.openById(file.id);
var text = doc.getBody().getText();
// Deleted the document once the text has been stored.
Drive.Files.remove(doc.getId());
return text;
}
解决方案
推荐阅读
- javascript - VSCode 不会忽略建议中的 node_modules
- django-import-export - 清理标题并删除粗体文本
- yii2 - yii2中用户名中的数字和字母组合
- fastify - fastify 为所有路由设置回复头
- php - jquery事件方法获取输入
- python - 如何计算关于输入的损失梯度?
- php - v-bind 表达式的值不能为空。在“v-bind:items”中找到
- sql - How to specify a hex character as part of a string in sqlite?
- javascript - 需要遍历一个数组并将每个值一次设置为 Javascript 中的一个类
- rust - 如何使用 salvo 将静态文件设置为 root?