Export 4D Write Pro documents to SVG format

Automatically translated from English

4D Write Pro documents can be exported into different formats: PDF, Plain text, Microsoft Word, 4D Write Pro, HTML… To this list is now added the SVG format!

SVG is an image format. Thanks to that, you will be able to create previews of any page, integrate them in your interface, visualize them in browsers, on mobile devices, etc.

Export SVG

SVG format is vectorial. As a result, exported files are generally small. They can be manipulated without loss, and more easily than any other bitmap image format, compressed or not (jpg, png, tiff, etc.).

SVG being an image format, you will have the possibility to choose which page of your document you want to export. The final image will be based on the page rendering of your document. It will take into account all the layout options such as orientation, margins, etc.

Pictures inSIDe pictures

4D Write Pro documents can themselves contain images of any type. How will they be processed?
You will have the choice at the time of export! These images can be integrated (encoded in base64) inside a single SVG file or exported, in their native format, in a separate folder. In this second case, they will be referenced in the SVG file, which will be, in the end, much less heavy.

The choice of one mode or the other will depend mainly on how you intend to use the SVG image. In some cases, you will prefer to have a standalone (but larger) file, and sometimes, you will prefer a lighter document with dependencies.

Fonts

The SVG format does not allow to embed fonts. Only their names are mentioned. There will be no rendering problem if the SVG image is read on the platform that generated it. On the other hand, the final rendering will not be guaranteed if opened on a different machine. To overcome this problem, it is possible to add a tag allowing the use of Google Fonts if one or more fonts are missing. This tag is mainly taken into account by internet browsers, but also by the web areas of 4D!

More options

As for PDF export, you will also have the possibility to define whether all the elements will be exported or not. For example, you can decide to hide headers, footers, background images, etc.

File or variable

Two separate commands allow two types of exports:
To export to a file, use the WP Export document command. If you prefer to export to a variable (which will be of type Text), use the WP Export variable command.

The only difference in the options is that the document’s images will be mandatorily embedded in the exported SVG when using WP Export variable.

Code sample

$options:=New object
// these options are new!
$options
[wk page index]:=1
$options[wk embedded pictures]:=true
$options[wk import Google fonts]:=False
// these options can also be used!
$options[wk visible background]:=True
$options[wk visible headers]:=True
$options[wk visible footers]:=True
$options[wk recompute formulas]:=True
$options[wk optimized for]:=wk print
$options[wk max picture DPI]:=300

WP EXPORT DOCUMENT(WPsample; "WPsample.svg"; wk SVG; $options)
// OR
WP EXPORT VARIABLE(WPsample; $text; wk SVG; $options)

 

Interface

The interface provided has, of course, been modified to take into account this new type of export.

The export menu now includes an export to SVG item…

…and a dialog allows you to precisely define the desired options:

Conclusion

An additional format is available for exporting documents! We are sure you will appreciate this feature as it was requested by many of you to improve the interface, create previews, etc.
All the necessary information is in the documentation. Enjoy the reading!

 

 

 

Roland Lannuzel

• Product Owner & 4D Expert •

After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.

Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.