Adobe Acrobat Javascript setPageRotations 不旋转页面
Adobe Acrobat Javascript setPageRotations does not rotate page
我正在尝试使用操作向导通过 Adobe Acrobat Javascript API
的 setPageRotations
方法通过单击 execDialog
中的按钮来旋转活动 pdf。下面是我使用的 javascript
代码。
var dialogBox =
{
description:
{
elements:
[{
type: "static_text",
name: "Rotate",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtlf",
name: "Left",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtrt",
name: "Right",
alignment: "align_center",
},
{
type: "ok",
name: "Close",
item_id: "cdoc"
}]
},
commit: function(dialog)
{
app.alert("This script from action is working");
},
rtlf: function () // handler of the custom component by id name
{
this.setPageRotations(0,0,90);
},
rtrt: function () // handler of the custom component by id name
{
this.setPageRotations(0,0,270);
}
};
app.execDialog(dialogBox);
显示警报 "This script from action is working"。但它似乎没有像我在 setPageRotations
.
中提到的那样应用旋转
我们应该怎么做?
在对话框对象定义中,"this" 指的是对话框对象本身。您需要传递对 PDF 文档对象的引用,以便在对话框打开时对其执行操作。我添加到对话框描述末尾的代码定义了一个新函数,该函数在对话框对象中定义了一个 pdfDoc 属性 然后调用执行对话框。然后我可以调用该函数并传入对话框对象 和 PDF 文档对象。 在对象定义之外,"this"指的是PDF文档本身。另外,请注意按钮回调的变化。现在他们指的是 "this"(此对话框),但随后指的是 pdfDoc 属性,它由 doTheDialog() 设置为 PDF 文档本身。
var dialogBox =
{
description:
{
elements:
[{
type: "static_text",
name: "Rotate",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtlf",
name: "Left",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtrt",
name: "Right",
alignment: "align_center",
},
{
type: "ok",
name: "Close",
item_id: "cdoc"
}]
},
commit: function(dialog)
{
app.alert("This script from action is working");
},
rtlf: function () // handler of the custom component by id name
{
this.pdfDoc.setPageRotations(0,0,90);
},
rtrt: function () // handler of the custom component by id name
{
this.pdfDoc.setPageRotations(0,0,270);
}
};
function doTheDialog(dialog, pdfDoc) {
dialog.pdfDoc = pdfDoc;
var retVal = app.execDialog(dialog);
}
doTheDialog(dialogBox, this);
我正在尝试使用操作向导通过 Adobe Acrobat Javascript API
的 setPageRotations
方法通过单击 execDialog
中的按钮来旋转活动 pdf。下面是我使用的 javascript
代码。
var dialogBox =
{
description:
{
elements:
[{
type: "static_text",
name: "Rotate",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtlf",
name: "Left",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtrt",
name: "Right",
alignment: "align_center",
},
{
type: "ok",
name: "Close",
item_id: "cdoc"
}]
},
commit: function(dialog)
{
app.alert("This script from action is working");
},
rtlf: function () // handler of the custom component by id name
{
this.setPageRotations(0,0,90);
},
rtrt: function () // handler of the custom component by id name
{
this.setPageRotations(0,0,270);
}
};
app.execDialog(dialogBox);
显示警报 "This script from action is working"。但它似乎没有像我在 setPageRotations
.
我们应该怎么做?
在对话框对象定义中,"this" 指的是对话框对象本身。您需要传递对 PDF 文档对象的引用,以便在对话框打开时对其执行操作。我添加到对话框描述末尾的代码定义了一个新函数,该函数在对话框对象中定义了一个 pdfDoc 属性 然后调用执行对话框。然后我可以调用该函数并传入对话框对象 和 PDF 文档对象。 在对象定义之外,"this"指的是PDF文档本身。另外,请注意按钮回调的变化。现在他们指的是 "this"(此对话框),但随后指的是 pdfDoc 属性,它由 doTheDialog() 设置为 PDF 文档本身。
var dialogBox =
{
description:
{
elements:
[{
type: "static_text",
name: "Rotate",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtlf",
name: "Left",
alignment: "align_center",
},
{
type: "button", // add a custom button
item_id: "rtrt",
name: "Right",
alignment: "align_center",
},
{
type: "ok",
name: "Close",
item_id: "cdoc"
}]
},
commit: function(dialog)
{
app.alert("This script from action is working");
},
rtlf: function () // handler of the custom component by id name
{
this.pdfDoc.setPageRotations(0,0,90);
},
rtrt: function () // handler of the custom component by id name
{
this.pdfDoc.setPageRotations(0,0,270);
}
};
function doTheDialog(dialog, pdfDoc) {
dialog.pdfDoc = pdfDoc;
var retVal = app.execDialog(dialog);
}
doTheDialog(dialogBox, this);