KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Saving 4D Write Pro documents to a text field
PRODUCT: 4D Write | VERSION: 15.1 | PLATFORM: Mac & Win
Published On: January 14, 2016

A 4D Write Pro document can be exported to a text variable using the WP EXPORT VARIABLE command as demonstrated in following code:

C_TEXT(exportedWriteDoc)
C_OBJECT(writeProArea)
WP EXPORT VARIABLE(writeProArea;exportedWriteDoc;wk web page html 4D)

The text variable exportedWriteDoc can then be saved to a text field in your database.

Then, at a later time, the exportedWriteDoc data can be loaded back into a 4D Write Pro area using the WP NEW command like this:
C_TEXT(exportedWriteDoc)
C_OBJECT(writeProArea)
writeProArea:=WP NEW(exportedWriteDoc)

The WP EXPORT DOCUMENT command also exists but is more suited for saving the document to disk because it wants a filepath for the blob, not a blob field. So it would take a few extra steps to get it into a field.