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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto populating text fields. Text insert question. 2

Status
Not open for further replies.

stevef22

Technical User
Sep 20, 2005
83
US
Hello and good day to everyone, glad to be a part of this forum! I am going to stick around this site, GREAT INFORMATION!

My question is how do I insert text faster? I am bulding a plaque. Booooring yes I know but necessary. Anyone know how to set up "pre-determined" text fields that populate from an internal or external text? Right now I have to >duplicate layer>drag layer to new spot>enter in new text. It would be really neat if PS could populate from a file like web-site populate pages from other text files. If anyone knows a faster way to enter in this text then your are the PS GURU. Thanks again.
Steve
attachment.php
 
The line spacing should be equal.
equal.gif


What field would I edit to make bottom picture true?

Steve
 
Code:
#!/usr/bin/perl

$v = 20;

open (PS_OUT, "> plaque_names.ps");

select PS_OUT;

chomp (@data = <DATA>);
#my $fontname = "Helvetica";
my $fontname  = "Times";
my $largesize = 14;
my $smallsize = 10;

print <<PREAMBLE;
%!PS

%---------- Procedures ----------

/cm {28.3464567 mul} def

%---------- Postscript ----------


PREAMBLE

for ($x=0; $x<=$#data; $x++) {
  if ($x % 3 == 0) {
    for ($y=1; $y<=4; $y++) {

       $name = shift @data;
      $store = shift @data;
       $date = shift @data;

      ($firstname, $surname) = split(/ /, $name);

      print $y * 4 . " cm " . $v . " cm moveto\n";
      print "/$fontname-Bold findfont $largesize scalefont setfont\n";
#      print "($firstname) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      print "($name) dup stringwidth pop 2 div neg 0 rmoveto show\n";

#      print $y * 4 . " cm " . ($v - 0.75) . " cm moveto\n";
      print $y * 4 . " cm " . ($v - 0.5) . " cm moveto\n";
#      print "/$fontname-Bold findfont $largesize scalefont setfont\n";
      print "/$fontname-Bold findfont $smallsize scalefont setfont\n";
#      print "($surname) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      print "($store) dup stringwidth pop 2 div neg 0 rmoveto show\n";

#      print $y * 4 - 1.5 . " cm " . ($v - 1.25) . " cm moveto\n";
      print $y * 4 . " cm " . ($v - 1.0) . " cm moveto\n";
      print "/$fontname findfont $smallsize scalefont setfont\n";
#      print "($store) show\n";
      print "($date) dup stringwidth pop 2 div neg 0 rmoveto show\n";

    }
    print "\n";
    $v-=4;
  }
}
print "showpage\n";

close PS_OUT;

__DATA__
Leann Mckneand
Store 592
January 2005
Angela Schuessler
Store 0593
January 2005
Rufus Smith
Store 2220
January 2005
Sara Doss
Store 2310
January 2005
Laynette Mccray
Store 2319
January 2005
Atalissa Vaughn
Store 2394
January 2005
Alex Camarrillo
Store 0903
January 2005
Roseann Lyson
Store 1409
January 2005
Jon Weller
Store 2352
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
See if that's better.


Trojan.
 
Looking great! Man you know your stuff! Equal space=true, can you make the line spacing smaller like the second picture?
current.gif
 
what field would that be? Im looking at the code but it looks like my Algebra class! : (
 
LOL
I'll make it more obvious.
I created a number of variables at the top to allow you to change settings more easily.
I've just created a "spacings" setting that was at 0.5 and now is at 0.4 so you can play with it to get it right.
Also you can change the font family there too.

Let me know how you get on.

Code:
#!/usr/bin/perl

$v = 20;

open (PS_OUT, "> plaque_names.ps");

select PS_OUT;

chomp (@data = <DATA>);
#my $fontname = "Helvetica";
my $fontname  = "Times";
my $largesize = 14;
my $smallsize = 10;
my $spacing   = 0.4;

print <<PREAMBLE;
%!PS

%---------- Procedures ----------

/cm {28.3464567 mul} def

%---------- Postscript ----------


PREAMBLE

for ($x=0; $x<=$#data; $x++) {
  if ($x % 3 == 0) {
    for ($y=1; $y<=4; $y++) {
    
       $name = shift @data;
      $store = shift @data;
       $date = shift @data;
       
      ($firstname, $surname) = split(/ /, $name);
      
      print $y * 4 . " cm " . $v . " cm moveto\n";
      print "/$fontname-Bold findfont $largesize scalefont setfont\n";
#      print "($firstname) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      print "($name) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
#      print $y * 4 . " cm " . ($v - 0.75) . " cm moveto\n";
      print $y * 4 . " cm " . ($v - $spacing) . " cm moveto\n";
#      print "/$fontname-Bold findfont $largesize scalefont setfont\n";
      print "/$fontname-Bold findfont $smallsize scalefont setfont\n";
#      print "($surname) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      print "($store) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
#      print $y * 4 - 1.5 . " cm " . ($v - 1.25) . " cm moveto\n";
      print $y * 4 . " cm " . ($v - $spacing*2) . " cm moveto\n";
      print "/$fontname findfont $smallsize scalefont setfont\n";
#      print "($store) show\n";
      print "($date) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
    }
    print "\n";
    $v-=4;
  }
}
print "showpage\n";

close PS_OUT;

__DATA__
Leann Mckneand
Store 592
January 2005
Angela Schuessler
Store 0593
January 2005
Rufus Smith
Store 2220
January 2005
Sara Doss
Store 2310
January 2005
Laynette Mccray
Store 2319
January 2005
Atalissa Vaughn
Store 2394
January 2005
Alex Camarrillo
Store 0903
January 2005
Roseann Lyson
Store 1409
January 2005
Jon Weller
Store 2352
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005


Trojan.
 
Ah man, your the best! Im on it! will keep you posted, I think Duncs is sitting back laughing at me. : )
 
I left Duncs code in and commented it out as you can see.
If you are happy with my newer version you can cut all Duncs commented out code out. It does nothing. It's just a fallback in case you want to go back to something.

Did you understand all the new little variables I added to allow control over the layout and fonts?



Trojan.
 
There is no "dump".
I don't understand the question.
I have attached a copy here with all Duncs old code removed to make it more readable.
Code:
#!/usr/bin/perl

$v = 20;

open (PS_OUT, "> plaque_names.ps");

select PS_OUT;

chomp (@data = <DATA>);
#my $fontname = "Helvetica";
my $fontname  = "Times";
my $largesize = 14;
my $smallsize = 10;
my $spacing   = 0.4;

print <<PREAMBLE;
%!PS

%---------- Procedures ----------

/cm {28.3464567 mul} def

%---------- Postscript ----------


PREAMBLE

for ($x=0; $x<=$#data; $x++) {
  if ($x % 3 == 0) {
    for ($y=1; $y<=4; $y++) {
    
       $name = shift @data;
      $store = shift @data;
       $date = shift @data;
       
      ($firstname, $surname) = split(/ /, $name);
      
      print $y * 4 . " cm " . $v . " cm moveto\n";
      print "/$fontname-Bold findfont $largesize scalefont setfont\n";
      print "($name) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
      print $y * 4 . " cm " . ($v - $spacing) . " cm moveto\n";
      print "/$fontname-Bold findfont $smallsize scalefont setfont\n";
      print "($store) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
      print $y * 4 . " cm " . ($v - $spacing*2) . " cm moveto\n";
      print "/$fontname findfont $smallsize scalefont setfont\n";
      print "($date) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
    }
    print "\n";
    $v-=4;
  }
}
print "showpage\n";

close PS_OUT;

__DATA__
Leann Mckneand
Store 592
January 2005
Angela Schuessler
Store 0593
January 2005
Rufus Smith
Store 2220
January 2005
Sara Doss
Store 2310
January 2005
Laynette Mccray
Store 2319
January 2005
Atalissa Vaughn
Store 2394
January 2005
Alex Camarrillo
Store 0903
January 2005
Roseann Lyson
Store 1409
January 2005
Jon Weller
Store 2352
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005


Trojan.
 
I think I see what you mean now.
It's a warning.
$surname is not used anywhere in the code anymore.
It's created but not used so perl warns you in case it's a mistake.
Clever eh?
;-)


Trojan.
 
It was part of the old code notes, sorry i ment "# print "($surname) dup stringwidth pop 2 div neg 0 rmoveto show\n";"

What decides the cut off of the document size? I tried to expand the doc when I import to PS but that wont do it.
cut.gif
 
Let me see if I can sort that one out.
In the mean while, I've cleaned the code up to allow warnings and strict to work.
Here's the latest version:
Code:
#!/usr/bin/perl -w
use strict;

my $v = 20;

open (PS_OUT, "> plaque_names.ps");

select PS_OUT;

chomp (my @data = <DATA>);
#my $fontname = "Helvetica";
my $fontname  = "Times";
my $largesize = 14;
my $smallsize = 10;
my $spacing   = 0.4;

