Solved

(Mis-)understanding HP-GL/2 SR command when using PCL coordinates

Posted on 2014-03-05
9
370 Views
Last Modified: 2014-04-06
Just trying to understand HP-GL/2 in somewhat more detail than I've done in the past, and there's something I'm failing to understand with use of the SR command to stretch character sizes.

It works if I use 600 user-units-per-inch and the default HP-GL/2 axes (where Y values increase UP the page).

SC0,1.6933,0,1.6933,2;          Scale sets user units = 600 per-inch

Open in new window


with labels preceded by various SR commands, such as:

SR5,4;            Set Relative Character Width  & Height as 5% / 4% of P1/P2 rectangle

SR5,2;            Set Relative Character Width  & Height as 5% / 2% of P1/P2 rectangle

SR10,2;           Set Relative Character Width  & Height as 10% / 2% of P1/P2 rectangle

Open in new window


But if I change the axes to match the PCL coordinate system (where Y values increase DOWN the page):

SC0,1.6933,0,-1.6933,2          Scale sets user units = 600 per-inch, with Y-axis reversed

IR0,100,0,100     Input Relative P1 and P2

Open in new window


as shown in the PCL5 & HP-GL/2 manual (alhough I don't yet understand just what the IR command is doing), then the same SR commands don't print anything (I suspect because the characters are too small to print).

... and even if I use the maximum value (32767) for width or height, the stretching is nowhere near as much as that printed using the original small SR values with the HP-GL/2 Y-axis setup.
0
Comment
Question by:DansDadUK
  • 8
9 Comments
 
LVL 16

Author Comment

by:DansDadUK
ID: 39905982
Some test files I've used, to make it clearer what I've tried:
 
test01.prn (renamed with extra .txt extension to allow it to be attached) uses the HP-GL/2 Y direction, and works OK; an analysis shows the content:

Offset         Type                   Sequence          Description
-------------  ---------------------  ----------------  ----------------------------------------------------

0000000000     PCL Simple             <Esc>E            Printer Reset
0000000002     PCL Parameterised      <Esc>&u600D       Unit-of-Measure (600 PCL units per inch)
0000000009     PCL Parameterised      <Esc>&l26a        Page Size: A4
0000000015                                   0o         Orientation: Portrait
0000000017                                   0s         Simplex/Duplex: Simplex
0000000019                                   1l         Perforation Skip: Enable
0000000021                                   0E         Top Margin (0 lines)
0000000023     PCL Parameterised      <Esc>&a0L         Left Margin (column 0)
0000000028     PCL Parameterised      <Esc>(0N          Primary Font: Symbol Set (0N = ISO 8859-1 Latin 1)
0000000032     PCL Parameterised      <Esc>(s1p         Primary Font: Spacing: Proportional
0000000037                                   15v        Primary Font: Height (15 points)
0000000040                                   0s         Primary Font: Style (Upright, solid)
0000000042                                   0b         Primary Font: Stroke Weight: Medium
0000000044                                   16602T     Primary Font: Typeface (16602 = Arial)
0000000050     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)
0000000057                                   600Y       Cursor Position Vertical   (600 PCL units)
0000000061     Data                                     test01
0000000067     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)
0000000074                                   900Y       Cursor Position Vertical   (900 PCL units)
0000000078     Data                                     600 units-per-inch
0000000096     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)
0000000103                                   1200Y      Cursor Position Vertical   (1200 PCL units)
0000000108     Data                                     Y axis = HP/GL2 (increases up page)
0000000143     PCL Parameterised      <Esc>*p0x         Cursor Position Horizontal (0 PCL units)
0000000148                                   0Y         Cursor Position Vertical   (0 PCL units)
0000000150     PCL Parameterised      <Esc>*c5611x      Picture Frame Size Width  (5611 decipoints)
0000000158                                   8416y      Picture Frame Size Height (8416 decipoints)
0000000163                                   0T         Set Picture Frame Anchor Point
0000000165     PCL Parameterised      <Esc>%0B          Enter HP-GL/2 Mode: Pen = HP-GL/2
               Comment                                  Switch language to HP-GL/2
