Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a template in PCL in Unix 3

Status
Not open for further replies.

alkane

MIS
Oct 16, 2017
1
0
0
AU
thread286-1706716
I have a project that looks decidedly similar to the thread above and in the same development environment. My client wants to remove some pre-printed forms for connotes and hazmat docs and replace with plain paper-printing. I need to store the form as a template in the Unix DB system and overlay the specific load data as required. I was looking at drafting a PCL document as that template.

I would be interested if Grotongroup was able to resolve his issues and let me know specifically how he did it.
 
Most of that (quite long) thread which you refer to was (very briefly) describing how to use the PCL 'draw rectangle' escape sequences to draw boxes.

In order to set this up as what you refer to as a 'template', you need to make use of PCL macros, as Jim Asman states in one of his later responses.

Describing how to create and use PCL macros is beyond the scope of what can easily be written in a response here.
I'd advise that you obtain a copy (plenty are available for download) of the "PCL5 Technical Reference" manual, part 1 (ref: bpl13210) and part 2 (ref: bpl13211).

Once you've read the chapter on macros, and tried things out for yourself, if you still have specific problems, we can then try to help you resolve those issues.
 
I will just add a couple of things to DansDadUK's comment.

Ideally, you would be able to create an overlay, and your existing output format would all just land perfectly on the overlay. BTW, the overlay is put on top of your data operationally and not the other way around. Sometimes that matters.

Often, the easiest scheme is to have a scan of the original form and derive a pcl macro from that. This can be a bit problematic as a bitmap image can be a very large file and introduce performance issues.

OR, you could simply use pcl commands to draw the form and if done properly would be less than 10% of the bitmap size. Now, if you have to absolutely clone the preprinted version, then the availability of the appropriate fonts can be an issue. It is a big win if you can utilize only the printer's internal fonts. For the line work, I always use HP-GL/2.

As yo probably know, the LaserJet can only print to a max width of about 8 inches on a portrait 8.5 x 11 page. Often, preprinted forms have printing out to the 8.5 width, in which case you will have to scale the form down to fit to the printable page. If you do scale the form down, you might be able to scale the data down similarly and still have the existing output format line up.

You can get very clever with this stuff. Years ago, we did some overlays for a very complex order entry system. Our download file contained something like 15 different macros, and depending on the nature of the order, the appropriate forms were printed.


Jim Asman
 
I should have mentioned that one huge benefit from an all PCL solution is that you can directly make a PDF from the generated PCL for customers that would like it emailed or print it as well.


Jim Asman
 
>> ... the overlay is put on top of your data operationally and not the other way around. Sometimes that matters ...

Not always true, Jim.

Macros can be invoked using call or execute, or automatic overlay.

With the first two of these, the required macro is selected on a page by-page basis, and can be invoked at the beginning of the page (before any variable data has been set), or at the end of the page (after all the variable data has been specified), or (I suppose) anywhere in between.

With 'automatic overlay', a (single) macro is selected at the beginning of the job, and applied automatically to each page thereafter, at the end of each page.
 
Chris,

I did say "overlay." ;-)

Seriously, once we get into the nether world of PCL viewers and PDF converters, a lot of things can change, particularly if your intended output is not from the printer. For example there is a free PCL Viewer from CoolUtils. If I create an invoice, let's say, with several line items, I prefer to shade every other line to simulate a "greenbar" type section. Now if I run the macro as an overlay with 4X, any data in the shaded lines is erased as the shading is NOT applied transparently as it should be. By running the macro with 3X all is well as the shading is laid down before the data. Ironically, in this case the thumbnail preview is correct, only the final output is wrong.

All of these options have their time and place. Thankfully, there is usually more than one way to do these things in PCL5. More that once I have seen PCL code fail on a $50K copier and print successfully on a $1K printer.





Jim Asman
 
To illustrate some of the differences, a small sample print job:

[ul]
[li]Downloads a very simple PCL macro (with identifier 501) which draws a black rectangle, overlaid with a smaller white rectangle; the macro contains no absolute positioning.[/li]
[li]Sets a position, then calls the macro, then writes some sample text.parts of which coincide with the rectangles.[/li]
[li]Sets a news position, then writes some sample text, then calls the macro which overlays parts of the text.[/li]
[/ul]

Analysis of job:
Code:
Offset: dec    Type                   Sequence          Description                                         
-------------  ---------------------  ----------------  ----------------------------------------------------
0000000000     PCL Parameterised      <Esc>%-12345X     Universal Exit Language (UEL)                       
               Comment                                  Switch language to PJL                              
0000000009     PJL Command            @PJL Enter         Language = PCL[0d][0a]                             
               Comment                                  Switch language to PCL                              
0000000036     PCL Simple             <Esc>E            Printer Reset                                       
0000000038     PCL Parameterised      <Esc>&u600D       Unit-of-Measure (600 PCL units per inch)            
0000000045     PCL Parameterised      <Esc>&f501y       Macro Control ID (identifer = 501)                  
0000000052                                   0X         Macro Control: Start Macro Definition               
0000000054     PCL Parameterised      <Esc>*c3600a      Rectangle Size Horizontal (3600 PCL units)          
0000000062                                   1800b      Rectangle Size Vertical   (1800 PCL units)          
0000000067                                   0P         Fill Rectangular Area: Solid Area                   
0000000069     PCL Parameterised      <Esc>*p+600x      Cursor Position Horizontal (+600 PCL units)         
0000000077                                   +300Y      Cursor Position Vertical   (+300 PCL units)         
0000000082     PCL Parameterised      <Esc>*c2400a      Rectangle Size Horizontal (2400 PCL units)          
0000000090                                   1200b      Rectangle Size Vertical   (1200 PCL units)          
0000000095                                   1P         Fill Rectangular Area: Solid White Areas            
0000000097     PCL Parameterised      <Esc>&f1X         Macro Control: Stop Macro Definition                
0000000102     PCL Parameterised      <Esc>&f501y       Macro Control ID (identifer = 501)                  
0000000109                                   10X        Macro Control: Make Macro Permanent                 
0000000112     PCL Parameterised      <Esc>&l26a        Page Size: A4: 210 mm x 297 mm                      
0000000118                                   0o         Orientation: Portrait                               
0000000120                                   0s         Simplex/Duplex: Simplex                             
0000000122                                   1l         Perforation Skip: Enable                            
0000000124                                   0E         Top Margin (0 lines)                                
0000000126     PCL Parameterised      <Esc>&a0L         Left Margin (column 0)                              
0000000131     PCL Parameterised      <Esc>(19U         Primary Font: Symbol Set (19U = Windows Latin 1 (CP 1252))
0000000136     PCL Parameterised      <Esc>(s0p         Primary Font: Spacing: Fixed                        
0000000141                                   12h        Primary Font: Pitch (12 characters per inch)        
0000000144                                   0s         Primary Font: Style (Upright, solid)                
0000000146                                   0b         Primary Font: Stroke Weight: Medium                 
0000000148                                   4099T      Primary Font: Typeface (4099 = Courier)             
0000000153     PCL Parameterised      <Esc>*p900x       Cursor Position Horizontal (900 PCL units)          
0000000160                                   600Y       Cursor Position Vertical   (600 PCL units)          
0000000164     PCL Parameterised      <Esc>&f501y       Macro Control ID (identifer = 501)                  
0000000171                                   3X         Macro Control: Call Macro                           
0000000173     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)          
0000000180                                   1200Y      Cursor Position Vertical   (1200 PCL units)         
0000000185     Data                                     Some sample text added AFTER macro call             
0000000224     PCL Parameterised      <Esc>*p600x       Cursor Position Horizontal (600 PCL units)          
0000000231                                   4200Y      Cursor Position Vertical   (4200 PCL units)         
0000000236     Data                                     Some sample text added BEFORE macro call            
0000000276     PCL Parameterised      <Esc>*p900x       Cursor Position Horizontal (900 PCL units)          
0000000283                                   3600Y      Cursor Position Vertical   (3600 PCL units)         
0000000288     PCL Parameterised      <Esc>&f501y       Macro Control ID (identifer = 501)                  
0000000295                                   3X         Macro Control: Call Macro                           
0000000297     PCL Simple             <Esc>E            Printer Reset                                       
0000000299     PCL Parameterised      <Esc>%-12345X     Universal Exit Language (UEL)                       
               Comment                                  Switch language to PJL
 
Chris,
Not wanting to nitpick, but your 501 macro appears to be lacking an <esc>*v101T command that will make the "white" pixels overwrite the existing black pixels. As it is, the white is applied transparently with no effect.


Jim Asman
 
Jim

I don't know what <Esc>*v101T does - the only # values I'm aware of are 1, 2, 3, and 4 for this "select current pattern" sequence.

But I don't think that pattern selection is required, since I'm using rectangular area graphics, and selecting (firstly) "black fill", then (for the second (inner) rectangle) "white (erase) fill", not the "user-defined" or "current pattern" fills.

On my various LaserJet models, it results (as expected) in a black rectangle containing a smaller white rectangle - i.e. the white pixels erase the black ones already laid down in the first rectangle.

According to the PCL5 Technical Reference manual: "Black fill (value field 0), also known as black rule, and the white fill (value field of 1) “patterns” do not have a choice of different patterns, and thus do not require a pattern specification using the Pattern ID command".
 
I think you will find that just having a white fill will not erase and already black pixel. Pattern transparency or something. There is a whole "headache generating" section in the manual about it where is shows overlaying 2 images, and depending on the setting, the white in the background clobbers the black in the foreground or vice versa as we are talking about here.


Jim Asman
 
Chris,
I apologize. Your code works correctly as advertised. I have my wires crossed somewhere, and when I have a moment I will sort out when you need the source/pattern transparency command.


Jim Asman
 
OK, this is about character fills, not rectangular fills.

Let's say you want to print white text on an existing black field on the background. <esc>*v1T specifies white characters. Just specifying white print will NOT overwrite existing black pixels. To do that you must also issue <esc>*v1O. Likewise if you want a shaded fill you specify <esc>*v2T. You would specify the % of shading with <esc>*v15G for a 15% shade. But by itself it still wouldn't copy the white pixels from the halftone to the black field. Again <esc>*v1O is also required. Of course you want to reset with <esc>(v0o0T when you're done.

Sorry for the confusion.


Jim Asman
 
Yes - when you are using pattern fills (other than black or white with rectangular area graphics), the source and pattern transparency settings can make quite a difference to the output.

... and when you also consider setting different ROP values (using <Esc>*l#O), it all gets very complicated (not something I've ever fully got to grips with).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top