๋ฐ์ํ
๐กApps Script๋ฅผ ์ด์ฉํด ์ด๋ฏธ์ง๋ pdfํ์ผ์์ ํ ์คํธ๋ฅผ ์ถ์ถํด๋ณธ๋ค.
์๋๋ฐฉ์์ ์ด๋ฏธ์ง๋ pdf ํ์ผ์ Google Drive์ OCR ๋ ํํ์ ์์ ํ์ผ๋ก upload ํ๋ ๋ฐฉ์์ด๋ค.
Apps Script ์ข์ธก ๋ฉ๋ด์์
์๋น์ค์ [+] ๋ฒํผ์ ํด๋ฆญํด Drive ์๋น์ค๋ฅผ ์ฐพ์ ์ถ๊ฐํ๋ค.
PDF ํ์ผ ocr
์๋ณธ pdf
์คํฌ๋ฆฝํธ
function readTextFromFile() {
const url = "https://www.africau.edu/images/default/sample.pdf";
const contentBlob = UrlFetchApp.fetch(url).getBlob();
const resource = {
title : contentBlob.getName(),
mimeType : contentBlob.getContentType()
}
const options = {
ocr : true
}
const docFile = Drive.Files.insert(resource, contentBlob, options);
const doc = DocumentApp.openById(docFile.id);
const text = doc.getBody().getText();
Drive.Files.remove(docFile.id);
console.log(text);
}
๊ฒฐ๊ณผ
์ด๋ฏธ์ง ํ์ผ ocr
์๋ณธ ์ด๋ฏธ์ง
์คํฌ๋ฆฝํธ
function readTextFromFile() {
const url = "https://i.stack.imgur.com/i1Abv.png";
const contentBlob = UrlFetchApp.fetch(url).getBlob();
const resource = {
title : contentBlob.getName(),
mimeType : contentBlob.getContentType()
}
const options = {
ocr : true
}
const docFile = Drive.Files.insert(resource, contentBlob, options);
const doc = DocumentApp.openById(docFile.id);
const text = doc.getBody().getText();
Drive.Files.remove(docFile.id);
console.log(text);
}
๊ฒฐ๊ณผ
๋ฐ์ํ