Skip to main content
December 14, 2011
Question

Need PostScript Multi line Justify and centre command

  • December 14, 2011
  • 2 replies
  • 3518 views

Any one have PostScript Multi line Justify and centre command.

I have single line justify command ,

syntax:

SpaceMod

               (LineWidth – StringWidth)

          =           ----------------

               Spaces

LeftMargin Y moveto

SpaceMod 0 32 (Line of text here) widthshow

If u got PostScript Multi line Justify and centre command Reply as soon as possible.

Advance Thanks,

Jai

This topic has been closed for replies.

2 replies

December 16, 2011

Any one have PostScript Multi line Justify and centre command.

% JUSTIFICATION PROCEDURES

/glue { 2 copy length exch length add string dup 4 2 roll 2 index

0 3 index putinterval exch length exch putinterval } bind def

% word store

/TXT { tinydict /txt 3 -1 roll put } bind def () TXT

/startpoint { rm currentpoint pop sub } bind def

/measure { dsp txt stringwidth pop add startpoint 2 add gt } bind def

/howlong? { rejoin measure } def

/join { txt exch glue TXT } bind def

/jproc { dsp startpoint exch sub exch dup spacecount } bind def

/popzero { dup 0 eq { pop }{ div } ifelse } def

/justify { jproc 1 sub 3 2 roll exch popzero sw 4 3 roll w L } bind def

/nextline { txt justify () TXT join } bind def

/J { em dsc { howlong? { split jump nextline }{ join } ifelse } repeat txt n () TXT pop } bind def

(Same Paragraph....)J

Its not working any other methods or same working example for justify and center any one know

Replay as soon as poosible.

Advance Thanks Guys,

Jai

Multiline text Justification procedure

Mr__Horton
Inspiring
December 16, 2011

Arul,

Do you want to perform word wrapping on a single string (paragraph) of text?

You can do the word wrapping or line breaking within PostScript, as I have modified or written procedures to perform word wrapping, justificaton and auto-sizing to fit within arbitrary and/or segmented paths based on the PostScript Language Cookbook's section on Text on an Arbitrary Path.

In order to troubleshoot the PostScript code you posted, you will need to repost the complete procedure definitions as it appears that you are referring to user procedures not defined in your post.

Mr__Horton
Inspiring
December 14, 2011

You can use a loop to call your procedure for line justification:

put multiple lines of text on the stack and then you can process them individually within a loop while you increment or decrement the vertical position.

Your new procedure definitions would look like this:

/LineLeading 12 def %sets the line leading to 12 points

/Multiline {/CurrentLine exch def LeftMargin Y moveto

%% Insert your SpaceMod calculations here based on the CurrentLine string

     SpaceMod 0 32 CurrentLine widthshow

     /Y Y LineLeading sub def     %decrements the vertical position of the next line by the amount defined in LineLeading

def

%% Every time Multiline is placed on the stack it will process the string placed directly before it, so you just need to repeat Multiline as many times as the number of lines of text you want to set.

Participating Frequently
August 21, 2012

This is a bit late, I know, but just in case the problem is still a problem: the July 2003 Acumen Journal (#27) has a lengthy article on justifying text in PS; it shows how to center-, right-, and fully-justify text. You might also find the January 2006 issue (#41) useful: it shows how to take a string of text and print it as a paragraph, calculating the line breaks, etc.

Both issues are free for the downloading at www.acumentraining.com/acumenjournal.html.

Hope this is still useful for someone.

- John

-------

John Deubert

Acumen Training

PostScript & PDF consulting and training

www.acumentraining.com