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
 
However, by removing the modulus it works:-

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

$v = 28;

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 "/Helvetica-Bold 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 "/Helvetica-Bold 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 "/Helvetica findfont 8 scalefont setfont\n";
    print "($store) show\n\n";
      
  }
  
  print "\n\n";
  $v-=3;

}

print "showpage";

close PS_OUT;

[blue]__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 0001
January 2005
Jon Doh
Store 0002
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 0010
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
John Smith
Store 0015
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Duncan Dude
Store 5555
January 2005[/blue]

and i have altered the X & Y stuff... please forgive me - i was trying to cope with remembering Postscript at the same time!


Kind Regards
Duncan
 
Yep, that looks fine to me.
It is right at the top of the page so it doesn't allow for the header though but at least it's all on the page now.


Trojan.
 
change the $v=28 at the top of the script - this is 28 cm at present :)

(the negative offset is on line 49)


Kind Regards
Duncan
 
i guess this is about as far as i need go? it should be pretty obvious what is able to be tweaked to adjust size, positioning, etc.

i hope this post was useful!?

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__
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 0001
January 2005
Jon Doh
Store 0002
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 0010
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
John Smith
Store 0015
January 2005
Jon Doh
Store 5555
January 2005
Jon Doh
Store 5555
January 2005
Duncan Dude
Store 5555
January 2005[/blue]


Kind Regards
Duncan
 
And thank you for your patience & help - did you enjoy mucking about with Postscript? If you did i might have some interesting examples for you...


Kind Regards
Duncan
 
Yep, I did.
And it's not the first time I've used postscript.
I've cand crafted a little from time to time but, more often, created a page with a postscript printer driver (writing to file) and then used perl to alter and populate the page.
In linux we have ps2pdf that you can then use to create pdf output from the postscript so it can be a very useful medium.


Trojan.
 
Man, u guys are something else~! Great job! You must work for a big software company. I am working/learning the ActivePerl program and playing around w/ it. Will post with my progress, Ive learned so much!
Steve
 
I've never met Duncs.
He lives 150 miles away from me.
But he's good at this kinda stuff! ;-)


Trojan.
 
Very kind words Trojan! Thank you.

Hi Steve
Thanks for your comments. I am VERY happy that we have got you into Perl - & that you seem to be having fun. If this gets you then you will never stop. Programming is addictive - the forte of problem-solvers. You start of with a blank screen... & a few minutes, hours, days or weeks later - you have what was just an idea in your mind as a working program (script).

Trojan's words were very kind, however, i can only polish his shoes in the Perl department.

The best of luck with the programming!

P.S. Did you manage to run my last script with your ActivePerl?


Kind Regards
Duncan
 
attachment.php

Nope, give me a little time to figure this thing out. You guys post too fast!
 
How come Perl doesn't have a graphic interface? Where do I click to imput script?


attachment.php
 
Hi Steve

Thank you for your picture! Superb!

I guess if you name any script yourscript[red].pl[/red] - then the extension will map to Perl. You should then be able to double-click the script... let us know how you get on


Kind Regards
Duncan
 
I changed the ex to .pl "JanuaryPlaque.pl" and Windows XP wont associate with Perl. Any other suggestions?

Steve
 
Curious. Are you sure it isn't actually named JanuaryPlaque.pl.exe ?

Sorry - have not really used PC's for many years... but we'll get there!

Better hope Trojan comes back :)


Kind Regards
Duncan
 
Yes,positive. Hope we can figure this out.

Steve
 
ok. how about running a DOS box (Start,Programs,Command Prompt - i think) & then navigating to the correct directory with your script in:-

cd path/to/your/script

then:-

perl JanuaryPlaque.pl


Kind Regards
Duncan
 
Duncs,
You forget that I'm a linux guy, not a windoze guy!
But I agree, initially run with a Dos prompt to prove that it works.
Once it does I suggest you use windoze help to see if you can arrange an association with the .pl extension.
Or, of course, you could ask the question in the perl forum or a windoze forum.

BTW: How do my shoes look? Nice and shiny?!! ;-)


Trojan.
 
I can't believe you guys dont use windows on a daily basis. Ofcourse Im sure you have seen window and been on a few PCs with the OS loaded but just the fact you don't use it on a daily basis really blows my mind! Does Linux/Unix have a graphic interface or does it look like the "Matrix'? : )


Ok, here is a screen capture of my set-up. Whats with the error, any advice?
attachment.php
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top