fontsize and/or space between lines

H

Huub

Hi,

Looking through CPAN I found font modules, but I can't figure if I can
use them for printing small(er) fonts. Also, is there a possibilty to
change the space between lines? If so, what should I look for (what is
it called in English?) ?

Thanks,

Huub
 
P

Paul Lalli

Huub said:
Looking through CPAN I found font modules,

*What* modules? Give us names.
but I can't figure if I can
use them for printing small(er) fonts

Printing to *what*?
. Also, is there a possibilty to
change the space between lines?

*What* lines? What are you printing to? Are you talking about printing
to a Unix terminal? A Microsoft World document? A plain text file?
The answer to your question is heavily dependent upon the answer to
that.
If so, what should I look for (what is it called in English?) ?

Line Spacing?

Paul Lalli
 
H

Huub

*What* modules? Give us names.

Like these: Font::FreeType found at
http://search.cpan.org/search?query=font&mode=module
Printing to *what*?

Printing ASCII to a HP DeskJet520
*What* lines? What are you printing to? Are you talking about printing
to a Unix terminal? A Microsoft World document? A plain text file?
The answer to your question is heavily dependent upon the answer to
that.

I've written a script to print address labels with 4 lines per label. A
problem is that the distance between each 2 lines is just too much (or
large?). Result is that after 2 or 3 labels downwards, the last line of
the label is partly being printed on the next-lower label.
Line Spacing?

That could be it.

Thank you for helping out,

Huub
 
I

Ian Wilson

Huub said:
Like these: Font::FreeType found at
http://search.cpan.org/search?query=font&mode=module



Printing ASCII to a HP DeskJet520



I've written a script to print address labels with 4 lines per label. A
problem is that the distance between each 2 lines is just too much (or
large?). Result is that after 2 or 3 labels downwards, the last line of
the label is partly being printed on the next-lower label.



That could be it.

I have done this by using Perl to merge a plain text file (e.g. fixed 5
lines per label) with appropriate PCL commands and use the HP DeskJet's
built-in fonts. Your 520 probably has a few dozen built in fonts that
are suitable for most purposes. With PCL you can control the font size
and line spacing. You could calculate the exact coordinates for each
line of text on each label and insert the PCL positioning commands.

Is this what you are doing?
 
H

Huub

I have done this by using Perl to merge a plain text file (e.g. fixed 5
lines per label) with appropriate PCL commands and use the HP DeskJet's
built-in fonts. Your 520 probably has a few dozen built in fonts that
are suitable for most purposes. With PCL you can control the font size
and line spacing. You could calculate the exact coordinates for each
line of text on each label and insert the PCL positioning commands.

Is this what you are doing?

Sound like a nice solution. I read data from a MySQL database and print
it without changing font(size) etc. The layout itself is fine.
Could you give an example about how to include PCL into Perl?

Thank you.
 
I

Ian Wilson

Huub said:
Sound like a nice solution. I read data from a MySQL database and print
it without changing font(size) etc. The layout itself is fine.
Could you give an example about how to include PCL into Perl?