print <<PREAMBLE;
%!PS

%---------- Procedures ----------

/cm {28.3464567 mul} def

%---------- Postscript ----------


PREAMBLE

for (my $x=0; $x<=$#data; $x++) {
  if ($x % 3 == 0) {
    for (my $y=1; $y<=4; $y++) {
    
  my   $name = shift @data;
  my  $store = shift @data;
  my   $date = shift @data;
       
#      ($firstname, $surname) = split(/ /, $name);
      
      print $y * 4 . " cm " . $v . " cm moveto\n";
      print "/$fontname-Bold findfont $largesize scalefont setfont\n";
      print "($name) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
      print $y * 4 . " cm " . ($v - $spacing) . " cm moveto\n";
      print "/$fontname-Bold findfont $smallsize scalefont setfont\n";
      print "($store) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
      print $y * 4 . " cm " . ($v - $spacing*2) . " cm moveto\n";
      print "/$fontname findfont $smallsize scalefont setfont\n";
      print "($date) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
    }
    print "\n";
    $v-=4;
  }
}
print "showpage\n";

close PS_OUT;

__DATA__
Leann Mckneand
Store 592
January 2005
Angela Schuessler
Store 0593
January 2005
Rufus Smith
Store 2220
January 2005
Sara Doss
Store 2310
January 2005
Laynette Mccray
Store 2319
January 2005
Atalissa Vaughn
Store 2394
January 2005
Alex Camarrillo
Store 0903
January 2005
Roseann Lyson
Store 1409
January 2005
Jon Weller
Store 2352
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005


Trojan.
 
New version that sets the page size.
I tried Duncs earlier suggestion on this but it didn't work so I worked out my own (with a little help from google).

Code:
#!/usr/bin/perl -w
use strict;

my $v       = 36;   # Y starting position (counts down from here)
my $xfactor = 5;    # Panel spacing in x axis

open (PS_OUT, "> plaque_names.ps");

select PS_OUT;

chomp (my @data = <DATA>);
#my $fontname = "Helvetica";
my $fontname  = "Times";
my $largesize = 14;
my $smallsize = 10;
my $spacing   = 0.4;

print <<PREAMBLE;
%!PS-Adobe-3.0
%\%DocumentMedia: Default 842 1190 0 () ()
%\%Orientation: Portrait


%---------- Procedures ----------

/cm {28.3464567 mul} def

%---------- Postscript ----------


PREAMBLE

for (my $x=0; $x<=$#data; $x++) {
  if ($x % 3 == 0) {
    for (my $y=1; $y<=4; $y++) {
    
  my   $name = shift @data;
  my  $store = shift @data;
  my   $date = shift @data;
       
#      ($firstname, $surname) = split(/ /, $name);
      
      print $y * 4 . " cm " . $v . " cm moveto\n";
      print "/$fontname-Bold findfont $largesize scalefont setfont\n";
      print "($name) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
      print $y * 4 . " cm " . ($v - $spacing) . " cm moveto\n";
      print "/$fontname-Bold findfont $smallsize scalefont setfont\n";
      print "($store) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
      print $y * 4 . " cm " . ($v - $spacing*2) . " cm moveto\n";
      print "/$fontname findfont $smallsize scalefont setfont\n";
      print "($date) dup stringwidth pop 2 div neg 0 rmoveto show\n";
      
    }
    print "\n";
    $v-=4;
  }
}
print "showpage\n";

close PS_OUT;

__DATA__
Leann Mckneand
Store 592
January 2005
Angela Schuessler
Store 0593
January 2005
Rufus Smith
Store 2220
January 2005
Sara Doss
Store 2310
January 2005
Laynette Mccray
Store 2319
January 2005
Atalissa Vaughn
Store 2394
January 2005
Alex Camarrillo
Store 0903
January 2005
Roseann Lyson
Store 1409
January 2005
Jon Weller
Store 2352
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005


Trojan.
 
Trojan, Also the font isnt being reconiged when I chaged. Below "the green blocky test" is the type-face I would like. I changed it in my code as you can see but it doesnt reflect in my document? Can you figure this what does "Times" mean? Thanks very much.
tee.gif

tee2.gif
 
I believe that Postscript is very limited in font faces.
I'm just googling now to see what I can find out about it but I'm sure the font you're asking for will not exist.


Trojan.
 
Interesting, I will look on google for a solution as well. Doesnt the PostScript just look at your windows>fonts folder? Obviously not but one would think so.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top