0000000169     HP-GL/2 Command        IN                Initialise
0000000171     HP-GL/2 Command        SP1;              Select Pen
0000000175     HP-GL/2 Command        DT~               Define Label Terminator
               Comment                                  Label terminator is now ~
0000000178     HP-GL/2 Command        SD1,14,2,1,4,12,  
0000000194                              5,0,6,0,7,1660  
0000000208                              2;              Standard Font Definition
0000000210     HP-GL/2 Command        SC0,1.6933,0,1.6  
0000000226                              933,2;          Scale
0000000232     HP-GL/2 Command        PU0,0;            Pen Up
0000000238     HP-GL/2 Command        PA1200,2100;      Plot Absolute
0000000250     HP-GL/2 Command        LB                Label
0000000252     HP-GL/2 Label                            (1200,2100)~
0000000264     HP-GL/2 Command        PD3000,2400       Pen Down
0000000275     HP-GL/2 Command        PU;               Pen Up
0000000278     HP-GL/2 Command        LB                Label
0000000280     HP-GL/2 Label                            (3000,2400)~
0000000292     HP-GL/2 Command        PA900,4310;       Plot Absolute
0000000303     HP-GL/2 Command        LB                Label
0000000305     HP-GL/2 Label                            standard:~
0000000315     HP-GL/2 Command        PA900,4010;       Plot Absolute
0000000326     HP-GL/2 Command        LB                Label
0000000328     HP-GL/2 Label                            set SR =5,4:~
0000000341     HP-GL/2 Command        PA900,3710;       Plot Absolute
0000000352     HP-GL/2 Command        LB                Label
0000000354     HP-GL/2 Label                            set SR = 5,2:~
0000000368     HP-GL/2 Command        PA900,3410;       Plot Absolute
0000000379     HP-GL/2 Command        LB                Label
0000000381     HP-GL/2 Label                            set SR = 10,2:~
0000000396     HP-GL/2 Command        PA2100,4310;      Plot Absolute
0000000408     HP-GL/2 Command        LB                Label
0000000410     HP-GL/2 Label                            abcde~
0000000416     HP-GL/2 Command        PA2100,4010;      Plot Absolute
0000000428     HP-GL/2 Command        SR5,4;            Relative Character Size
0000000434     HP-GL/2 Command        LB                Label
0000000436     HP-GL/2 Label                            abcde~
0000000442     HP-GL/2 Command        PA2100,3710;      Plot Absolute
0000000454     HP-GL/2 Command        SR5,2;            Relative Character Size
0000000460     HP-GL/2 Command        LB                Label
0000000462     HP-GL/2 Label                            abcde~
0000000468     HP-GL/2 Command        PA2100,3410;      Plot Absolute
0000000480     HP-GL/2 Command        SR10,2;           Relative Character Size
0000000487     HP-GL/2 Command        LB                Label
0000000489     HP-GL/2 Label                            abcde~
               Comment                                  Previous sequence not terminated by semi-colon
               Comment                                  Switch language to PCL
0000000495     PCL Parameterised      <Esc>%0A          Enter PCL Mode: Cursor = PCL
0000000499     PCL Simple             <Esc>E            Printer Reset

Open in new window


which prints as per the attached scan_Test01.pdf scan.
test01.prn.txt
scan-Test01.pdf
0
 
LVL 16

Author Comment

by:DansDadUK
ID: 39905984
... and test02.prn (renamed with extra .txt extension to allow it to be attached) uses the PCL Y direction, but doesn't work as expected; an analysis shows the content:

Offset         Type                   Sequence          Description
-------------  ---------------------  ----------------  ----------------------------------------------------

