• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
16

HyperlinkPageDestination with viewBounds

Explorer ,
Jan 02, 2024 Jan 02, 2024

Copy link to clipboard

Copied

Hi,

 

Can anyone guide me how to use "HyperlinkPageDestination" with viewBounds property?

Sumit_KGL_0-1704208058088.png

Here is my code snippet.

 

var text = textArray[i];
var parent = text.parentTextFrames[0];
var bounds = parent.geometricBounds;
var id = text.contents;
var page = parent.parentPage;
try {
	var ref = xrefs[id];
	if (ref == undefined) continue;
	var idDestination = myDoc.hyperlinkPageDestinations.add(page);
	idDestination.viewSetting = HyperlinkDestinationPageSetting.FIT_WIDTH;
	idDestination.viewBounds = bounds;
	for (var j = 0; j < ref.length; j++) {
		var sourceText = ref[j];
		if (sourceText.index != text.index)
			createHyperlink(myDoc, sourceText, idDestination, hyperlinkColor);
	}

}
catch (e) {
}

 

Sumit

TOPICS
Bug , Experiment , Performance , Scripting

Views

214

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 03, 2024 Jan 03, 2024

but these options will work inside indesign. Need to update zoom option inside Acrobat.

 

They work in InDesign and in Acrobat.

 

I don't think that the viewBounds property does very much. To see that you need to do some troubleshooting. Use the following script to create a test document:

 

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

d = app.documents.add();

views = {
  width: HyperlinkDestinationPageSetting.FIT_WIDTH,
  height: HyperlinkDestinationPageSetting.FIT_HEIGHT
...

Votes

Translate

Translate
Community Expert ,
Jan 02, 2024 Jan 02, 2024

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

Thank you @Eugene Tyson, but these options will work inside indesign. Need to update zoom option inside Acrobat.

 

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

Oh I thought it was related to InDesign as you posted in the InDesign forum. 
I don't know how to do it in Acrobat... 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2024 Jan 03, 2024

Copy link to clipboard

Copied

but these options will work inside indesign. Need to update zoom option inside Acrobat.

 

They work in InDesign and in Acrobat.

 

I don't think that the viewBounds property does very much. To see that you need to do some troubleshooting. Use the following script to create a test document:

 

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

d = app.documents.add();

views = {
  width: HyperlinkDestinationPageSetting.FIT_WIDTH,
  height: HyperlinkDestinationPageSetting.FIT_HEIGHT,
  window: HyperlinkDestinationPageSetting.FIT_WINDOW,
  view: HyperlinkDestinationPageSetting.FIT_VIEW,
}

gb = [300, 200, 320, 360];

for (i in views) {
  gb[0] += 40;
  gb[2] += 40;
  frame = d.textFrames.add ({
    geometricBounds: gb,
    contents: i,
  });
  dest = d.hyperlinkPageDestinations.add (d.pages[0], {name: i});
    dest.viewSetting = views[i];
  source = d.hyperlinkTextSources.add (frame.words[0]);
  d.hyperlinks.add(source, dest, {name: i});
}

 

The script creates a new document, places four text frames, adds the name of a zoom setting, and creates a page destination for each setting to the first page and a hyperlink for each setting. That produces this:

 

PeterKahrel_0-1704294917878.png

Click each hyperlink to check that they work. Then export the document to PDF. In there, you see the same behaviour. Naturally, sometimes height and view are the same (depending on the page size), but width should always show a different view. You can zoom in or out manually and click a link to see that (and howw) it works.

 

Now in InDesign change the document size to A3 (or bigger) and move the four frames to the centre of the page. Click the hyperlinks again, then export to PDF again and check the behaiour of each link. A bit laborious but it's instructive.

 

Now to viewBounds. First check what their current values are. Run this script:

 

 

p = app.documents[0].hyperlinkPageDestinations;
for (i = 0; i < p.length; i++) {
  $.writeln (p[i].name);
  $.writeln (p[i].viewBounds.join('\r'));
}

 

which produces unexpected result: all viewbounds are the same:

 

 

width
-301.069518716577
-298.930481283422
301.069518716577
718.716577540107
height
-301.069518716577
-298.930481283422
301.069518716577
718.716577540107
window
-301.069518716577
-298.930481283422
301.069518716577
718.716577540107
view
-301.069518716577
-298.930481283422
301.069518716577
718.716577540107

 

 

Now change the viewBounds of e.g. the view hyperlink:

 

 

app.documents[0].hyperlinkPageDestinations.item('view').
   viewBounds = [100,100,300,300];

 

 

And click the iew hyperlink in the Hyperlinks panel. Nothing much happens. Then export to PDF. No difference.

My conclusion would be that the viewBounds property doesn't do anything and if it does, it can't be changed with any visible effect.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 04, 2024 Jan 04, 2024

Copy link to clipboard

Copied

LATEST

Yes! You are right, viewBounds property does not do anything. I am surprised why they given this property.

Also, I find the sample script provided by the Adobe and there is no sample for viewBounds.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines