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

Why isn't my Page Link not working correctly?

Status
Not open for further replies.

woo545

Programmer
Jan 13, 2004
6
US
AGGGGGGGGHHHHH! Ok, now that I got that out my system...

I'm fairly new working with both Adobe Acrobat and PS files.
I'm using Acrobat Distiller 5 to merge multiple files together. In one of these file (pg 0 - see "PDF Page Structure" below), I have multiple links to one of the other pages. The PS files below are created by printing to file using the HP Deskjet 1600CM/PS printer driver. In the section "The Code" you will see some of the pdfMark commands that I am using to link to the individual pages. Page 6 and Page 8 links correctly, but Page 7 links to Page 6. This problem doesn't occur if I create the PDF in any format other than "Screen", but Screen is the only view that makes the Landscape pages appear upright, right?

Why doesn't the link work correctly?

OR

Does anyone have any suggestions to work around this problem? If so, do have a sample?

I'm thinking that I might be able to use a bookmark, I just haven't figured out how.



* ******************************
* PDF PAGE STRUCTURE
* ******************************
Pg 0: Word file, Portrait
Pg 1: Excel Worksheet(w/Chart), Portait
Pg 2: Excel Chart, Landscape
Pg 3: Excel Chart, Landscape
Pg 4 & 5: Excel Worksheet(w/charts), Portait
Pg 6: Excel Chart, Landscape
Pg 7: Word Document, Portrait
Pg 8: Excel Chart


* ******************************
* PS LINK CODE:
* ******************************
[/Rect [ 467 1504 1121 1472 ]
/Border [ 0 0 2 ]
/Color [ .7 0 0]
/Page 6
/View [ /FitH 5]
/Subtype /Link
/ANN pdfmark

.828 0.895 0.039 0 3 scol 467 1504 M (Primary, Secondary and Tertiary)[28 17 13 38 22 18 24 13 13 28 22 22 26 24 25 22 18 23 13 23 24 25 13 31 22 16 15 13 22 18 0]xS
/DeviceRGB dup setcolorspace /colspABC exch def
: N 467 1509 654 2 rp C
/DeviceCMYK dup setcolorspace /colspABC exch def
0.828 0.895 0.039 0 3 scol L ; /DeviceCMYK dup setcolorspace /colspABC exch def
0.859 0.82 0.762 0.594 3 scol 1121 1504 M ( )S
317 1586 M ( )S

[/Rect [ 467 1586 588 1554 ]
/Border [ 0 0 2 ]
/Color [ .7 0 0]
/Page 7
/View [ /FitH 5]
/Subtype /Link
/ANN pdfmark

.828 0.895 0.039 0 3 scol 467 1586 M (Detail)[36 22 15 22 13 0]xS
/DeviceRGB dup setcolorspace /colspABC exch def
: N 467 1591 121 2 rp C
/DeviceCMYK dup setcolorspace /colspABC exch def
0.828 0.895 0.039 0 3 scol L ; /DeviceCMYK dup setcolorspace /colspABC exch def
0.859 0.82 0.762 0.594 3 scol 588 1586 M ( )S
317 1669 M ( )S

[/Rect [ 467 1669 855 1637 ]
/Border [ 0 0 2 ]
/Color [ .7 0 0]
/Page 8
/View [ /FitH 5]
/Subtype /Link
/ANN pdfmark

* ******************************
* VB create PDF CODE:
* ******************************

hr = m_oAdbDstlr.FileToPDF(sSrcFile, sDstFile, "Screen")
 
The title is demonstration of my great English. "Why isn't...not working..." Geez.
 
This'll take a little while to work out, so bear with me. One thing to note immediately is that the Distiller Job Option "screen" refers to the resolution, really, not orientation. So you're not limited to using "Screen".



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
It looks like your pdfmark structure is correct. When you say you are merging several PostScript files together, how exactly are you doing that? Where in the final, merged PostScript are you putting your pdfmark operators?

The structure I would use would be a single PostScript program that 1) "runs" the other PostScript programs and 2) intersperses the pdfmark dictionaries where needed.

Code:
%!PS
save
  /showpage {} def
  /setpagedevice /pop load def

  (page0) run

  [/Rect [ 467 1504 1121 1472 ]
  /Border [ 0 0 2 ]
  /Color [ .7 0 0]
  /Page 6
  /View [ /FitH 5] 
  /Subtype /Link
  /ANN pdfmark

  [/Rect [ 467 1586 588 1554 ]
  /Border [ 0 0 2 ]
  /Color [ .7 0 0]
  /Page 7
  /View [ /FitH 5] 
  /Subtype /Link
  /ANN pdfmark

  %and so on 
restore 

save (page1) run restore
save (page2) run restore
save (page3) run restore
% and so on

Something like that.

Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
******************************

tgreer...thanks for the effort, but I found the solution.

******************************

It's one of those things, where after troubleshooting for a long time (2+ days), I finally gave up and posted my question. After posting the question I closed IE. At this time, I noticed that I had the PDFMark documentation open. It was refering to the /View section. After briefly reading this, I started played with the /Fit options. I changed the setting from /FitH 5 to /Fit. When I rebuilt the PDF and clicked on the problem link, I found that the page was showing, but at the bottom of the screen. So, I removed the /View option all together. Here's what I found out:

1. Despite what I read in the documentation earlier, I was treating the pages as zero based. The reason, is that it gave the appearance that it was working, because of the /View.

2. Examples in the Help PDFs are just that, examples... I was using the example verbatim as my outline for my code.

I do have another question

How do you determine your dimensions of your rectangle for your link?
In the example Below, say I want to draw the rectangle around "Test".

F /F0 0 /256 T /Helvetica mF
/F0S2A F0 [42 0 0 -42 0 0 ] mFS
F0S2A Ji
317 280 M (Test)[26 23 20 0]xS
398 280 M ( )S
LH

I was able to determine the following:

Xll = 317
Yll = 280
xur = 398

If the above is correct, then what is the best way to figure out yur?



ALSO, you mentioned something about my comment about the "Screen" option and landscape. What exactly did you mean? Basically I want to view the landscape document on the PC screen, right side up. Is there another way?

*** Just saw your most recent post...
Are you saying that I can modify my (what I call) binding file to do all of the links?

Meaning that I can add the code that you had into the file that includes this:

/prun { /mysave save def % Performs a save before running the PS file
dup = flush % Shows name of PS file being run
RunFile % Calls built in Distiller procedure
clear cleardictstack % Cleans up after PS file
mysave restore % Restores save level
} def

(C:/Data/Intro.PS) prun
(C:/Data/Report1.PS) prun
(C:/Data/Report2.PS) prun
(C:/Data/Report3.PS) prun
(C:/Data/Report4.PS) prun
(C:/Data/Report5.PS) prun
(C:/Data/Report6.PS) prun
(C:/Data/Report7.PS) prun



 
1. Swell!

2. Determine rectangle.

The best way is to use "stringwidth", but that might not work for you. I say that because of "xS", which is probably a redefinition of "xshow". The character displacements are calculated based on the numeric values in the array. You can redefine xS to stick the final currentpoint into a dictinary for you. This gives you the final "x" value.

Calculating the y-value is more difficult. I have two suggestions:

a. Calculate a "height" based on current pointsize. Looking at your code snippet, I would guess that "mFS" is a redefinition of makefont/scalefont, and that your pointsize is 42. Just a guess. Again, you can modify that procedure to save out the pointsize to something you can grab later. I would make your height 1.2x the pointsize.

b. Use "pathbbox flattenpath" prior to "show" to get your dimensions. Again, you'll need to add code to the "xS" proc to do that. This will be more accurate, but is more computationally intensive.

3. Screen Option.

Just look through the Job Options. "Screen" is just a collection of compression and resolution settings appropriate to screen display. "Screen" doesn't automatically rotate your pages to "fit" on a monitor. It's fine, if you're satisfied with the quality. I was just saying that "screen" doesn't mean what you think it means. No Big Deal.

4. Binding File.

Yep. It's just a PostScript file. You can put your pdfmark code in it. Run your first page, but first redefine showpage to a no-op so that your pdfmark code ends up ON THAT PAGE. After the "(page) run" (don't use the prun proc here), stick in your pdfmark code. Then do a restore, and a showpage, then the rest of your pages.

This may not work for you, since you'll be hacking the page1 code anyway to get your rectangle values.

I've done lots of this stuff. I'll modify the procs to scan for certain strings (URLS) and pdfmark them on-the-fly. Make the procs do the work.

Good luck!





Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top