Previous Document Next Document

Understanding the CorelDRAW object model : Working with layers : Importing files into layers


Importing files into layers

Files of all supported formats can be imported.

 
Files are imported at the Layer level because each imported object is assigned to a specified layer on a specified page. However, files are exported at the Document level because the range of exported objects can extend over multiple layers and multiple pages (see Exporting files from documents).

The Layer class has two file-import methods: Import and ImportEx.

 
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.
Understanding the Layer.Import method

The Layer.Import method provides basic functionality for importing files.

The following VBA code imports the file C:\logotype.gif into the active layer at the center of the page:

ActiveLayer.Import "C:\logotype.gif"

Importing a file selects the contents of that file and deselects any other selected objects in the document. You can therefore reposition or resize the imported objects by getting the document selection:

ActiveDocument.Unit = cdrInch
ActiveSelection.SetSize 3, 2

Some file formats can be imported by using one of several filters, so it is important to understand the benefits of each available filter. For example, when importing an Encapsulated PostScript (EPS) file, you can choose between the EPS filter and the PDF filter. The EPS filter lets you do the following:

 
import an EPS file as a placeable object that can be printed but not modified
 
interpret the PostScript portion of the file, so that you can import the original artwork from within the file rather than its low-resolution header

To specify which filter to use, you can include the optional parameter Filter, as in the following VBA example:

ActiveLayer.Import "C:\map.eps", cdrPSInterpreted
Understanding the Layer.ImportEx method

The Layer.ImportEx method provides much better control over the import filter through its optional use of a StructImportOptions object. The following VBA code imports the specified file as a linked file:

Dim iFilt As ImportFilter
Dim importProps As New StructImportOptions
importProps.LinkBitmapExternally = True
Set iFilt = ActiveLayer.ImportEx("C:\world-map.epsf", cdrAutoSense, importProps)
iFilt.Finish

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.