Sharper Report Pictures with MetafileToPng

<< Click to Display Table of Contents >>

Navigation:  Reference Section > Reports >

Sharper Report Pictures with MetafileToPng

Part schematics, magnet plans, nest maps and remnant maps reach a report as metafiles. The MetafileToPng report function turns one of these into a PNG image while the report runs. The template chooses the size of the image in pixels and how thick each kind of line is, so the look of a report can be changed without a PrimeCut update.

It is used from the Calc tab of the Report Designer, in the OnGetPicture event of a DBImage.

Using the function

procedure DBImage1OnGetPicture(aPicture: TPicture);

begin

 MetafileToPng(plPart.FieldObjects['DimensionedMetafile'].AsPicture, aPicture,

 900, 600, 'Outline=1.5;Dimension=0.5;Grid=0.25');

end;

Parameter

Meaning

aSource

The picture to convert. Read it from the pipeline field, as in the example: once a DBImage has an OnGetPicture event it no longer loads its own data field, so aPicture arrives empty.

aTarget

Where the PNG goes, normally the aPicture parameter of OnGetPicture.

aWidthPx, aHeightPx

The box the PNG must fit in, in pixels. The picture keeps its shape. Pass 0 for one of them to have it worked out from the other.

aOptions

Settings as key=value pairs separated by ; - see below. Use a full stop for decimals. Leave it empty ('') to accept every default.

The pixel size sets how sharp the picture is; the size of the DBImage on the page sets how big it prints. For example, a 150 mm wide DBImage printed at 300 dpi needs about 1770 pixels across (150 ÷ 25.4 × 300).

Line thickness

All widths are in pixels of the PNG and can be fractions, such as 0.75. A width looks the same on every part, whatever the part's size. A line that no key covers keeps the thickness PrimeCut draws it with.

Key

Lines it controls

Outline

Part outlines, outer and inner

OpenPath

Open paths in part schematics; enabled magnets in magnet plans

Dimension

Dimensions and annotation lines; processed paths and lead-ins in part and magnet plans

Grid

The part grid and multibox and multicut copies

Grain

The grain direction mark

Parts

Nest maps: the other parts on the plate. Magnet plans: disabled magnets

Multibox

Nest maps: dashed multibox boxes

Plate

Nest maps and remnant maps: the plate outline and remnants

Toolpath

Nest maps: the toolpath

Highlight

Nest maps: the highlighted work order part

Crop

Nest maps: crop lines

Other settings

Key

Meaning

Default

LineScale

Multiplies the thickness of any line that no key above covers

1

MinWidth

The thinnest a line can be, so nothing disappears on a small picture. Also sets the size of single points

0.5

Transparent

1 makes the white background transparent

0

PdfLossless

1 keeps the picture at full resolution in PDF exports (see below); 0 lets the report's own PDF settings apply

1

Supersample

Smoothness, a whole number from 1 to 4. Higher is smoother and uses more memory

4

Widths, LineScale and MinWidth must be between 0 and 64. A mistake stops the report with a message saying what is wrong - an unknown key lists all the valid keys.

PDF export

PDF export normally shrinks images to 96 dpi and saves them as JPEG. Pictures made by MetafileToPng are exempt: they go into the PDF at full resolution with no loss, whatever the report's PDF settings. Every other image in the report still follows those settings.

This can be turned off for one picture with PdfLossless=0, or for the whole datastore by clearing Full quality PDF pictures from MetafileToPng under Database Settings, Emailed Quotes, Report Generation. Full resolution pictures make larger PDF files, so a report with many part pictures may be worth a smaller pixel size.

Black and white metafiles (with coloured metafiles turned off in the user settings) keep their line thicknesses too.

NOTES:
* Requires PrimeCut NE 4.136.25 or later.
* Outer and inner part outlines always share one thickness, as do lead-ins and processed paths.
* Stroke-font annotation text on a part, such as HOLES: 2 x 25.40 mm, is drawn with the outline pen, so Outline thickens it too.