Related Information Examples & Tutorials

How To Position Text And Graphics

When printing via Device Context in Collect! you can use several graphics commands for text and graphics. Margins can be set using margin commands. Text and images can be placed using position commands. You can also draw boxes, circles and lines in several different styles.

The output device, screen, printer, etc., is treated as a rectangular region with varying degrees of resolution determined by the device's pixels per inch. As a result of this, all graphics commands that require an absolute position must be supplied coordinates in 1/100ths of an inch. This allows the output of a 1200dpi laser and a 300dpi dot matrix to be basically identical with the exception of quality.

tip.gif Use the Print Preview "Ruler" feature to map out the exact coordinates to use with these commands! Simply press r on your keyboard as soon as the Print Preview displays and then use your mouse to drag the crosshairs. Read the exact coordinates displayed in the Print Preview title bar.


Print Preview Ruler with Coordinates

tip.gif DC Printing Samples - In this document, many sample snippets are shown. These are taken from the Printer Test that ships with Collect! Please print the Printer Test to view the results.

Margins

Top, bottom, right and left margins can be set using the following commands.

Top of page.

LM

This function sets the current left margin.

@LM

SYNTAX: @LM(value)

The argument value is interpreted as 1/100ths of an inch. The value is measured from the LEFT edge of the page.

If you would like to have an half inch left margin, you would use: @LM(50)

The setting is in effect until it is "turned off." This would be accomplished by using a value of zero. For instance, @LM(0) would restore the left margin to its default value.

Top of page.

RM

This function sets the current right margin.

@RM

SYNTAX: @RM(value)

The argument value is interpreted as 1/100ths of an inch. The value is measured from the RIGHT edge of the page.

If you would like to have an half inch right margin, you would use: @RM(50)

The setting is in effect until it is "turned off." This would be accomplished by using a value of zero. For instance, @RM(0) would restore the right margin to its default value.

tip.gif With large blocks of text, this command should be combined with @WRAP and @no line feed to correctly wrap the text within the right margin.

Top of page.

TM

This function sets the current top margin.

@TM

SYNTAX: @TM(value)

The argument value is interpreted as 1/100ths of an inch. The value is measured from the TOP edge of the page.

If you would like to have an half inch top margin, you would use: @TM(50)

The setting is in effect until it is "turned off." This would be accomplished by using a value of zero. For instance, @TM(0) would restore the top margin to its default value.

Top of page.

BM

This function sets the current bottom margin.

@BM

SYNTAX: @BM(value)

The argument value is interpreted as 1/100ths of an inch. The value is measured from the BOTTOM edge of the page.

If you would like to have an half inch bottom margin, you would use: @BM(50)

The setting is in effect until it is "turned off." This would be accomplished by using a value of zero. For instance, @BM(0) would restore the bottom margin to its default value.

tip.gif All of the above margin-setting commands are in addition to the over-all margin settings that you can specify through the Report Options form. You can set margins for your report in the Report Options form and then set margins for specific parts of your report with the commands above.

Top of page.

Pen, Line And Shapes

Sample code in the following commands is taken from the report, PRINTER TEST, in the Demodb database, please refer to this report for actual examples of the output of these graphics commands.

Top of page.

RGB Values

In the following commands, r, g, b arguments provide optional color choices in the standard RGB color model used for computer generated graphics and the Internet.

R, G, B: Each of these arguments may contain a value from 0 to 255, representing the levels of red, green and blue that make up the final color. (For example, 0, 0, 0 = black and 255, 255, 255 = white.) This allows for a maximum of 16,581,375 possible colors.

Please refer to Color Chart for sample colors you may use in commands that have the r, g, b arguments. For more complete color listings, search the web for "color chart."

Top of page.

Pen

This function modifies the current pen which is then used by subsequent commands such as Box, or Line. The Pen command has 5 arguments.

@Pen

SYNTAX: @Pen(type, width, r, g, b)

Type: Specifies the type of pen you want to use. There are currently 5 types.

0 - Solid
1 - Dashed (width must be 1)
2 - Dotted (width must be 1)
3 - Dash - Dot - Dash - Dot (width must be 1)
4 - Dash - Dot - Dot - Dash - Dot - Dot (width must be 1)

Width: Represents the thickness of the pen in 1/100th of an inch accuracy. A value of 1 always equals 1 pixel. Higher values are treated as a percentage of an inch.

tip.gif The types 1 - 4 will not work if the width is anything other than one. This is a Microsoft Windows restriction not Collect!

R, G, B: These arguments may contain a value from 0 to 255 and represent the levels of red, green and blue that make up the final color of the line. Please refer to the section above entitled RGB Values for more information.