0000000000     PCL Simple             <Esc>E            Printer Reset
0000000002     PCL Parameterised      <Esc>&u600D       Unit-of-Measure (600 PCL units per inch)
0000000009     PCL Parameterised      <Esc>&l26a        Page Size: A4
0000000015                                   0o         Orientation: Portrait
0000000017                                   0s         Simplex/Duplex: Simplex
0000000019                                   1l         Perforation Skip: Enable
0000000021                                   0E         Top Margin (0 lines)
0000000023     PCL Parameterised      <Esc>&a0L         Left Margin (column 0)
0000000028     PCL Parameterised      <Esc>(0N          Primary Font: Symbol Set (0N = ISO 8859-1 Latin 1)
0000000032     PCL Parameterised      <Esc>(s1p         Primary Font: Spacing: Proportional
0000000037                                   15v        Primary Font: Height (15 points)
0000000040                                   0s         Primary Font: Style (Upright, solid)
0000000042                                   0b         Primary Font: Stroke Weight: Medium
0000000044                                   16602T     Primary Font: Typeface (16602 = Arial)
0000000050     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)
0000000057                                   600Y       Cursor Position Vertical   (600 PCL units)
0000000061     Data                                     test02
0000000067     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)
0000000074                                   900Y       Cursor Position Vertical   (900 PCL units)
0000000078     Data                                     600 units-per-inch
0000000096     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)
0000000103                                   1200Y      Cursor Position Vertical   (1200 PCL units)
0000000108     Data                                     Y axis = PCL (increases down page)
0000000142     PCL Parameterised      <Esc>*p0x         Cursor Position Horizontal (0 PCL units)
0000000147                                   0Y         Cursor Position Vertical   (0 PCL units)
0000000149     PCL Parameterised      <Esc>*c5611x      Picture Frame Size Width  (5611 decipoints)
0000000157                                   8416y      Picture Frame Size Height (8416 decipoints)
0000000162                                   0T         Set Picture Frame Anchor Point
0000000164     PCL Parameterised      <Esc>%0B          Enter HP-GL/2 Mode: Pen = HP-GL/2
               Comment                                  Switch language to HP-GL/2
0000000168     HP-GL/2 Command        IN                Initialise
0000000170     HP-GL/2 Command        SP1;              Select Pen
0000000174     HP-GL/2 Command        DT~               Define Label Terminator
               Comment                                  Label terminator is now ~
0000000177     HP-GL/2 Command        SD1,14,2,1,4,12,  
0000000193                              5,0,6,0,7,1660  
0000000207                              2;              Standard Font Definition
0000000209     HP-GL/2 Command        SC0,1.6933,0,-1.  
0000000225                              6933,2          Scale
0000000231     HP-GL/2 Command        IR0,100,0,100     Input Relative P1 and P2
0000000244     HP-GL/2 Command        PU0,0;            Pen Up
0000000250     HP-GL/2 Command        PA1200,2100;      Plot Absolute
0000000262     HP-GL/2 Command        LB                Label
0000000264     HP-GL/2 Label                            (1200,2100)~
0000000276     HP-GL/2 Command        PD3000,2400       Pen Down
0000000287     HP-GL/2 Command        PU;               Pen Up
0000000290     HP-GL/2 Command        LB                Label
0000000292     HP-GL/2 Label                            (3000,2400)~
0000000304     HP-GL/2 Command        PA900,2700;       Plot Absolute
0000000315     HP-GL/2 Command        LB                Label
0000000317     HP-GL/2 Label                            standard:~
0000000327     HP-GL/2 Command        PA900,3000;       Plot Absolute
0000000338     HP-GL/2 Command        LB                Label
0000000340     HP-GL/2 Label                            set SR = 16384,32767:~
0000000362     HP-GL/2 Command        PA900,3300;       Plot Absolute
0000000373     HP-GL/2 Command        LB                Label
0000000375     HP-GL/2 Label                            set SR = 16384,16384:~
0000000397     HP-GL/2 Command        PA900,3600;       Plot Absolute
0000000408     HP-GL/2 Command        LB                Label
0000000410     HP-GL/2 Label                            set SR = 32767,16384:~
0000000432     HP-GL/2 Command        PA2100,2700;      Plot Absolute
0000000444     HP-GL/2 Command        LB                Label
0000000446     HP-GL/2 Label                            abcde~
0000000452     HP-GL/2 Command        PA2100,3000;      Plot Absolute
0000000464     HP-GL/2 Command        SR16384,32767;    Relative Character Size
0000000478     HP-GL/2 Command        LB                Label
0000000480     HP-GL/2 Label                            abcde~
0000000486     HP-GL/2 Command        PA2100,3300;      Plot Absolute
0000000498     HP-GL/2 Command        SR16384,16384;    Relative Character Size
0000000512     HP-GL/2 Command        LB                Label
0000000514     HP-GL/2 Label                            abcde~
0000000520     HP-GL/2 Command        PA2100,3600;      Plot Absolute
0000000532     HP-GL/2 Command        SR32767,16384;    Relative Character Size
0000000546     HP-GL/2 Command        LB                Label
0000000548     HP-GL/2 Label                            abcde~
               Comment                                  Previous sequence not terminated by semi-colon
               Comment                                  Switch language to PCL
0000000554     PCL Parameterised      <Esc>%0A          Enter PCL Mode: Cursor = PCL
0000000558     PCL Simple             <Esc>E            Printer Reset

Open in new window


 which prints as per the attached scan_Test02.pdf scan.
test02.prn.txt
scan-Test02.pdf
0
 
LVL 12

Expert Comment

by:satsumo
ID: 39908071
Hello DansDadUK,

I like this question. Try this for the second case:

SC 0,1.6933, 1.6933, 0, 2

Any idea what the 2 on the end of that command is for?
0
 
LVL 16

Author Comment

by:DansDadUK
ID: 39908969
The type parameter of the SC command can take one of three values:

0 = Anisotropic
Establishes standard user-unit scaling allowing different unit size on X-axis and Y-axis.
1 = Isotropic
Establishes standard user-unit scaling with same unit size on X-axis and Y-axis.
2 = Point Factor
Establishes P1 user-unit location and a specific ratio of plotter units to user-units.

I'll try your suggested change to the second SC command later this morning (UK time), but as this departs from the method documented in the PCL5 Technical Reference manual regarding "Adapting the HP-GL/2 Coordinate System to Match the PCL System", I have my doubts as to the effect it will have.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Author Comment

by:DansDadUK
ID: 39912228
test03.prn (renamed with extra .txt extension to allow it to be attached), with the suggested change to the SC command, uses the HP-GL/2 Y direction, not the PCL Y direction and still doesn't make the required changes to the character sizes.
test03.prn.txt
test03.prn-analysis.txt
scan-Test03.pdf
0
 
LVL 16

Author Comment

by:DansDadUK
ID: 39961937
The crux of the matter is in not understanding the purpose, or action, of the command:

IR0,100,0,100

Open in new window

According to the specification (in part 2 of the PCL5 Technical Reference manual), the IR command (Input Relative P1 and P2) establishes P1 and P2 locations as a percentage of the PCL Picture Frame.

The command has the format:

IR XP1,YP1,[XP2,YP2;]

Open in new window

where "the X,Y coordinates specify the location of P1 (and, optionally, P2) as percentages of the PCL Picture Frame limits".

It also states that "Neither X,Y coordinate of P1 can equal the corresponding coordinate of P2. If either coordinate of P1 equals the corresponding coordinate of P2, the coordinate of P2 is incremented by 1 plotter unit".

So with coordinates of 0,100,0,100, it seems that this would causes the P2 values to both be automatically incremented by one plotter unit (0.25mm), making the P1-P2 distance very small - hence perhaps the reason for the very large SR values required as per the initial (test02.prn) example.

But I still don't understand the reason why this IR command is required (but if it is omitted, nothing after the SC command prints, so it is obviously necessary).
0
 
