Understanding the CorelDRAW object model : Working with documents : Exporting files from documents |
Files of all supported formats can be exported.
• |
Files are exported at the Document level because the range of exported objects can extend over multiple
layers and multiple pages. However, files are imported at the Layer level because each imported object
is assigned to a specified layer on a specified page (see Importing files into layers).
|
The Document class has three file-export methods Export, ExportEx, and ExportBitmap all of which can export to the bitmap and vector formats.
• |
The wide selection of supported file formats is due to the vast number of filters that are available to the
application. Each filter lets you work with the files from another graphics application. To learn more
about working with these filters, see Working with import filters and export filters.
|
If you want, you can use event handlers to respond to events that are triggered by opening the Export dialog box:
• |
Application.DocumentBeforeExport
|
• |
Document.BeforeExport
|
• |
GlobalMacroStorage.DocumentBeforeExport
|
You can also use event handlers to respond to events that are triggered by exporting a document and closing the Export dialog box:
• |
Application.DocumentAfterExport
|
• |
Document.AfterExport
|
• |
GlobalMacroStorage.DocumentAfterExport
|
Finally, you can also use event handlers to respond to events that are triggered when the user responds to a request to export a document:
• |
Application.QueryDocumentExport
|
• |
Document.QueryExport
|
• |
GlobalMacroStorage.QueryDocumentExport
|
To export a page, you require only the Document.Export method, a filename, and a filter type. The following VBA code exports the current page to a TIFF bitmap file:
ActiveDocument.Export "C:\ThisPage.eps", cdrTIFF |
However, the preceding code gives little control over the output of the image. More control is obtained by including a StructExportOptions object, as in the following VBA code:
Dim expOpts As New StructExportOptions |
expOpts.ImageType = cdrCMYKColorImage |
expOpts.AntiAliasingType = cdrNormalAntiAliasing |
expOpts.ResolutionX = 72 |
expOpts.ResolutionY = 72 |
expOpts.SizeX = 210 |
expOpts.SizeY = 297 |
ActiveDocument.Export "C:\ThisPage.eps", cdrTIFF, cdrCurrentPage, expOpts |
• |
A StructPaletteOptions object can also be included in the function call for palette-based image formats,
if you want to provide the settings for automatically generating the palette.
|
The Document.ExportEx method is the same as the Document.Export method, except that ExportEx can retreive the dialog-box settings for a filter and apply those settings to the export:
Dim eFilt As ExportFilter |
Set eFilt = ActiveDocument.ExportEx("C:\ThisPage.eps", cdrEPS) |
If eFilt.HasDialog = True Then |
If eFilt.ShowDialog = True Then |
eFilt.Finish |
End If |
Else |
eFilt.Finish |
End If |
The Document.ExportBitmap method is similar to the Document.ExportEx method in that it returns an ExportFilter object that can be used to display the Export dialog box. However, the ExportBitmap method simplifies the coding by taking the individual members of the StructExportOptions object as parameters:
Dim eFilt As ExportFilter |
Set eFilt = ActiveDocument.ExportBitmap("C:\Selection.eps", _ |
cdrTIFF, cdrSelection, cdrCMYKColorImage, _ |
210, 297, 72, 72, cdrNormalAntiAliasing, _ |
False, True, False, cdrCompressionLZW) |
eFilt.Finish |
Copyright 2013 Corel Corporation. All rights reserved.