fontsize and/or space between lines

Discussion in 'Perl Misc' started by Huub, Jul 24, 2006.

  1. Huub

    Huub Guest

    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
    Huub, Jul 24, 2006
    #1
    1. Advertising

  2. Huub

    Paul Lalli Guest

    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
    Paul Lalli, Jul 24, 2006
    #2
    1. Advertising

  3. Huub

    Huub Guest

    >
    > *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
    Huub, Jul 24, 2006
    #3
  4. Huub

    Ian Wilson Guest

    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?
    Ian Wilson, Jul 25, 2006
    #4
  5. Huub

    Huub Guest

    >>
    >
    > 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.
    Huub, Jul 25, 2006
    #5
  6. Huub

    Ian Wilson Guest

    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
    "";
    }
    Ian Wilson, Jul 25, 2006
    #6
  7. Huub

    Huub Guest

    > 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.
    Huub, Jul 25, 2006
    #7
  8. Huub

    Ian Wilson Guest

    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_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.
    Ian Wilson, Jul 25, 2006
    #8
  9. Huub

    Huub Guest

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


    You're right. Thank you for helping.
    Huub, Jul 25, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,893
    Bryan Bullard
    Jul 11, 2003
  2. Christian Seberino
    Replies:
    21
    Views:
    1,655
    Stephen Horne
    Oct 27, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    1,010
    Steve Lamb
    Oct 23, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    723
    Michael Hudson
    Oct 24, 2003
  5. =?Utf-8?B?ZHc=?=
    Replies:
    5
    Views:
    1,121
    Alan Silver
    Jul 30, 2006
Loading...

Share This Page