Saving Documents with Graphics

General TRichView support forum. Please post your questions here
Post Reply
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

Saving Documents with Graphics

Post by dc3_dcfl »

Sorry if this has been asked before. I am just starting to use RV.

To start with, I am using Delphi 2006, with ZEOS connecting to MySQL 5.1.

I have been tasked to import word documents into my db. I am (for now) doing a copy/paste from an RTF file (I load the doc in word and save as RTF). I have no problems saving the doc unless there are graphics in the document. Rarely, the doc saves with no problem, but other times, I get a db error, database has gone away.

When I don't get the error, the graphics show up fine, when I get the error, I need to reconnect to the database, delete the record I was working, insert a new one, and copy/paste without the graphics, and attempt to save again.

Any idea why I get the error?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Does it happen on some specific documents?

RTF file may contain graphics which will be imported in TMetafile, TBitmap, TJPEGImage, and png.
To provide a correct processing of PNG, you need to use a thirdparty class (TPngObject), and register it using RV_RegisterPngGraphic and RegisterClass. If you will not call RegisterClass, saved RichView documents will not be read (if you save them as RVF)
See: http://www.trichview.com/forums/viewtopic.php?t=89

In addition, RTF files may contain references to external images in any format.
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

Graphic Images

Post by dc3_dcfl »

How can I figure out if the graphic embedded in the document is .PNG?

I don't think they are png files. They are mostly screen captures then inserted into the word doc directly (probably not even saved as a file between capture and insertion into the doc)
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Normally, MS Word saves raster images (like screenshot) in an RTF file twice: as PNG and as a metafile.
If you call RV_RegisterPngGraphic, TRichView will read them as PNG.
Otherwise it will load them as TMetafile or as TBitmap (if it will be able to extract bitmap from a metafile).
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

Post by dc3_dcfl »

I followed the direction of the link you provided, and it looks like it may have done the trick.

Thanks for the quick response.
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

Post by dc3_dcfl »

Unfortunately, I now have another issue.

I have another unit which copies several of the RVF formatted docs together. This works without problem. I then have:

if Savedialog1.execute then
RichvieEdit1.SaveRTF(Savedialog1.filename, False)

On the SaveRTF function I get a Class EListError with message "List index out of bounds (6)

Before I added graphics to the docs, this code worked fine. Now with images in the docs, I added the PNGImages to this unit but get the EListError.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please send me a simple project to reproduce this problem.
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

Post by dc3_dcfl »

I think I know what may be causing this error. The remnants of the rtf file created stops just before the beginning of a table in the doc. The table is beyond the right margin of the doc. (I used the openaction function to import rather than cut and paste)

Now the issue is that I cannot move the table within the margins. Placing the cursor over the edge of the table changes the cursor, implying that I will be able to move the edge, but unfortunately, it doesn't actually move anything.

How do I reset the table to be within the margins?

Thanks again in advance.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

No, there should be another reason. Table or documents outside margins should not cause any problems.
More in a private message.
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

May have found the graphic issue

Post by dc3_dcfl »

Sergey,

I ultimately had yet another occurrence of the db giving me an error on trying to save a doc with graphics. I began to think the problem isn't an issue for the RichViewEdit because I attempted to save the doc as a file and I had no problems.

So I began to research BLOB field with MySQL and with my connection to the DB with ZEOS. I think the problem is due to a setting with MySQL.

You may want to make this information available for anyone using MYSQL.

here is the relevant link with MySQL to change the max_allowed_packet variable.

http://dev.mysql.com/doc/refman/5.1/en/ ... large.html

Once again, thanks for your quick replies.
Post Reply