Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > fontsize and/or space between lines

Reply
Thread Tools

fontsize and/or space between lines

 
 
Huub
Guest
Posts: n/a
 
      07-24-2006
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
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      07-24-2006
Huub wrote:
> 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

 
Reply With Quote
 
 
 
 
Huub
Guest
Posts: n/a
 
      07-24-2006
>
> *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.

>
>> If so, what should I look for (what is it called in English?) ?

>
> Line Spacing?


That could be it.

Thank you for helping out,

Huub
 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      07-25-2006
Huub wrote:
>>
>> *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.
>
>>
>>> If so, what should I look for (what is it called in English?) ?

>>
>>
>> Line Spacing?

>
>
> 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?
 
Reply With Quote
 
Huub
Guest
Posts: n/a
 
      07-25-2006
>>
>
> 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.
 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      07-25-2006
Huub wrote:
>>>

>>
>> 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?
>


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
"";
}
 
Reply With Quote
 
Huub
Guest
Posts: n/a
 
      07-25-2006
> 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.
 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      07-25-2006
Huub wrote:
>> 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?


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
lots of clicking around HP's web site. <later> The Wikipedia article
referred to below has links to PCL technical reference manuals.

> 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...ugh_5_overview

This is now completely off-topic for comp.lang.perl so I'm exiting this
discussion here.
 
Reply With Quote
 
Huub
Guest
Posts: n/a
 
      07-25-2006
>
>
> This is now completely off-topic for comp.lang.perl so I'm exiting this
> discussion here.


You're right. Thank you for helping.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 6.3 How can I pull out lines between two patterns that are themselves on different lines? PerlFAQ Server Perl Misc 0 01-14-2011 05:00 AM
Why Python style guide (PEP-8) says 4 space indents instead of 8 space??? 8 space indents ever ok?? Christian Seberino Python 21 10-27-2003 04:20 PM
Re: Why Python style guide (PEP-8) says 4 space indents instead of8 space??? 8 space indents ever ok?? Ian Bicking Python 2 10-24-2003 11:15 AM
Re: Why Python style guide (PEP-8) says 4 space indents instead of8 space??? 8 space indents ever ok?? Ian Bicking Python 2 10-23-2003 07:07 AM
Stack space, global space, heap space Shuo Xiang C Programming 10 07-11-2003 07:30 PM



Advertisments