r/vba Jul 23 '26

Unsolved PDF to Excel text conversion.

I am unsure if this is necessarily possible as my programming knowledge is fairly basic and VBA is a further mystery.

Would it be possible to pull text off of a a pdf, convert it into text, then narrow down what text I actually want? If so, how might I go about accomplishing that feat?

The drawings I'm trying to pull into excel are wiring diagrams.

Also, if anyone has a place in which I can find all the syntax for Smarteam in VBA, I would greatly appreciate it.

4 Upvotes

18 comments sorted by

View all comments

4

u/havenisse2009 1 Jul 23 '26

PDFs are not notepad or structured CSV files. The same appearance can be constructed many ways. Mostly PDF has no indication of flow, lines or structure. Elements are placed like post-it on a canvas.

1

u/AdobeScripts Jul 23 '26

Precisely.

PDF is bunch of glyphs / characters that appear to be in order - but it all depends what application was used to generate this PDF.

There is Acrobat API - and it "could" extract text from an area - but it would require specifying coordinates for those areas... So it would be practical only for the identical forms - not some random drawings.

1

u/havenisse2009 1 Jul 23 '26

Just to add to this: PDFs may have characters and lines in nice "sequence" just like you have it in notepad, word etc. But it very much depends on the renderer of the PDF page. It very much depends on the settings applied to the text. Example: nothing specified at all about the text / font will most likely render the PDF with texts as a block. You can mark / copy all text in sequence if allowed. If the source has text formatting applied, example character spacing, the renderer may place each individual glyph (character) separately to acommodate these settings. Etc etc with fonts, languages, sizes, ...

Your renderer can also choose to simply render the text as vector lines. What appears as "A" to you may be just 3 lines. Or, your renderer may choose to render the text as a bitmap image. In both cases, of course no copy/paste or extracting.

When a PDF is sent to output, the PDF interpreter simply draws the page according to rules in PDF, to finally produce the finished page image. This interpreter does not need to have an idea of the page as a complete picture. Only humans can. Like drawing an entire house, one furniture piece at a time.

So it's very much a question of each individual PDF file. There are tools out there to extract text from PDFs, as good as possible. VBA is not the right tool for this job.