MCPcopy Create free account
hub / github.com/devflowinc/trieve / getAllText

Method getAllText

pdf2md/server/static/viewer.mjs:7128–7151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7126 ac.abort();
7127 }
7128 async getAllText() {
7129 const texts = [];
7130 const buffer = [];
7131 for (let pageNum = 1, pagesCount = this.pdfDocument.numPages; pageNum <= pagesCount; ++pageNum) {
7132 if (this.#interruptCopyCondition) {
7133 return null;
7134 }
7135 buffer.length = 0;
7136 const page = await this.pdfDocument.getPage(pageNum);
7137 const {
7138 items
7139 } = await page.getTextContent();
7140 for (const item of items) {
7141 if (item.str) {
7142 buffer.push(item.str);
7143 }
7144 if (item.hasEOL) {
7145 buffer.push("\n");
7146 }
7147 }
7148 texts.push(removeNullCharacters(buffer.join("")));
7149 }
7150 return texts.join("\n");
7151 }
7152 #copyCallback(textLayerMode, event) {
7153 const selection = document.getSelection();
7154 const {

Callers 1

#copyCallbackMethod · 0.95

Calls 2

removeNullCharactersFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected