Key issues when automating OyezForms
- Working with a test copy of OyezForms
- Launching OyezForms in dotnet
- Retrieving a list of available forms
- Mapping data to OyezForms fields
- Printing from OyezForms
- Exporting PDFs from OyezForms
Working with a test copy of OyezForms
You can develop with OyezForms by downloading the evaluation copy here. This unlicensed copy contains a selection of forms and is fully functioning apart from stamping 'SPECIMEN' on printed forms.
Launching OyezForms in dotnet
Applications automating OyezForms should use either the oyezfrms.tlb type library file or the OyezV8EZ.ocx control (for early binding), both of which are installed to the application directory. Dotnet programmers who wish to launch OyezForms from a non-form context should use InteropServices to access the .tlb (see example code).
Oyezforms has several dispatch interfaces providing automation, only the OyezAutomation interface should be used by other applications. Only one instance of OyezForms can be created. Only the currently active form can be manipulated. OyezForms does not support a collection of open forms.
Referencing the .OCX control (recommended)
- In a form's design view, right-click in the 'General' area of the Toolbox panel and select 'Choose Items...'
- In the 'Choose Toolbox Items' dialog, select the 'COM Components' tab
- Scroll down the list of components and put a tick next to 'OyezV8EZ', then click 'OK'.
- The ocx will appear on the Toolbar. Double-click on it to add it to your application's form.
- In the 'Solution Explorer' tree, a reference named 'AxOyezV8EZ1' will be created.
Referencing the .tlb file using InteropServices (if your project has no form object)
- Select 'Add reference' in your project.
- choose 'Browse', and select oyezfrms.tlb (installed to the application folder)
- using System.Runtime.InteropServices;
Type OyezAp = Type.GetTypeFromProgID("OyezLegalForms.Application");
OyezFrms.OyezAutomation oa = (OyezFrms.OyezAutomation)Activator.CreateInstance(OyezAp);
Retrieving a list of available forms
OyezForms stores data about its current library of forms in the <app folder>\library\master\mastlibr.mdb access database. The sub-folder path is fixed. You can retrieve the application path using the executablepath function.
You can query the database to retrieve the following fields from the LegalForms table:
<formname>
<Description>
<Revision> (YYYYMMDD)
<Copyright> (used to show last relevant EFIS release see www.oyezforms.co.uk/efis )
<CategoryID> (links to Category table, below)
<OyezID> (Oyez's stable ID, assigned to each form)
<path> (CategoryID-OyezID-alpanumeric representation of revision)
Multiple revisions will exist for most forms. Use the revision (integer) field to determine the most recent and display this. Descriptions may occasionally change across revisions. The Categories table lists Oyez's form range organisation. The <CategoryID> field links to the <Category> field in the LegalForms table .
- SELECT Categories.Category, Max(CStr([revision])+[formname]) AS form_title, Max(CStr([revision])+[description]) AS form_description FROM LegalForms INNER JOIN Categories ON LegalForms.CategoryID = Categories.CategoryID GROUP BY Categories.Category, LegalForms.OyezID
The above query is the simplest way of returning an up-to-date list of legal titles in the library. Your application output should ignore the first 8 characters of form_title and form_description.
Locks on the database should only ever be read-only. The table contents should never be changed.
Mapping data to OyezForms fields
Data from your application can be inputted into fields on any form after it is created by the new command.
When retrieving label or fieldID lists, you should first specify the page to be interrogated via the .selectpage command.
OyezForms supports descriptive fieldlabels that are stable across pages, form revisions, and within a range of forms. We strongly recommend using fieldlabels as your primary route for mapping data to OyezForms via the .fill command. A list of labels on the current page of a form can be retrieved programmatically via the .labellist command < .labellist().Split(',') >.
As fieldlabels were introduced during the lifetime of OyezForms, a number of less-frequently updated forms do not have fieldlabels. If creating a mapping interface for your users, you should ensure they also have the option to target OyezForms' numeric fieldIDs, using the .fillat command. A list of FieldIDs for the current page can be retrieved programmatically via the .fieldlist property. FieldIDs repeat across pages, and are not stable between form revisions; if extra fields are added to a page, the ID sequence will be reset.
You can find a field label associated with a fieldID by calling .getlabel using a fieldID as parameter.
OyezForms users can see where fieldlabels/fieldIDs appear on any form by selecting Tools>Options>PrintLabels/PrintIDs
Printing from OyezForms
The targetprint command allows you to print to a programmatically selected printer, tray and duplex option:
< .targetprint("HP LaserJet 1020", 2, 0) > uses tray 2 on the specified printer without duplex printing.
Targetprint prints all pages within a form. To control a range of pages in the printed output, use the print command:
< .print(4, axOyezV8EZ1.Pages); >
The above example prints page 4 through to the last page of the currently active form. When using the print command, OyezForms will auto-target a printer in the following order:
1. As set by OyezForms user in Tools>Options>Print:'Initial Printer'
2. The operating System's default printer
Exporting PDFs from OyezForms
The exporttopdf command allows you to save a form as a flattened PDF file. This export cannot be subsequently re-edited, so should be used as an archive, or as a 'for signature' option. The export process is not synchronous, so it may be desirable to check for the task to finish via Actioncomplete.
-
oa.exporttoPDF(@"c:\temp\out.pdf");
while (oa.ActionsComplete() != true)
{
System.Windows.Forms.Application.DoEvents();
}
The PDF export facility is based on novaPDF technology and is silently installed in standalone installs. This is also the case in the manual attachment of client PCs to a networked copy of OyezForms (see install help); however, if Active Directory is used with the \setup\setup_AD.msi file to roll out the attachment of client PCs, then the user will need to invoke File > 'Export to PDF' once in order to install the required components.
See also: Configuring OyezForms' PDF engine



