Skip to content

Reading pdf in hebrew results in reversed text #2021

Open
@uriva

Description

@uriva

test3.pdf

I'm loading a pdf in hebrew, and getting reversed text from the pdf reader.

import { PDFReader } from "npm:@llamaindex/readers/pdf";

const pdfToDocument = (buffer: Uint8Array) =>
  new PDFReader().loadDataAsContent(buffer);

Deno.test("test chunking", { sanitizeResources: false }, async () => {
  const testDoc = Deno.readFileSync("test.pdf");
  const docs = await pdfToDocument(testDoc);
  console.log(docs.length, "chunks");
  for (const doc of docs) {
    console.log(doc.text);
    prompt();
    console.log("--------------------------------------------");
  }
  console.log(docs.map((doc) => doc.text).join("\n\n"));
});

example text output (each word is spelled as expected, but across words, the word order is reversed)

למיין להתחיל דרך שאין שנראה אינפורמציה במבול הופצצתם כנראה ליפן טיול מתכננים אתם אם.
,מוזיאונים ,שוליים תרבות ,יוקרה בוטיקי ,עילית קולינריה .טבע פנינות לצד אורבנית שוטטות .מהכל הכל מציעה טוקיו
איים וגם נהנתניים לילה חיי ,הימורים ,תמנונים עם סקס ,סקס ,מטורללת קניות חווית ,ומסורת מקדשים .ואומנות גלריות
הבאה המאה של 80ה בשנות תקועה ,ביחד והעבר העתיד היא .שקט של.
מכוונת יד רק צריך ,בטוקיו עצמו את למצוא יכול אחד כל.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions