-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for Y coordinate with new version of pdfjs #47
Comments
Hey @MCMattia how did you run this in a browser environment? I'm trying to use Cloudflare Workers, and it's not working there. Could you please let me know how you ran this in a browser environment? |
Hi @sujjeee, I adapted the code of this repo. This is my version: ExtractorPdf.ts:
ExtractorTypes.ts:
|
@MCMattia Oh, okay, I see you are using pdfjs-dist. I also tried pdfjs-dist, but it feels slow to me in getting the Y-coordinate of a text. So basically, I was searching for the Y-coordinate of a given text from all pages of the PDF. Nowadays, everyone is talking about Cloudflare Workers, so I thought to use this in a serverless environment, but it's not working. |
Hey @MCMattia, I'm trying to use pdfjs-dist in my Next.js app. This is essentially a function: this is basically a function import * as pdfjsLib from "pdfjs-dist";
export async function crop(pdfBuffer: ArrayBuffer) {
const pdfDoc: PDFDocumentProxy = await pdfjsLib.getDocument(pdfBuffer).promise;
// other code
} I'm calling this function when a button is clicked, but before that, I'm getting this error:
Please let me know if you have any solutions to fix this issue. |
Hi @ffalt thank you a lot for this project. I have successfully been using your
extractBuffer
function in a browser environment.Working with pdfjs-dist V4.0.269 I noticed that the y coordinate is slightly wrong. If you consider upgrading pdfjs I had success calculating the y coordinate in the following way:
This would replace the block that you currently have here
I hope this will be of help
The text was updated successfully, but these errors were encountered: