For days, I've tried to add an image to programmatically created Libre Office (v7.4) Writer Document using VB.net (using Visual Studio 2022) with no success. The LibreOffice SDK I'm using was downloaded using NuGet. None of the instructions or examples I've found work for me. Can anyone share a listing on how to do this, specifically to insert a JPG into a cell in a table and dock it there, or alternately size it and center it in the cell.
I have studied the Libre Office site, the Open Office site and other good instructional sites/documents including Andrew D. Pitonyak's "Open Office Macros Explained." Of course I've also Googled everywhere to find instructions and/or examples, and have found many, but none are specifically use VB.Net. I'm familiar, but not fluent in the other languages in which the examples have been provided, so I've used several different conversion tools to generate VB.Net code. I've had good success using these tools in numerous other efforts, but not here.
The best source has been Libre Office's own (very good) "WriterDemo," written specifically in VB.Net. This demo worked straight away for me and I've attempted to build on it and its methodologies for building components, objects and interfaces for writing text, building and filling tables, building and filling text frames etc. But even this hasn't gotten me to the promised land (embedding jpg images). Finally, since I've tried so many variations on the use of Graphics Objects to do this, providing a listing of what is not working would likely lead to 'go-backs' about whatever non-working code I might provide. Instead I'll simply ask (and hope) for a working listing. Help!
A strong thumbs up to user246821. But I cannot declare this as a fully answered question....
I was able to use the Open XML SDK 2.5 Productivity Tool to generate (a lot) of VB.Net code in conjunction with a LibreOffice Writer Document. Unfortunately the tool only allows you to decompose an MS Word Document. So the process I had to use was the following:
It is definitely a circular path to do this and it didn't avoid using MS Word as I desired. But worse, modifying the Writer Document to MS Word did not preserve the table names I'd assigned to each of the tables. So my hopes of easily manipulating the VB.Net code (actually finding references to individual tables) was derailed. This of course too was not insurmountable, but with things stacking up against use this as an easy solution I gave up on this approach.
But if the VB.Net code had a small number of LOC, I might have continued on this path, but as I said, this created a ton of code for a relatively small document. I ended up with almost 30K LOC for a document that contained a total of 4 empty tables. While much of the code was generated to specify 'style' properties, it was difficult to wade through. But overall this did not bode well for using this methodology to generate code to either generate LibreOffice Documents from scratch or even call up and modify templates of files.
All that said, the XML SDK 2.5 Productivity Tool is very impressive and something to consider if you want to build or modify MS Word Documents. Take Note: it is still available but MS declares it to be deprecated.
But I'm still looking for code to add and image to a Libre Office Writer Document using VB.Net. Anyone?