The script below is an edited version of what I use. I have not tested
the edited version but it should give you some idea of one way to
accomplish this type of task. (The actual script is for CGI and creates
a web page which allows the user to upload a text file of label data,
you'll have to amend it for your needs, what follows below should read
label text from STDIN.

The input would be something like

label 1 line 1
label 1 line 2

label 2 line 1
label 2 line 2
label 2 line 3

label 3 line 1

I can't remember when exactly I wrote this but it clearly shows a *lot*
of my bad habits from Perl 4 days. therefore do *not* use it as an
eample of good style! Regulars of c.l.p.m may wish to point out it's
many many deficiencies. I'll grit my teeth and bear it :)


#!/usr/bin/perl
use strict;
use warnings;

#
# Avery J8163M labels are 14 per A4 sheet in two columns
# The distance from edge of page to the edge of the labels is:
# left: 4mm, top 14mm.
# There is no gap between labels vertically but there is a gap
# of about 3mm (1/10") between the two columns.
# The label dimensions are 99.1mm wide x 38.1mm high.
#
# Since PCL works in units of Inches or decipoints (1/720")
# The above are converted to
#
# left 0.1575" 113dp
# top 0.5512" 396dp
# gap 0.1000" 72dp
# width 3.9016" 2809dp
# height 1.5000" 1080dp
#

my $left = 50;
my $top = 450;
my $hgap = 72;
my $vgap = 0;
my $width = 2809;
my $height = 1080;

#
# We will not print at very edge of label but a few mm in from the edge
#
my $hinset = 144;
my $vinset = 144;

#
# We assume we are printing 6 lines per inch
#
my $lineheight = 720 / 6;

my $Esc = chr(27);
my $FormFeed = chr(12);

my $x = $left + $hinset;
my $y = $top + $vinset;

open (OUT, "|lp -d laserjet")
or die "(cannot print (lp -d laserjet) because $!\n";

pclstart();

my $count = 0;
my $row = 0;
while (<>) {
chomp;

if (/^\s*$/) { # move to top of next label
$count++;
$row++;

# move to top of next column?
if ($count == 7) {
$row = 0;
$x = $left + $width + $hgap + $hinset;
$y = $top + $vinset;

# start a new page?
} elsif ($count == 14) {
print OUT $FormFeed;
$count = 0;
$row = 0;
$x = $left + $hinset;
$y = $top + $vinset;
} else {
$y = $top + ($row * ($height + $vgap)) + $vinset;
}

} else {
print OUT "${Esc}&a${x}h${y}V$_"; # position text
$y = $y + $lineheight;
}

}
print OUT "${Esc}E"; # reset
close OUT;

exit;

sub pclstart {
print OUT "${Esc}E", # reset
"${Esc}&l0S", # Simplex (1 side per sheet)
"${Esc}&l2H", # Manual feed
"${Esc}&l26A", # A4
"${Esc}&k2G", # LF -> CR+LF
"${Esc}&l6D", # 6 lpi
"${Esc}&l0O", # Portrait
"${Esc}&l0E", # Top Margin (lines)
"${Esc}&l70F", # Text length (lines)
"${Esc}&a0L", # left Margin (columns)
"${Esc}(0N", # Character set: 0N = Latin 1
"${Esc}(s10v", # 10 point
"0s", # upright
"3b", # bold
"3t", # Courier
"2Q", # Letter Quality
"";
}
 
H

Huub

exit;
sub pclstart {
print OUT "${Esc}E", # reset
"${Esc}&l0S", # Simplex (1 side per sheet)
"${Esc}&l2H", # Manual feed
"${Esc}&l26A", # A4
"${Esc}&k2G", # LF -> CR+LF
"${Esc}&l6D", # 6 lpi
"${Esc}&l0O", # Portrait
"${Esc}&l0E", # Top Margin (lines)
"${Esc}&l70F", # Text length (lines)
"${Esc}&a0L", # left Margin (columns)
"${Esc}(0N", # Character set: 0N = Latin 1
"${Esc}(s10v", # 10 point
"0s", # upright
"3b", # bold
"3t", # Courier
"2Q", # Letter Quality
"";
}

Looks like what I need. What is your source of PCL codes? I can only
find some codes of PCL5 online, but that's certainly too new for the 520.
 
I

Ian Wilson

Huub said:
Looks like what I need. What is your source of PCL codes?

PCL PJL Quick Reference bpl13205.pdf
PCL 5 Tech Ref bpl13210.pdf

Downloaded from HP's web site. Don't ask me the URL, I used Google and
I can only
find some codes of PCL5 online, but that's certainly too new for the 520.

It's not that PCL5 is new, its just that the DeskJet range implement a
subset called PCL3. See
http://en.wikipedia.org/wiki/Printer_Command_Language#PCL_levels_1_through_5_overview

This is now completely off-topic for comp.lang.perl so I'm exiting this
discussion here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top