User guide

DOKuStar Validation Programming Manual Page 23
The code for adding the second document is more or less the same as for the first one, so we skip explanations here.
Up to now, we added two documents, but still things are missing: The image window and the snippet window are
still empty, and we didn’t care about the table field yet. Let us now fill these gaps.
Adding Data Sources
Currently, data sources for documents are simply images. The term data source was chosen for future extensions (e-
docs etc.).
Concerning objects, there is a basic
DataSource object in DOKuStar Validation, and an ImageDataSource
object especially for images, which is a derivation from
DataSource.
All
DataSources, no matter to which document they belong, are always linked to the Dataset’s Data object.
To assign an image to a special document, you add a reference to this central collection.
This sounds more complicated than it really is. Let us add three images to our first document:
Dim doc As Document
Dim subdoc As Document
Dim imgDataSource As ImageDataSource
'*
'*** add a document
'*
Set doc = MyData.Documents.Add("Letter")
doc.Fields("Sender").Value = "Océ Document Technologies"
Set subdoc = doc.Documents.Add("CoveringLetter")
'* add a datasource (image) to the subdoc "CoveringLetter"
Set imgDataSource = MyData.DataSources.Add("dataset::ImageDataSource")
imgDataSource.FileName = App.Path & "\Source_1.tif"
subdoc.DataSources.Add imgDataSource
Set subdoc = doc.Documents.Add("Invoice")
subdoc.Fields("TotalAmount").Value = "100.00"
'* add two datasources (images) to the subdoc "Invoice"
Set imgDataSource = MyData.DataSources.Add("dataset::ImageDataSource")
imgDataSource.FileName = App.Path & "\Source_2.tif"
subdoc.DataSources.Add imgDataSource
Set imgDataSource = MyData.DataSources.Add("dataset::ImageDataSource")
imgDataSource.FileName = App.Path & "\Source_3.tif"
subdoc.DataSources.Add imgDataSource
'* add another document
Set doc = MyData.Documents.Add("Letter")
doc.Fields("Sender").Value = "Océ Document Technologies"
Set subdoc = doc.Documents.Add("CoveringLetter")
Set subdoc = doc.Documents.Add("Invoice")
subdoc.Fields("TotalAmount").Value = "200.00"
subdoc.Fields("InvoiceDate").Value = "2.2.2002"
Set subdoc = doc.Documents.Add("Voucher")
subdoc.Fields("VoucherDate").Value = "31.01.2003"
The Data object has got a DataSources collection, where all data sources reside. Use its Add method with
dataset::ImageDataSource as parameter, this will generate a new ImageDataSource object. Assign
the image file name to its
FileName property.
To link the images to individual documents, each document also has got a
DataSources collection. Its Add
method takes an existing
ImageDataSource object as a parameter. We link one image to the
CoveringLetter and two images to the Invoice, assuming that this is a two-sided invoice.