DC Printing Samples:

@Pen (0, 1, 0, 0, 0)
@Box (100, 150, 100, 100)

@Pen (0, 2, 0, 0, 0)
@Box (250, 150, 100, 100)

Top of page.

Line

This function draws a single line using the current pen or one you specify with the type, width, r, g, b arguments.

@Line (This command is case sensitive.)

SYNTAX: @Line(x1,y1,x2,y2,type,width,r,g,b)

x1: The X position of the START point in 1/100ths of an inch.
This is measured from the LEFT edge of the page.

y1: The Y position of the START point in 1/100ths of an inch.
The value is measured from the TOP edge of the page.

x2: The X position of the END point in 1/100ths of an inch.
The value is measured from the LEFT edge of the page.

y2: The X position of the END point in 1/100ths of an inch.
The value is measured from the TOP edge of the page.

Type: Specifies the type of pen you want to use. There are currently 5 types.

0 - Solid
1 - Dashed (width must be 1)
2 - Dotted (width must be 1)
3 - Dash - Dot - Dash - Dot (width must be 1)
4 - Dash - Dot - Dot - Dash - Dot - Dot (width must be 1)

Width: Represents the thickness of the pen in 1/100th of an inch accuracy. A value of 1 always equals 1 pixel. Higher values are treated as a percentage of an inch.

tip.gif The types 1 - 4 will not work if the width is anything other than one. This is a Microsoft Windows restriction not Collect!

R, G, B: These arguments may contain a value from 0 to 255 and represent the levels of red, green and blue that make up the final color of the line. Please refer to the section above entitled RGB Values for more information.

tip.gif Type, Width, and RGB are optional arguments that allow you to use a pen other than the current one. Doing so will not affect the current pen, just the line. If you specify only the parameters Type and/or Width, the line color defaults to black.

DC Printing Samples:

@Pen (0, 1, 0, 0, 0) // Color is BLACK when box and line are drawn.
@Box (100, 300, 100, 100)
@Line (100, 350, 200, 350)

@Pen (0, 1, 0, 0, 0) // Color is BLACK when box and 2 lines are drawn.
@Box (250, 300, 100, 100)
@Line (250, 325, 350, 325)
@Line (250, 375, 350, 375)

@Line (250, 375, 350, 375, 1, 2, 255, 0, 0) // Line is drawn in RED.

Top of page.

Box

This function draws a simple box using the current pen as the border. See the Pen () command for details.

@Box

SYNTAX: @Box(left, top, width, height, r, g, b)

Left: Represents the TOP LEFT X co-ordinate of the box in 1/100ths of an inch.
The value is measured from the LEFT edge of the page.

Top: Represents the TOP LEFT Y co-ordinate of the box in 1/100ths of an inch.
The value is measured from the TOP edge of the page.

Width: Represents the WIDTH of the box in 1/100ths of an inch.

Height: Represents the HEIGHT of the box in 1/100ths of an inch.

R, G, B: Optional FILL COLOR for the box. Please refer to the section above entitled RGB Values for more information.

DC Printing Samples:

@Pen (0, 1, 0, 0, 0)
@Box (100, 150, 100, 100)

@Pen (0, 2, 0, 0, 0)
@Box (400, 300, 100, 100)
@Line (400, 315, 500, 315)
@Line (400, 345, 500, 345)

Top of page.

Circ

This function draws a circle or ellipse based on the arguments you supply. This function behaves exactly like the Box () function but draws circles instead.

@Circ

SYNTAX: @Circ(left, top, width, height, r, g, b)

Left: Represents the TOP LEFT X co-ordinate of the box in 1/100ths of an inch.
The value is measured from the LEFT edge of the page.

Top: Represents the TOP LEFT Y co-ordinate of the box in 1/100ths of an inch.
The value is measured from the TOP edge of the page.

Width: Represents the WIDTH of the box in 1/100ths of an inch.

Height: Represents the HEIGHT of the box in 1/100ths of an inch.

R, G, B: Optional FILL COLOR for the box. Please refer to the section above entitled RGB Values for more information.

DC Printing Samples:

@Pen (0, 2, 0, 0, 0)
@Circ (250, 450, 100, 100)

@Pen (0, 3, 0, 0, 0)
@Circ (550, 450, 100, 100)
@Circ (560, 460, 80, 80)
@Circ (570, 470, 60, 60)

Top of page.

Img

This function displays a bitmap or a PNG image on the page.

@Img

SYNTAX: @Img(filename, left, top, width, height)

