Possible Bug

Questions and answers on how to use DOCXReadWrite
Post Reply
Vinski
Posts: 12
Joined: Thu Dec 16, 2021 7:41 am

Possible Bug

Post by Vinski »

Hello!

I think I might have found a bug.
If I add a new paragraph with
DOCX.Editor.AppendPara
and add no text to this paragraph, the program crashes, when it tries to get a preview going.
Saving the document to a file works just fine.

Example:
DOCX:=TDOCXReadWriteVcl.Create(Nil);
DOCX.Editor.Paras.AppendPara;
DOCX.SaveToFile('C:\Users\Praktikant\Desktop\test.docx');
TfrmPreview.Create(Self).Execute(DOCX.Editor);
DOCX.Free;

This code will save the file just fine, but crash, when trying to show a preview it crashes.
Adding
DOCX.Editor.Paras.Last.AppendPlainText('Example');
before the preview fixes the problem.
Is this intentional?
If so, why?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Possible Bug

Post by larsa »

Hello

It's intentional. Using AddPara can be more efficient when building documents as the paragraph content don't have to be plain text, it can be tables, tabs, pictures etc.
Lars Arvidsson, Axolot Data
Post Reply