Given a document, is there a way to parse through it and determine if it contains tables or images?
Might be a easy question, but just need a general direction to head towards.
Thanks!
[Solved] Check if a document contains tables or images
[Solved] Check if a document contains tables or images
Last edited by elu on Sun Aug 05, 2018 8:31 am, edited 1 time in total.
OpenOffice 4.1.5 on MacOS 10.13
Re: Check if a document contains tables or images
Getting a count of tables is easy. It is also easy to get a count of objects on the "DrawPage" of the document. These could be images or shapes, or, I suppose, other non-text content.
Code: Select all
oTables = ThisComponent.TextTables
print "Tables: ", oTables.Count
oDP = ThisComponent.DrawPage
print "Drawpage objects: ", oDP.Count
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Check if a document contains tables or images
Also objects inserted as TextContent, OLE objects and TextFrames e.g. in addition to graphical Shapes are mostly gathered to the DrawPage. The only exceptions I know of are Paragraphs and TextTables.
Please point me to additional exceptions.
Please point me to additional exceptions.
Last edited by Lupp on Sat Aug 04, 2018 12:07 pm, edited 1 time in total.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Check if a document contains tables or images
If I remember correctly (no time to look it up) Andrew Pitonyak gives such a document analysis macro in his book.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
-
- Posts: 145
- Joined: Mon Jun 13, 2016 10:50 am
Re: Check if a document contains tables or images
Hello,
There is a dedicated method for images: getGraphicObjects.
There is a dedicated method for images: getGraphicObjects.
Code: Select all
oImages = ThisComponent.GraphicObjects
print "Images: ", oImages.Count
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems