#how to detect when a specific element appears in a PDF

8 messages · Page 1 of 1 (latest)

junior jungle
#

lets say you have a pdf file in this formathttps://papers.gceguide.com/A%20Levels/Physics%20(9702)/2023/9702_m23_qp_12.pdf

my main goal is to basically take each question, and end up with an individual image of each question. is this something feasible that i can do in my website? the main way i can check if a question starts/ends is by seeing if there is a bolded number to its left, but i have no idea how to do that.
i understand theres a lot of problems with this, such as the question spanning multiple pages and stuff, but so far i have no idea how to begin. i have no idea how to read the raw pdf data using the pdfJS library

candid tusk
dim solstice
#

I don't think you'd need AI training for this since the text is actually in the pdf's data and not just an image. The way I'd probably do it is by finding all the leftmost numbers that are in sequence (the question numbers on the side) and storing their positions. Then you can take a screenshot between all the positions. You might also have to figure out how to stitch multiple pages together.
You'd have to find libraries for reading the pdf and taking a screenshot.

However, this really only works for this particular format and for pdfs with text data and not just images of text (you should be able to highlight the text). If you want to put this on a website for the public you'd probably have to use AI for it to be mostly consistent, unless you provide a specific format for users to use.

#

sorry for the massive paragraph lol

junior jungle
dim solstice
#

Then it'd probably work without AI. Shouldn't be too horribly hard to code, just might take a while to get all the little quirks ironed out. Good luck!

junior jungle
#
    fetch('https://papers.gceguide.com/Cambridge%20IGCSE/Physics%20(0625)/2018/0625_w18_qp_22.pdf')
        .then(response => response.arrayBuffer())
        .then(arrayBuffer => {
            const reader = createReader(new PDFRStreamForBuffer(new Uint8Array(arrayBuffer)));

is the only progress ive made so far (muhammara.js)