Random Ramblings on LabVIEW Design

Community Browser
Labels
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Open Document Text Document

swatts
Active Participant

What-ho Wire Wrestlers.

I had two other options for this article

  1. A discussion about the poor sods who get thrown onto complex projects undercooked and what can be done to educate project managers about the value of employing experience. I've witnessed this a few times this year.
  2. Open up the design of the API for the ODS tool. It's working rather nicely in my application, but I know it's not sorted yet.

Or alternatively I could leave the ODS API half-cooked and I'm not in the mood to grizzle. So instead I'm going to talk about ODTs

ODTs are the output of Open Document Word Processors, including newer versions of Microsoft Word, Open-Office Writer and LibreOffice Writer.

Before I plough in and do the hard work I thought it might be good to request some input from other users.

Here's one use-case that would be marvellous for me.

IssueReport.png

Here I have my bug reporting tool, when I press commit I would like it to generate an issue report document, with all the details filled in for me. This would be way better than my current "Issue Saved" dialog confirmation.

Using a similar model to the one I employed for the spreadsheet I could load a template and update it.

Luckily both Word and Openoffice offer bookmarking facilities. We could organise our template with various bookmarks and then offer methods to insert things at the book mark point. In ODS I have fathomed tables, Images are just links and the images go into a directory called ..\Configurations2\images\Bitmaps, text is a direct replacement.

Main page data goes in content.xml

Header and Footer info goes into styles.xml so I would need to search that for bookmarks too.

The bookmark tags come in two flavours.

<text:bookmark text:name="headerbookmark"/> <--- this is just a single place point and your insertion goes either at the end or the beginning of this tag.

<text:bookmark-start text:name="my2ndbookmark"/>ddd<text:bookmark-end text:name="my2ndbookmark"/> <--- this is a range of text that should be replaced by whatever is inserted.

The only additional facility that I can think that will be useful is the ability to duplicate pages.

Here's the updated (version D1:01) example program screen

ODFExampleScreen.jpg

This demonstrates both ODS and ODT generation.

Here's another instance where I could use this type of functionality.

Document.png

I generate a new document number for a project using this little utility, it would be splendid if it actually generated the document all numbered and dated.

Is there any other use-cases that would be handy?

Leave words of wisdom in the comments please.

Much Love

Steve

04-May-2016 added ODF toolkit, this purely replaces/insert text into a template and saves the template, as a bonus there's a bit that then converts the ODT file to a PDF if you have LibreOffice (probably works with OpenOffice too). Created file works with Word too. Questions and use cases into the comments please. ODTExample.vi shows usage. Video to follow...

06-May-2016 Made the text entered XML safe (as far as I know) for ODS and ODT

19-05-2016 D1:01 added version numbering and prettied up the example, tested with provided templates and works OK. Used LibreOffice 5 for the pdf printing

08-06-2016 D1:02 ODTGetBookmarks removed table of contents "RefHeadings" bookmarks LV2014

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile

Comments
Ian_Billingsley
Member

Hi Steve,

This is great and im really interested to see where this goes.

We have been using the vi attached without too much pain with a teststand solution we have recently put together.

The customer basically requires a PDF report to be produced at the end of each test.

They had an existing MSword based report that they were using and due to the difficulties in getting changes authorised by their aerospace customer they wanted the report to look exactly the same.

So we created a template from it and populated it with bookmarks which we insert values to at runtime.

Then we destroy the temporary word document once the PDF is generated.

The only slight issue we seem to have with this is the time it takes to execute particularly in the LabVIEW runtime environment.  It takes over 10seconds and seems to completely hang the system during this time.  Have you seem any similar issues?

Array to Word Template FP.JPGArray to Word Template BD.JPG

Billican
swatts
Active Participant

Looking at the Word specific Report Gen stuff it calls an activeX reference, I'm guessing this will be loading some part of Word (if not all of it) to generate the document. Anti-virus hates programs calling programs and it pretty much always results in quarantining of files and active scanning. This may be the cause of your hanging issues.

My solution is to create the file and doesn't need a Word processor program at any point to create documents. Essentially the method will be similar to the ODS stuff where I unzip the .odt file, stream the styles.xml and content.xml and search and replace at the bookmark points before rebuilding the file.

With ODS it works fairly seamlessly, less than 1sec.

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile

Ian_Billingsley
Member

Steve,

You are absolutely right on all accounts.

I would be very interested to see how we can replace what we have with an ODS solution.

Cheers

Billican
swatts
Active Participant

I reckon I could get it working with a couple of days hard graft, and then spend a few weeks tarting it up.

From and API point of view I suspect I should be looking at the existing report gen toolkit for guidance. Although I will be always relying on templates as a matter of course (unless I embed one in the code), that's a change in philosophy..Oh Design I love you you gray temptress you!

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile

justACS
Active Participant

swatts wrote:


                       

I reckon I could get it working with a couple of days hard graft, and then spend a few weeks tarting it up.

I love it when you do crime!

swatts
Active Participant

283574_1 (1).jpg

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile

swatts
Active Participant

Progress Report: Got it reading bookmarks and saving. Working on replacing text at a bookmark, should be done by the end of the week. When I'm happy with that I'll attempt images and tables.

TADA!!!

converttoPDF.jpg

This example inserts issue numbers into our issue report template and saves as a new file, as a bonus I use Libreoffice to convert the resulting document to a pdf.

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile

swatts
Active Participant

I've just found out that there are special characters and if your text includes them it will cause issues.

For <, >, &, " and ' we will need to replace them with &lt;, &gt;, &amp;, &quot; and &apos; respectively. I think some low level control characters also need policing.

Expect an update this weekend.

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile

Terry_ALE
Active Participant

Interesting! We tried to interface with the open office spreadsheet tool and ended up switching but this is a great reference.

I would really like to hear about the poor sods, been hearing more of those stories this year.


Certified LabVIEW Architect, Certified Professional Instructor
ALE Consultants

Introduction to LabVIEW FPGA for RF, Radar, and Electronic Warfare Applications
swatts
Active Participant

Hi Terry,

The difference here is that I'm directly creating the files, so you don't need an API to hook into or any other software loaded. This all feeds into my requirement to have few dependencies in my code, I want to load it from my repo, on any machine and it to just run (ideally!)

I think you've just pushed my next article forward, I think I'll draw together all of my feelings and grumblings from other articles together in one rant!

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile