Recent

Author Topic: Issue with fpvectorial and Onedrive  (Read 2484 times)

LittleBritaly

  • New Member
  • *
  • Posts: 24
Issue with fpvectorial and Onedrive
« on: March 25, 2019, 07:26:00 pm »
I'm using Lazarus on a mac.

I'm pulling information from a database and placing it into a .docx file then saving the .docx on OneDrive locally, I'm using fpvectorial to do this.

The .docx will then be shared with customers.

Shortly after, the file shows up in Onedrive online (so in my web browser), but when I try and open it in Word Online, I'm told "Sorry, this document can't be opened for editing".

If I open the file locally in Libreoffice, then save it (even without making any changes), I can then open it for editing in Word online.

The permissions of the file don't change after saving in Libreoffice, but the file size changes significantly (from 8294 to 13597).

Does anyone have any idea what the issue could be ?


Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: Issue with fpvectorial and Onedrive
« Reply #1 on: March 26, 2019, 03:18:33 pm »
G'day,

The change in file size doesn't surprise me - I focused on readability in the XML files (indents, line break, full labels etc) over space-optimisation.

Bit annoyed it doesn't open in Word Online though, I checked as many versions of Word as I had available at the time, and I was referencing the open office specs.  This was in the days before Word Online.

Hopefully it's just a simple bug in the exporter, and not a compatibility issue with Word Online.  Any chance you can flick me through a copy of a word document that breaks in Word Online?  (The original version, not the version saved by Word).  I'll have a look.

Can't promise a quick turnaround.  I work offshore - where I work 12 hours a day/7 days a week.  We're currently in the middle of a project.  Things get quieter for me in around 2 weeks.

Cheers

Mike
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

LittleBritaly

  • New Member
  • *
  • Posts: 24
Re: Issue with fpvectorial and Onedrive
« Reply #2 on: March 26, 2019, 08:23:49 pm »
Hi Mike,

Thank you for the reply and offer of help, but I've figured it out after many hours of testing and comparing a file that opens with word online and one that doesn't.

Basically, I unzipped the .docx into a separate directory, deleted different .xml files in the "word" directory until I finally figured out that the string "xml:space="preserve" was the cause of all my problems, by deleting that string and recompressing back to a .docx worked.

I read up a little on what "xml:space="preserve" was for, here's a link for anyone interested :- http://www.xmlplease.com/xml/xmlspace/

The I changed the string to "xml:space="default" and recompressed, again this worked.

I then edited the docxvectorialwriter.pas file and changed every occurrence of xml:space="preserve" to xml:space="default (I think there were three), opened the fpvectorialpkg.lpk (in /Developer/lazarus/components/fpvectorial on my system), recompiled, ran a small test program and the resulting .docx opened in Word online.

I still have testing to do, but it does seem to work.

Sorry for the long winded reply, but I wanted to explain what was happening and the fix.




Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: Issue with fpvectorial and Onedrive
« Reply #3 on: March 27, 2019, 05:31:05 am »
Absolutely awesome work :-)

When you're happy with your testing, could you upload a patch to Mantis?  Alternatively, flick me the updated file and I'll create a patch acknowledging you as author?

Many thanks, and well done

Mike
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

LittleBritaly

  • New Member
  • *
  • Posts: 24
Re: Issue with fpvectorial and Onedrive
« Reply #4 on: March 27, 2019, 07:18:37 am »
Thank you, it was a pain to find.

Could you pm me your email address, I'll then send you the file.

I'm going to try a week of testing.

 

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Issue with fpvectorial and Onedrive
« Reply #5 on: March 27, 2019, 10:01:05 am »
Are all three occurances of "xml:space=preserve" detrimental?

Looking at the one in line 1045 belonging to the opening x:document node - it seems to be obsolete since an original Word2016 document does not contain it.

The one associated with fields (e.g. author name) in line 646, however, is written by Word2016 as well - so I think it should be kept.

I can't say anything on the third one in line 762 since I did not find a way so far to convince my Word to write such a node to the xml.

I would appreciate if you would could find out which occurances can be kept.

dsiders

  • Hero Member
  • *****
  • Posts: 1052
Re: Issue with fpvectorial and Onedrive
« Reply #6 on: March 27, 2019, 10:10:08 am »
Are all three occurances of "xml:space=preserve" detrimental?

Looking at the one in line 1045 belonging to the opening x:document node - it seems to be obsolete since an original Word2016 document does not contain it.

The one associated with fields (e.g. author name) in line 646, however, is written by Word2016 as well - so I think it should be kept.

I can't say anything on the third one in line 762 since I did not find a way so far to convince my Word to write such a node to the xml.

I would appreciate if you would could find out which occurances can be kept.

Not detrimental, unless the code doesn't know how to handle it. It just means whitespace only text nodes should be retained. If that causes a problem, it's bad code. Not bad data.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Issue with fpvectorial and Onedrive
« Reply #7 on: March 27, 2019, 10:47:13 am »
Now I registered to Word Online and opened the test file written by the fpvectorial demo fpvtextwritetext (after adding a line to save in .docx format) by Word Online without any issues although the lines with "xml:space=preserve" were not removed from the docxvectorialwriter unit. The issue must be something else in general or something in your particular document. Can you share a document which shows these issues? (Rename its extension to .zip to be accepted by the forum software, it's a zip anyway).

 

TinyPortal © 2005-2018