LVL 16

Accepted Solution

by:
DansDadUK earned 0 total points
ID: 39968977
I believe that the example (in the PCL5 Technical Reference manual, Table 19-5 "Adapting the HP-GL/2 Coordinate System to Match the PCL System in Portrtait Orientation") is incorrect.
 
The correct IR command should be:
IR0,100,100,0

Open in new window

This fits logically with the specification of the IR command (Input Relative P1 and P2) that it "establishes P1 and P2 locations as a percentage of the PCL Picture Frame".

The command has the format:
IR XP1,YP1,[XP2,YP2;]

Open in new window

where "the X,Y coordinates specify the location of P1 (and, optionally, P2) as percentages of the PCL Picture Frame limits".
 
To make this clearer, consider the default  situation (HP-GL/2 Y-axis), where P1 is at lower-left, and P2 is at upper-right of the picture frame; the default IR coordinates are 0,0,100,100:
Picture frame with default P1 P2Now consider the 'adapt' situation (PCL Y-axis), where P1 is at upper-left, and P2 is at lower-right of the picture frame; the correct IR coordinates are (I believe) 0,100,100,0:
Picture frame - modified P1 P2The only other change that then needs to be made is with the SR command: because the P2Y-P1Y value is now negative, the height coordinate of the command should now also be negative; for example:
SR5,-4

Open in new window

0
 
LVL 16

Author Comment

by:DansDadUK
ID: 39968999
... and attached are two test files (and scans of those files printed on a LaserJet Pro 400 Colour MFP M475dn printer) which illustrate the point.
 
test21_a.prn uses the default HP-GL/2 Y-axis; it uses PCL to:
Initialise the job, and print a heading.
Print a list (using CarriageReturn + LineFeed terminated text lines) of the HP-GL/2 commands which will follow.
It then switches to HP-GL/2 mode to:
Print a rectangle and a slanted line (with coordinate labels), both with Pen width of 1.
Call the SC command to set the scale to 600 user-units-per-inch.
Call the IR command with the default coordinates 0,0,100,100.
Print the 'same' rectangle and a slanted line (with coordinate labels), but with Pen width of 2.
Print some descriptive labels.
Use the LB command to print the characters abcde several times, all apart from the first after calling the SR command to set different character scaling.
The job illustrates how the same user-coordinates result in different outputs depending upon the scaling.

test22_a.prn is similar to the previous job, but uses the scaling stage to make use of the PCL Y-axis; it uses PCL to:
Initialise the job, and print a heading.
Print a list (using CarriageReturn + LineFeed terminated text lines) of the HP-GL/2 commands which will follow.
It then switches to HP-GL/2 mode to:
Print a rectangle and a slanted line (with coordinate labels), both with Pen width of 1.
Call the SC command to set the scale to 600 user-units-per-inch, but setting the Y-axis to increase down the page.
Call the IR command with the modified coordinates 0,100,100,0.
Print the 'same' rectangle and a slanted line (with coordinate labels), but with Pen width of 2.
Print some descriptive labels.
Use the LB command to print the characters abcde several times, all apart from the first after calling the SR command (with negative height coordinates) to set different character scaling.
test21-a.prn
test22-a.prn
scan-Test21a.pdf
scan-Test22a.pdf
0
 
LVL 16

Author Closing Comment

by:DansDadUK
ID: 39981011
I've found a solution by trial and error (plus some re-reading of the specification), leading me to believe that the example in the HP manual is incorrect.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

When designing and editing page layouts in inDesign, fonts can become messy without the help of paragraph styles. How many times have you re-read through a document you created and noticed a sentence in the middle of a paragraph happened to be a dif…
A short article about problems I had with the new location API and permissions in Marshmallow
Learn how to automatically add page numbers in your next InDesign project. This can be very helpful in multi-page books and magazines that you are designing. Make sure your Pages window visible.:  In the document you wish to add page numbers to. Act…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now