Open Menu

Synergex Blog


To Print or not To Print

By Richard Morris, Posted on February 12, 2010 at 10:10 pm

The Synergy Windows Printing API is a collection of routines that allow you to fully control printing on the Windows platform, and make use of extended printer features.  The API records the print information in a Windows enhanced metafile which can then be played back to devices such as a printer or the print preview window.

Many of you will be using this API to bring true Windows printing capabilities to you applications. So, when you upgraded to version 9.3 of Synergy and rebuilt your applications, where did your prints disappear to?  You may have been caught out by a new feature added to the API.  In version 9.3 two new integer fields were introduced to the font specifications structure to enable you to change the orientation and escapement of the font.  The orientation allows you to specify the angle between the baseline of a character and the page’s horizontal axis.  The escapement specifies the angle between the baseline of a string of text and the page’s horizontal axis.  For full details see the version 9.3 on-line manuals.  The default value for both of these two new fields is zero, meaning that no rotation of the text will occur.

To set the required font characteristics you use the DWP_FONT sub-function of the WPR_SETDEVICE() function.  The font characteristics are defined within a structure called “font_specs”, included in the DBLDIR:winprint.def header file.  This structure is used to allocate memory to store the font specifications, and provide them to the %WPR_SETDEVICE() function.  You allocate the required memory using the %MEM_PROC() function, for example;

    fontHandle = %mem_proc(DM_ALLOC+DM_STATIC, ^size(font_specs))

You can then set the required font details;

    ^m(font_specs.face_name, fontHandle) = “Courier”

However, if you don’t specify values for all of the fields defined within the “font_specs” structure, the values will be undefined, and for the integer fields, most likely be non-zero.  So, the two new fields will actually contain values, and so orientation and escapement settings will be passed to the %WPR_SETDEVICE() function.  Things will no longer print as you expect!

One way to ensure that the integer data is initialised when you allocate dynamic memory is to use the DM_NULL qualifier.  This ensures that any integer data is initialised correctly.  For example;

    fontHandle = %mem_proc(DM_ALLOC+DM_STATIC+DM_NULL, ^size(font_specs))

However, this does not correctly initialise any non-integer data, and is not future-proof.  If the structure is modified to include new alpha/decimal/implied decimal fields in the future, these fields would then contain incorrect values.  An alternative is to initialise a local copy of the font specifications structure and then assign that to the allocated dynamic memory.  The INIT statement ensures that fields within a record or structure are initialised correctly based on the field type.  Firstly, create a structfield, which is a field defined as a structure type.

.ifdef DBLV9

record

    tmpFont    ,font_specs

endrecord

.endc

The code to allocate the memory for the font specification remains the same;

    fontHandle = %mem_proc(DM_ALLOC+DM_STATIC+DM_NULL, ^size(font_specs))

Now we use the structfield to correctly initialise the dynamic memory;

.ifdev DBLV9

init tmpFont    ;ensures individual fields correctly initialised

^m(font_specs, fontHandle) = tmpFont

.endc

This same coding structure can be applied to the other structure specifications defined in the DBLDIR:winprint.def header file.  The code is backward compatible with earlier versions of Synergy, and will prevent any similar issues in the future.

Alternatively, from version 9.1 you can remove the need to allocate memory, and simply use the structfield.  For example;

record

    textFont    ,font_specs

endrecord

And then use the structfield to define font characteristics;

    init textFont    ;ensures individual fields are correctly initialised

    textFont.facename = “Courier”

    textFont.weight = 700

    wpr_setdevice(rptHandle, DWP_FONT, textFont)

    wpr_pint(rptHandle, DWP_WRITEOUT, x, y, “Hello Bloggers!”)

This second approach has two advantages.  Firstly, you no longer need to allocate and clean up any dynamic memory.  The second is that you get full intellisense within workbench, listing the available fields within the font structfield.


Picture This!

By Richard Morris, Posted on January 28, 2010 at 11:29 pm

In days of old, carrying your trusted, heavy weight camera around your neck, you’d take the perfect snap.  You’d then continue snapping away until the film was full, which, for the impatient among us, meant taking a large number of “I was just finishing off the film darling” type shots. On returning home you’d quickly rewind the film back into its cartridge, unless you had one of those fancy modern “advanced” film cameras of course, where the camera did it for you, and then pop it into your “postage free” envelope.  And off you sent it, in the hope that your “once in a life time” shot would be processed and returned to you post haste.

And what of the results?  Normally a hazy, slightly out of focus, batch of glossy pictures that really don’t give your artistic prowess justice.  After all, the subject must have moved because you’d never intentionally crop the top of the head of the bride, just above the eye line, and why was the gentleman third from the right picking his nose?

If this sounds like your photography experiences, the chances are if you live in the UK the people processing your film were a company called Harrier L L C.  You may know them better as “TRUPRINT”.  At their peak they were processing 85,000 rolls of film per day!  Today, however, they are processing no more than 1,000 films.  Not really a great statistic if film processing is your business.  But Harrier saw the potential of the digital world and has embraced the processing of the digital image.  Today they average over 200,000 prints a day, which can rise to over 1,000,000 prints at times like Christmas.  However, although this figure is significantly lower than the prints they were processing in the heyday of film, it’s now a very small part of their product portfolio.  The key to success was to diversify.  Today, in this digital age, people want more than just a glossy print of their blurred, half-cropped pictures.  They want the t-shirt, a coffee mug and of course the family calendar, all donned with their own artistic compositions.  Today, with a few clicks of a mouse you can upload your pictures and have them delivered to your door on anything from coffee mugs, placemats to a full size framed canvases.  You can even have your prized picture delivered to you in lots of tiny pieces – in the form of a jigsaw!

So where does Synergy fit into their IT strategy?  Their OpenVMS based Synergy /DE applications manage the order processing and management of every item they process.  Once an order is accepted through the many portals including a host of web sites, major supermarket chains, leading pharmacies, and of course by post, the Synergy application takes control.  It manages the processing or the required prints, storybooks or mugs (to name but a few product lines – they have over 500) through to despatch and successful delivery to the customer.  The Synergex Professional Services Group is assisting Harrier to evaluate to work needed to migrate their Synergy/DE applications from the OpenVMS platform to Microsoft Windows.


Don't miss a post!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Recent Posts Tag Cloud Archives