%!PS % ACROBAT GALLEY SLAVE GALLERY.PSL % ================================ % by Don Lancaster % Copyright c 2002 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.5 % "Galley Slave" Acrobat PDF galleries offer a number of advantages over traditional % HTML. This tutorial file links you the needed tools to exploit same. % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. %%%%%%%%%%% links menu directory %%%%%%%%%%%% % This code locks pdfmark commands out of a PostScript printer. /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse % /surl "start url" marks the beginning of a text sequence to be urled. % It also paints the text blue... /surl {mark /blue cvx 0.33 /setgray cvx % change text to blue /currentpoint cvx % remember box start /urly /exch cvx /store cvx /urlx /exch cvx /store cvx ] cvx % complete deferred command printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def % /eurl "end url" unmarks the end of a text sequence and sets up % the pdfmark needed to define the Acrobat web link. /eurl {mark % start deferred proc exch % position url string % /black cvx 0 /setgray cvx % turn blue marker off % maintextcolor /setrgbcolor cvx % reset to main text color??? /aqua cvx /black cvx /makeurl cvx % defer call of url builder ] cvx % complete deferred proc printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } def % /makeurl generates the pdfmark, receiving a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /urlover 0.2 def % fraction of hot area over bounds /makeurl { /cururlname exch store % save the url string mark % start pdfmark currentfont /ScaleMatrix get 3 get /fsize exch store % guess height /Rect [ urlx fsize urlover mul sub % set box left x urly fsize urlover mul sub % set box left y currentpoint exch fsize urlover mul add exch fsize add ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def % /makeurlx generates the box specific pdfmark, receiving % a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /makeurlx { /cururlnamex exch store % save the url string mark % start pdfmark /Rect [ xpos % set box left x ypos 0.9 sub % set box left y xpos 2.8 add % box right x ypos 0.9 sub 2.8 add % box right y ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def /maintextcolor {0 0 0 } def % text link specific data -- use dictionary instead below /tinaja {(http://www.tinaja.com) eurl} def /cubic01 {(http://www.tinaja.com/cubic01.asp) eurl} def /hack62 {(http://www.tinaja.com/glib/hack62.pdf) eurl} def /post01 {(http://www.tinaja.com/post01.asp) eurl} def /increment {(http://www.tinaja.com/text/bezgen3.html) eurl} def /interpolate {(http://members.bellatlantic.net/~vze2vrva/design.html) eurl } def /info01 {(http://www.tinaja.com/info01.asp) eurl} def /bezmath {(http://www.tinaja.com/text/bezmath.html) eurl } def /table {(http://www.tinaja.com/psutils/imtable.psl) eurl } def /maildon {(mailto:don@tinaja.com) eurl} def % dictionary method << %% these are urls only... /adobe (http://www.adobe.com) /netscape (http://www.netscape.com) /gallypsl (http://www.tinaja.com/galley1.psl) /gallypdf (http://www.tinaja.com/galley1.pdf) /nutour (http://www.tinaja.com/bargains/nutour02.pdf) /nutoursource (http://www.tinaja.com/bargains/nutour02.psl) /bwhistle (http://www.tinaja.com/glib/bwhistle.pdf) /gonzo1 (http://www.tinaja.com/post01.asp#gonzo) /acrob01 (http://www.tinaja.com/acrob01.asp) /barg01 (http://www.tinaja.com/barg01.asp) /weblib01 (http://www.tinaja.com/weblib01.asp) /z1 (http://www.tinaja.com/bargains/thumb/albradz2.jpg) /z2 (http://www.tinaja.com/bargains/sbtesteq.asp) /z3 (http://www.tinaja.com/images/bargs/albrad02.jpg) /z4 (http://www.tinaja.com/bargains/thumb/tutenaz2.jpg) /z5 (http://www.tinaja.com/bargains/sbphone.asp) /z6 (http://www.tinaja.com/images/bargs/tutena02.jpg) /sourceme (http://www.tinaja.com/glib/gallery.psl) >> {mark exch /eurl cvx ] cvx def} forall %%%%%%%%%%%%%%%% New colorizer patches %%%%%%%%%%%%%%%%%% /boxgrays 0.899 def /grayshade boxgrays def /mastergray boxgrays def /staytint {0.33 setgray} def /staytint1 {0.25 setgray} def /showadgrays true def /red {0 settint} def /Zmacro {staytint /ypos ypos 2 add def 72 300 div setlinewidth xpos ypos moveto txtwide 0 rlineto stroke /ypos ypos -2 add def tintoff} def % hair rule /amacro {(zy0) stringmacro /ypos ypos ypara add def 0.33 setgray } def % start drop cap /bmacro {(iFy1) stringmacro /ypos ypos ypara add def black} def % finish drop cap % Gonzo character colorizer /blueon {mark /blue cvx 0.33 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /blueoff {mark /beige cvx 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton {mark 0.33 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1 {mark 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1b {mark beige cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1a {mark /aqua cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1p {mark /burple cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1r {mark /red cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1b {mark /beige cvx % try for beige after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tintoff {mark 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def %%%%%%%%%%%%%% COMPACT VERSION OF COLORIZER II %%%%%%%%%%%%%%%%%%%%%% /settint {dup /currenttint exch store 5.999 mul dup floor cvi /&cbar exch store dup floor sub /&cwt exch store [ {/setgray [ /dup cvx 0.3 &cwt 0.59 mul add /ge cvx [1 /exch cvx &cwt 0.59 mul 0.30 add /sub cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx ] cvx [ &cwt 0.59 mul 0.3 add /div cvx /dup cvx &cwt /mul cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub 0.3 mul add /ge cvx [1 &cwt sub 0.3 mul 0.59 add /sub cvx &cwt 0.3 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx /exch cvx 1 /exch cvx] cvx [1 &cwt sub 0.3 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 &cwt 0.11 mul add /ge cvx [&cwt 0.11 mul 0.59 add /sub cvx 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx 1 /exch cvx] cvx [0 /exch cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub mul 0.11 add /ge cvx [1 &cwt sub 0.59 mul 0.11 add /sub cvx &cwt 0.59 mul 0.30 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx 1] cvx [0 /exch cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.11 &cwt 0.30 mul add /ge cvx[&cwt 0.30 mul 0.11 add /sub cvx 1 &cwt sub 0.30 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx 1] cvx [ &cwt 0.30 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx /exch cvx 0 /exch cvx ] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} {/setgray [ /dup cvx 0.30 1 &cwt sub 0.11 mul add /ge cvx[ 1 /exch cvx 1 &cwt sub 0.11 mul 0.30 add /sub cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx ] cvx [ 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx 0 /exch cvx] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} ] &cbar get exec exec} bind def /beige {0.10 settint} def % examples of convenience operators /aqua {0.52 settint} def /blue {0.67 settint} def /lime {0.44 settint} def /burple {0.75 settint} def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def % guru % activate gonzo utilities 50 50 10 setgrid % create grid % 56 61 showgrid /setpagefonts { /cstretch 0.015 def /sstretch 0.015 def /font0 /StoneSans-Bold 1.6 gonzofont /font1 /StoneSans 0.95 gonzofont /font4 /StoneSans 0.85 gonzofont /font3 /StoneSans-Bold 0.85 gonzofont /font8 /StoneSans-Bold [0.65 0 0 0.65 0 0.4] gonzofont /txtwide 36 store /yinc 1.2 store /kern 0.1 store /pm 1.5 store /tabs [7 -2] store aqua 0.33 setgray font1 black font2 /amacro { mark /aqua cvx 0.33 /setgray cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch } def /bmacro { mark /black cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch } def /shiftin {xpos /xposhold exch store /xpos xpos 3 add store} def /shiftout {/xpos xposhold store} def /texttop 51 store /textleft 3 store } def setpagefonts % -2 50.5 (optional header here \274) cl aqua 0.33 setgray font0 20 47.3 0.7 add ("Galley Slave") cc 20 45.3 0.7 add (Acrobat PDF Galleries) cc black font2 textleft 43 (|3Don Lancaster Synergetics, Box 809, Thatcher, AZ 85552 |/surl http://www.tinaja.com|/tinaja |/surl don@tinaja.com|/maildon (928) 428-4073 |h |a|0T|1|b|khose "galleries" and other |4HTML|1 photomenu "thumbnail collections" on the web are really popular these days. Giving viewers a quick set of your products or other snapshots they can zoom in on for more detail. |h Sadly, most of these suffer from grievous flaws. They are fairly hard to write and even harder to update. They severely limit your control of exactly what your end viewer will see. They are often slow loading. But worst of all, these often involve dozens to hundreds of fragmented file transfers. Giving your |4ISP|1 fits, clogging up the web, and slowing down your user. |h |/surl |3Adobe Acrobat PDF|1|/adobe offers some interesting alternatives to the classic |4HTML|1 galleries with a number of compelling advantages. A demo sampler of what you can do with Acrobat Galleries appears as our |/surl |3Bargain Guided Tour|1|/nutour . |h Key points are that |/tinton1 |3this is a single loading file!|1|/tintoff Thanks to Acrobat's |/surl |3byte range|/bwhistle |/surl retrival|1|/bwhistle , the file can be quickly viewed well before all images fully background load. You get two (or more) clickable areas per thumbnail, one for more printed info, and one to magnify the image for closer viewing. The code is data base driven for easy updates and changes. All the regular text urls look and behave in expected ways. Arrows and scroll bars provide fast nav. And your last page will automatically handle any partial image counts. |h Example sourcecode is |/surl |3found here|1|/nutoursource . This "Galley Slave" demo starts off with a |/surl |3PostScript|1|/post01 program using my |/surl |3Gonzo Utilities|1|/gonzo1 you view and alter in your favorite editor or word processor. You then distill your customized file by using |/surl |3Adobe|/adobe |/surl Acrobat|1|/adobe or GhostScript to generate a |4.PDF|1 file. The |4.PDF|1 file is then sent to your website at your |4ISP|1. The usual free |/surl |3Acrobat Reader|1|/adobe is needed by your end user. |h You first create a simple data base of each thumbnail's source file plus its text description, linking url names, image sizes, and any optional id comments. This can be either external or internal to your program. Because PostScript is a general purpose computing language, you could optionally teach a fancier version to read virtually any format data base written in any language. ) cl black beige 0.35 setgray 21 -2.5 (|3\320|j1|j\320) cc aqua 0 57 mt line1 40 r % temp align showpage %% start page two 50 50 10 setgrid % create grid setpagefonts textleft texttop (|1Here is one possible example of the data textfile format. This file consists of an array of arrays of text data\274 |3|/shiftin |h|/burple |/staytint1 /galdata [ |h [ % data for the first thumbnail (|jhost source filename for the first thumbnail image|j) (|jweb url for link to the first full image|j) (|jweb url for link to the first text description|j) INTEGER value for horizontal number of pixels in the thumbnail INTEGER value for vertical number of pixels in the thumbnail ] . . . . . . . . [ % data for the last thumbnail (|jhost source filename for the last thumbnail image|j) (|jweb url for link to the last full image|j) (|jweb url for link to the last text description|j) INTEGER value for horizontal number of pixels in the thumbnail INTEGER value for vertical number of pixels in the thumbnail ] ] def |h|/shiftout |/black |1Or, using some actual data\274 |3|/shiftin |h|/burple |/staytint1 /galdata [ |h [ % location A.0 |/surl (|jalbradz2.jpg|j)|/z1 |/surl (|jsbtesteq.asp|j)|/z2 |/surl (|jalbrad02.jpg|j)|/z3 (Allen-Bradley SLC-100\\\\nPLC Trainer & Programmer) 125 113 ] ....... [ % location Z.8 |/surl (|jtutenaz2.jpg|j)|/z4 |/surl (|jsbphone.asp|j)|/z5 |/surl (|jtutena02.jpg|j)|/z6 (Internet over\\\\nlive voice phone lines!) 116 125 ] ] def |h|/shiftout |/aqua |/black |1Our example sourcecode uses a slightly more complex data format that is page conditional. This requires |/tinton1 |3/galdata|1|/tintoff to defer its execution till run time. Note that the thumb images |/tinton1 |3must|1|/tintoff be locally available during distill time.|1 ) cl black beige 0.35 setgray 21 -2.5 (|3-|j2|j-) cc aqua 0 57 mt line1 40 r % temp align showpage %% start page three 50 50 10 setgrid % create grid setpagefonts /tabs [17.5 ] store textleft texttop (|1The |/tinton1 |3image|1|/tintoff operator is |/tinton1 |3very|1|/tintoff fussy about getting its pixel counts exactly right. If you get a torn or smeared image, check this detail. Thumbnail images are best used 1:1 as larger sizes will ridiculously increase your final PDF file sizes and download times. |h |1External versus internal data can be selected by commenting or uncommenting a line such as\274 |3|/shiftin |h|/burple |/staytint1 % (|jC:\\\\\\\\WINDOWS\\\\\\\\Desktop\\\\\\\\tours\\\\\\\\newtour\\\\\\\\galdat01.txt|j) run |h|/shiftout |/aqua |/black |1Suitable code is next generated to provide background art, text and linking and to create the individual gallery boxes in the correct position on the correct page. Dozens of predefined variables are used to control appearance and sizes. These are easily customized. |h |1One of the trickier parts of the code involves converting multiple |4JPEG|1 files into combined |4PS|1 images. This can get done by the PostScript |/tinton1 |3image|1|/tintoff operator, preceded by a |/tinton1 |3DCTDecode|1|/tintoff filter. Here is some example code\274 |3|/shiftin |h|/burple |/staytint1 /imfile imfilename (r) file store |t % establish input JPEG read file |h /Data {imfile /DCTDecode filter} store |t % define a data source |h << |t % start image dictionary /ImageType 1 |t % always one /Width curimagewidth |t % JPEG width in pixels /Height curimageheight |t % JPEG height in pixels /ImageMatrix [ curimagewidth |t % scale and position 0 0 curimageheight neg 0 curimageheight ] /DataSource Data |t % proc to get filtered JPEG /BitsPerComponent 8 |t % color resolution /Decode [|j0 1 0 1 0 1|j] |t % per red book 4.10 >> |t % close image dictionary |h image |t % call the image operator |h|/shiftout |/aqua |/black |1This code is repeatedly called every time a |4JPEG|1 image is to get inserted into the to-be-distilled |/surl |3PostScript|1|/post01 code. Note that this |/tinton1 |3only|1|/tintoff works with |4.JPG|1 or |4.JPEG|1 files. |h Unlike a |4HTML|1 gallery, all of the images are |/tinton1 |3internally|1|/tintoff delivered inside a single file. Early images may be viewed immediately while the others invisibly download as a background task. |h |1A second concern involves creating mouseover links in Acrobat files. This gets done following the |/tinton1 |3ANN|1|/tintoff annotation proc of PostScript's |/tinton1 |3pdfmark|1|/tintoff operator. Details are in Adobe Tech Note |4#5150|1. And otherwise known as their freebie |3|/surl pdfmark|/adobe |/surl Reference Manual|1|/adobe . |h Here is some typical url linking code\274 ) cl black beige 0.35 setgray 21 -2.5 (|3-|j2|j-) cc aqua 0 57 mt line1 40 r % temp align showpage %% start page four 50 50 10 setgrid % create grid setpagefonts /tabs [17.5 ] store textleft texttop (|3|/shiftin |h|/burple |/staytint1 mark |t % begin a pdfmark data array |h /Rect [|j0 thumbimageheight thumbboxwidth totalthumbheight|j] |t % llx lly urx ury mouseover /Border [|j0 0 0|j] |t % no color /Color [|j0.7 0 0|j] |t % not used /Action <> |t % link url from input data /Subtype /Link |t % desired pdfmark action /ANN |t % annotation type pdfmark |t % call pdf operator |h |/shiftout |/aqua |/black |1As shown, the program automatically generates page after page of thumbnails. As many as you want for your chosen rows and columns per page. The last page can be partial or full, depending on how the math works out. |h There are some tradeoffs. Certain versions of |/surl |3Netscape|1|/netscape will blow up if you try to access a magnified |4.JPG|1 file from inside of a |4.PDF|1 file. The workarounds are either to ignore all |417|1 remaining NetScape users or to put your linked images inside |4.HTML|1 shell containers. |h |4IE|1 Internet Exploder also has a curious bug: If you link on an inner page of a |4.PDF|1 file, it often will return you to the first page rather than your chosen one. Use of the |4.PDF|1 nav arrows and scrolling minimizes this annoyance. |h One small detail: You'll normally want your gallery pages to open at 100% percent magnification with a resized window. Otherwise, your thumbnails might distort. To do this, you get into Acrobat. Then select |/tinton1 |3File --> Document Info --> |/tinton1 Open --> 100% magnification|1|/tintoff and |/tinton1 |3Resize to Page|1|/tintoff . Then do a |/tinton1 |3Save As|1|/tintoff . |h Additional details on these concepts are found in the |/surl |3Acrobat|1|/acrob01 , |/surl |3PostScript|1|/post01 , and |/surl |3Webmastering|1|/weblib01 library pages of my |/surl |3Guru's Lair|1|/tinaja website. |h Sourcecode for this document is |/surl |3Found Here|1|/sourceme . |h |1Additional consulting services available per |/surl |3www.tinaja.com/info01.asp|1|/info01 . ) cl black beige 0.35 setgray 21 -2.5 (|3-|j4|j-) cc aqua 0 57 mt line1 40 r % temp align showpage %%%%%%%%%%%%%%%%%%%% % EOF