Filename: Represents the *.bmp or *.png file you want to use. Currently, the bitmap file must be saved in uncompressed format. You can simply put your *.bmp or *.png image into the CV11\bin\styles folder. For example, if you have used the default installation path for Collect!, you can put your image into C:\CV11\bin\styles.

Left: The LEFT position of the image in 1/100ths of an inch.
The value is measured from the LEFT edge of the page.

Top: The TOP position of the image in 1/100ths of an inch.
The value is measured from the TOP edge of the page.

Width: The output WIDTH of the image in 1/100ths of an inch.

Height: The output HEIGHT of the image in 1/100ths of an inch.

DC Printing Sample:

When your image is in the default folder as described above, just put the name of your image file in the @Img tag as shown below.

@Img(mylogo.bmp, 350, 625, 45, 30)

looks in the CV11\bin\styles folder for the bitmap, "mylogo.bmp."

Top of page.

Bitmaps And Pngs For Printing

Alternatively, you can store your image files in your own folder, using one of the following rules.

1. Subfolder in Styles Folder

Example: @Img(\images\mylogo.bmp, 350, 625, 45, 30)

Collect! looks in the "images" subfolder inside your CV11\bin\styles folder for the bitmap, "mylogo.bmp."

2. Global File Access Path

If you set your Global File Access Path in Database Preferences, Collect! will look there for a "styles" subfolder.

Example: @Img(mylogo.png, 350, 625, 45, 30)
Global File Access Path set to c:\myfiles

Collect! will look for "mylogo.png" in c:\myfiles\styles

3. Explicitly Specified Path

If you set an explicit path in your @Img tag, Collect! will look there for the image file.

UNC Path

@Img(\\myserver\myfiles\mylogo.bmp, 350, 625, 45, 30)


Collect! will look for the "myserver" computer on your network and will use the "mylogo.bmp" in the "myfiles" folder.

Local or Mapped Path

@Img(D:\myfiles\mylogo.png, 350, 625, 45, 30)


Collect! will look for the "mylogo.png" in the "myfiles" folder on the D drive of your computer.

@Img(C:\images\mylogo.bmp, 350, 625, 45, 30)


Collect will look for the "mylogo.bmp" in the "images" folder on your C drive.

Top of page.

Img With Variables

You can also set the bitmap or PNG through a variable. This can be used with the IF conditional to change the image file based on a condition you set.

For Example:

The following snippet will show a different logo depending on the Client Name.

@varBMP* = ""
@varBMP = "oldlogo.bmp"
@varBMP = "mynewlogo.png" if (@cl.na = "My New Client")
@Img (@varBMP, 350, 625, 45, 30)

Top of page.

Metafile Image In Reports

There is a special command, @EMF, for putting an *.emf metafile in your report. Please refer to Help topic, Enhanced Metafile in Report for details.

Top of page.

Pos

This function sets the current text position. The default text position is just after the last character output. However, it is sometimes necessary to output a line of text at a specific location on the page.

@Pos

SYNTAX: @Pos(left,top)

Left: The current X position in 1/100ths of an inch.
The value is measured from the LEFT edge of the page.

Top: The current Y position in 1/100ths of an inch.
The value is measured from the TOP edge of the page.

DC Printing Sample:

@Pos (0, 400)

@= This is centered 4 inches from the top of the page @=

Top of page.

Shades Of Gray

These are a few RGB values for shades of gray. Please refer to the section above entitled RGB Values for more information.

White: 255, 255, 255

Very Light Gray: 200, 200, 200

Light Gray: 150, 150, 150

Darker Gray: 75, 75, 75

Black: 0, 0, 0

Top of page.

Color Chart

Please refer to Color Chart to view some colors you can use in Collect!. For more complete charts, you may search the web for "color chart."

Top of page.

Samples Of Graphics

Please refer to the sample report " Printer Test" for details and code samples.

1. In the Demodb database, pull down the Print menu and choose Reports and Letters.

2. Locate the Printer Test report and print it.

3. Pull down the Print menu and choose Customize Printing, Edit Report Templates.

4. Locate the Printer Test report and open the Report Definition for the report.

5. Click in the Report Body to view the codes for the graphics commands.

6. Pull down the Print menu and choose Reports and Letters.

7. Choose Quick Print to print out the codes.

8. Compare the Samples with their respective codes to see how the graphics commands are actually used and the results that are produced.

Top of page.

See Also

- How To Control Font Attributes for changing font color
- Report Options for setting margins
- Report Sample to view sample reports and letters
- Report Topics Index for a list of all report and letter topics

Top of page.

Was this page helpful? Do you have any comments on this document? Can we make it better? If so how may we improve this page.

Please click this link to send us your comments: helpinfo@collect.org