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
 
Just looked at my .PS in notepad. My dada is not there, some how it didnt transfer from the .pl to .ps. Im studying it somemore.
 
I think it's the modulus 3 (%3) bit that gives the problem - i had the same trouble so i posted a fixed version later on - i should have made it more obvious

Code:
[b]#!/usr/bin/perl[/b]

$v = 25; # this is the top-most (start) position in centimetres
         # [ global change to inches can be effected by altering /cm declaration ]

  $typeface_big = 'Times-Bold';
$typeface_small = 'Helvetica';

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

select PS_OUT;

chomp (@data = <DATA>);

print <<PREAMBLE;
%!PS

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

/cm {28.3464567 mul} def

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

<< /PageSize [21 cm 29.7 cm] >> setpagedevice

PREAMBLE

for ($i=0; $i<=$#data; $i++) {

  for ($x=1; $x<=4; $x++) {
    
     $name = shift @data;
    $store = shift @data;
     $date = shift @data;
       
    ($firstname, $surname) = split(/ /, $name);
      
    print $x * 4 . " cm " . $v . " cm moveto\n";
    print "/$typeface_big findfont 16 scalefont setfont\n";
    print "($firstname) dup stringwidth pop 2 div neg 0 rmoveto show\n\n";
      
    print $x * 4 . " cm " . ($v - 0.75) . " cm moveto\n";
    print "/$typeface_big findfont 16 scalefont setfont\n";
    print "($surname) dup stringwidth pop 2 div neg 0 rmoveto show\n\n";
      
    print $x * 4 - 1.5 . " cm " . ($v - 1.25) . " cm moveto\n";
    print "/$typeface_small findfont 8 scalefont setfont\n";
    print "($store) show\n\n";
      
  }
  
  print "\n\n";
  $v-=3;

}

print "showpage";

close PS_OUT;

[blue]__DATA__[/blue]


Kind Regards
Duncan
 
Whats the difference between your code and Trojans code? Yours produces the right amout of text and Trojans goes up to 24. I like Trojans because it prints the text in proper format + it's easy to read. Whats the difference, whats making Trojans not produce more than 24? Please feel free to make it as obvious as possible. : )

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

my $v       = 25;   # Y starting position (counts down from here)
my $xfactor = -6;    # 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 = 12;
my $smallsize = 10;
my $spacing   = 0.4;

print <<PREAMBLE;
%!PS-Adobe-9.0
%\%DocumentMedia: Default 842 1000 0 () ()
%\%Orientation: Landscape


%---------- 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-=3;
  }
}
print "showpage\n";

close PS_OUT;

__DATA__

PS> Working with the fonts I've had nothing but trouble. 3hrs later and no luck with the list Trojan posted up for me. I really dont believe .PS likes different fonts. Ive tried, AvantGarde-Book NB, NewCenturySchlbk-Bold, Palatino-Bold , Times-Italic, Times-BoldItalic and no luck. Its like the .pl selected its own font. Even after substituting multiple variations. I am convinced Helvetica Times is the only font I can use.
 
PS> I’m also leaning/reading up about PHP, I want to make my own website that presents random text boxes and always has fresh content. I thought you guys could appreciate this. :) What’s your take on PHP? Can you write data driven sites in .PL? I guess your server would just have to have Perl installed on it, correct?! OMG, I think im learning.
 
Yes,yes and yes.
PHP is great for websites. I use it for simple pages but for complex stuff I tend to prefer Perl.
The big advantage of PHP is that it's embedded in the html directly whereas perl has to generate the html.
PHP can be more readable as a consequence but perl can generate many pages from one script.


Trojan.
 
Try this then:
Code:
#!/usr/bin/perl -w
use strict;

my $v       = 25;   # Y starting position (counts down from here)
my $xfactor = -6;    # 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 = 12;
my $smallsize = 10;
my $spacing   = 0.4;

print <<PREAMBLE;
%!PS-Adobe-9.0
%\%DocumentMedia: Default 842 1000 0 () ()
%\%Orientation: Landscape


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

/cm {28.3464567 mul} def

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


PREAMBLE

while(@data) {
    for (my $y=1; $y<=4; $y++) {
    
  my   $name = shift @data;
  my  $store = shift @data;
  my   $date = shift @data;
  last unless($date);
       
      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-=3;
}
print "showpage\n";

close PS_OUT;

__DATA__


Trojan.
 
Man, thats great to hear. There are so many PHP templates to use for sites. I found a pretty neat one... atleast I think thats a PHP template. Do you recomend any one there are so many.
 
Holy moly~! It worked what did you change. The ___DATA___ doesn’t even have to be in 4 increments. Gee that’s great! Thank you very much.
 
Oh, I see you changed,
Code:
for (my $x=0; $x<=$#data; $x++) {
  if ($x % 3 == 0) {
    for (my $y=1; $y<=4; $y++) {
to
Code:
while(@data) {
    for (my $y=1; $y<=4; $y++) {
 
Cool, I started a thread in PHP. Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top