我想在PDF文档中创建PushButton并设置Action(GoToLocalPage):
PushButton:=New PushbuttonField(stamper.writer, New Rectangle(300, 300,330,330),"Text");
PushButton.Image:=img;
PushButton.ProportionalIcon:=True;
PushButton.Layout:=PushbuttonField.LAYOUT_ICON_ONLY;
PushButton.Field.Action:=PdfAction.GotoLocalPage(2, New PdfDestination(PdfDestination.FIT), stamper.Writer);
stamper.AddAnnotation(PushButton.Field,5);
因此,该行动无效。我做错了什么?
在所有写的例子中:PushButton.GetFields()。SetAction(...)。但是在iTextSharp 5.3.3方法中,GetFields不存在......
我试过了:
Action:=PdfAction.GotoLocalPage(2, New PdfDestination(PdfDestination.FIT), stamper.Writer);
PushButton.Field.SetAdditionalActions(iTextSharp.text.pdf.PdfName.D, Action);
但它也不起作用..
答案 0 :(得分:1)
我就是这样做的:
PdfAnnotation pushbuttonAnn = PushButton.Field;
pushbuttonAnn.Action:=PdfAction.GotoLocalPage(2, New PdfDestination PdfDestination.FIT), stamper.Writer);
stamper.AddAnnotation(pushbuttonAnn,5);