-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathshowXY.js
188 lines (176 loc) · 8.91 KB
/
showXY.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//overlay ruler grid onto PDF doc
//Copyright 2014 djulien17@thejuliens.net. All rights reserved.
//to use: copy to Adobe scripts folder, then open PDF in Adobe Reader or Acrobat and click the XY grid button
//
//
//<AcroButtons name="showXY" version="2.0" "modified="7/18/2014 11:25:27" id="7:18:2014:11:25:27">
// This script was created by AcroButtons from Windjack Solutions, www.windjack.com
// Do not modify the code inbetween the AcroButtons Tags
// Moving or changing tag positions can compromise AcroButtons' ability to handle
// this file
// Place Extra-AcroButton Code in the following "Code Above" Section
//
//<CodeAbove>
function showXY()
{try{
// app.alert("show x,y");
var rect = this.getPageBox("Crop", this.pageNum); //visible portion
app.alert("rect = " + rect[0] + ", " + rect[1] + ", " + rect[2] + ", " + rect[3] + ", zoom " + this.zoom);
var w = rect[2] - rect[0], h = rect[1] - rect[3];
/*
var xy = this.getField("myXY");
if (!xy)
{
/ *var* / xy = this.addField("myXY", "text", this.pageNum, [0, h - 72, 0 + 72/2, h - 0]); //left, top, right, bottom (rel to bottom of page)
xy.borderStyle = border.d; //dashed
xy.display = display.visible;
xy.fillColor = ["RGB", 1, 0.9, 0.9]; //color.red;
}
xy.value = this.zoom + "%"; //"x, y"; //this.mouseX + "," + this.mouseY;
*/
var annos = this.getAnnots({ nPage: this.pageNum});
if (annos)
for (var i = 0; i < annos.length; ++i)
if ((annos[i].type == "Line") && annos[i].name.match(/^xygrid/)) annos[i].destroy(); //remove previous grid
var delta = 72; //1"
if (this.zoom > 500) delta /= 10;
// else if (this.zoom > 1000) delta /= 100;
// w * 100 / this.zoom;
var numcre = 0;
for (var x = 0; x < w; x += delta)
{
this.addAnnot({type: "Line", name: "xygridx" + x, page: this.pageNum, points: [[x, 0], [x, h]], contents: "x=" + round(x/72) + "\"", strokeColor: color.red});
++numcre;
}
for (var y = 0; y < h; y += delta)
{
this.addAnnot({type: "Line", name: "xygridy" + y, page: this.pageNum, points: [[0, h - y], [w, h - y]], contents: "y=" + round(y/72) + "\"", strokeColor: color.red});
++numcre;
}
app.alert(numcre + " lines drawn: w " + w + ", h " + h);
}catch (exc) { app.alert("EXC@" + exc.fileName + "." + exc.lineNumber + ": " + exc.message); }}
function round(val)
{
return Math.round(1000 * val)/1000;
}
//</CodeAbove>
//<JSCodeSnippet name="ImageData6">
var strData6showXY =
"FFFDFDFDFFFDFDFDFF797979FFF7F7F7FFFFFFFFFFBCBCBCFFF1F1F1FFC0C0C0FFFBFBFBFFFCFCFC" +
"FFFBFBFBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0C0C0FFFDFDFDFFFDFDFDFF797979" +
"FFF7F7F7FFFFFFFFFFBCBCBCFFF1F1F1FFC0C0C0FFFBFBFBFFFCFCFCFFFBFBFBFFFFFFFFFFFFFFFF" +
"FFFFFFFFFFFFFFFFFFFFFFFFFFC0C0C0FFFDFDFDFFFDFDFDFF010101FFFDFDFDFFFFFFFFFF7F7F7F" +
"FFFFFFFFFF7E7E7EFFFFFFFFFFF9F9F9FFFDFDFDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +
"FFC0C0C0FFFAFAFAFFFAFAFAFFF3F3F3FF7F7F7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FFFFFFFFFFFBFBFBFFFAFAFAFFFFFFFFFFFFFFFFFFFFFFFF" +
"FFFFFFFFFFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0" +
"FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0FFC0C0C0";
//</JSCodeSnippet>
// Icon Generic Stream Object
//<JSCodeSnippet name="ButtonIconDef">
var oIconshowXY = null;
if(app.viewerVersion < 7){
oIconshowXY = {count: 0, width: 17, height: 17,
read: function(nBytes){return strData6showXY.slice(this.count, this.count += nBytes);}};
}else{
oIconshowXY = {count: 0, width: 17, height: 17,
read: function(nBytes){return strData7showXY.slice(this.count, this.count += nBytes);}};
}
//</JSCodeSnippet>
//<JSCodeSnippet name="EventCode">
var DoCmdshowXY =
"// Enter your JavaScript code here\n" +
"// Or select one or more JavaScrippets\n" +
"showXY();"
//</JSCodeSnippet>
//<JSCodeSnippet name="ButtonObjDef">
var oButObjshowXY =
{cName: "showXY",
cExec: DoCmdshowXY,
cEnable: "event.rc = (app.doc != null)",
cMarked: "event.rc = false",
cTooltext: "show X,Y",
nPos: -1,
cLabel: "show X,Y"};
//</JSCodeSnippet>
if(oIconshowXY != null)
oButObjshowXY.oIcon = oIconshowXY;
try{app.removeToolButton("showXY");}catch(e){}
//<JSCodeSnippet name="TryAddBut">
try
{
//</JSCodeSnippet>
//<JSCodeSnippet name="AddButtonfn">
app.addToolButton(oButObjshowXY);
//</JSCodeSnippet>
if((event.type == "Doc") && (app.viewerVersion >= 7))
global["showXY_InDoc"] = "7:18:2014:11:25:27";
else
global["showXY"] = "7:18:2014:11:25:27";
//<JSCodeSnippet name="CatchAddBut">
}catch(e)
{
if((global.bReportNameCollision != null) && (global.bReportNameCollision == true))
{
var strError = 'Cannot Install AcroButton "oButObjshowXY"\n';
strError += ':' + e.fileName + '\n';
strError += 'Error: ' + e.name + '\n';
strError += e.message + '\n';
strError += 'Possible Name conflict';
app.alert(strError,0,0,'AcroButton Error');
}
}
//</JSCodeSnippet>
//</AcroButtons>