按照此SO解决方案在此处通知客户PDF文档中的单击事件,如何在客户端使用this.myPDF.submitForm("localhost/Handler.ashx?r = 2"提交PDF时通知客户端)功能?
PDF文件在用户控件内创建,然后呈现为HTML对象:
string container = ("<object data='/myfile.pdf' type='application/pdf'></object>");
Run Code Online (Sandbox Code Playgroud)
附加到PDF的JS文件是这样完成的:
var webClient = new WebClient();
string htmlContent = webClient.DownloadString(fileurl + "pdf_script.js");
PdfAction action = PdfAction.JavaScript(htmlContnent, pdfstamper.Writer);
pdfstamper.Writer.SetOpenAction(action);
Run Code Online (Sandbox Code Playgroud)
和js文件的内容:
this.disclosed = true;
if (this.external && this.hostContainer) {
function onMessageFunc(stringArray) {
try {
this.myPDF.submitForm("http://localhost/Handler.ashx?EmpNo=12345" + "#FDF", false);
}
catch (e) {
}
}
function onErrorFunc(e) {
console.show();
console.println(e.toString());
}
try {
if (!this.hostContainer.messageHandler);
this.hostContainer.messageHandler = new Object();
this.hostContainer.messageHandler.myPDF = this;
this.hostContainer.messageHandler.onMessage = onMessageFunc;
this.hostContainer.messageHandler.onError = onErrorFunc;
this.hostContainer.messageHandler.onDisclose = function …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用acrofields填充PDF,我能够完美地添加字符串数据,但在向acrofields添加图像时遇到问题.这是我添加字符串数据的代码..
File f = new File("F:/Test/Agreement.pdf");
InputStream sourceTemplatePDFUrlStream = new BufferedInputStream(new FileInputStream(f));
File destinationFile = new File("F:/Test/ag1.pdf");
PdfReader reader = new PdfReader(sourceTemplatePDFUrlStream);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(
destinationFile));
AcroFields form = stamper.getAcroFields();
Image img = Image.getInstance("E:/signature/signature.png");
Set fields = form.getFields().keySet();
Hashtable val = new Hashtable();
val.put("name", "xxx" );
val.put("city_street_zip", "xxx"+" "+"xxx"+" "+"xxx");
val.put("chck_1", "Yes" );
val.put("chck_2", "No");
val.put("chck_3", "Yes" );
val.put("street_address", "xxx" );
val.put("account_num", "1234");
Enumeration enumeration = val.keys();
// iterate through Hashtable val keys Enumeration
while (enumeration.hasMoreElements()) …Run Code Online (Sandbox Code Playgroud) 我需要使用acrofields创建一个新的模板PDF文件.用数据库中的数据替换它们并将其作为PDF保存在新文件中.我发现它可以使用itextsharp实现.但我无法找到如何使用acrofields创建模板PDF文件?找到一个更好的方法!
我目前正在研究在pdf文档上应用和验证数字签名的工具.据我所知,pdf文档中的每个签名都适用于AcroFields的某个版本.每次用户更改某些输入(即填写pdf表单)时,都会创建一个新版本.
我的问题是:如何从AcroFields对象中检索所有修订?我知道如何让一个单一的版本,如果我有它的名字是这样的:
AcroFields fields = ...;
fields.getRevision("revision1");
Run Code Online (Sandbox Code Playgroud)
但是,我如何检索所有修订版(或至少他们的名字)?到目前为止,我还没有在iText API和网络中找到任何内容.
我在2.1.7版本中使用iText.
谢谢和问候,汤姆
我iTextSharp用来填写PDF模板.我使用的数据保存在数据库中并进行HTML格式化.我的问题是,当我加载AcroField这个文本时,我得到它来做换行符,但没有粗体也没有斜体.我已经尝试使用HtmlWorker,但在线的所有示例都显示它被用于转换HTML为a PDF但我正在尝试AcroField在PDF模板中设置.任何帮助,将不胜感激.
我需要帮助使用以下命令向字段添加西里尔字母值PDFBox API. 这是我到目前为止所拥有的:
PDDocument document = PDDocument.load(file);\nPDDocumentCatalog dc = document.getDocumentCatalog();\nPDAcroForm acroForm = dc.getAcroForm();\nPDField naziv = acroForm.getField("naziv");\nnaziv.setValue("\xd0\x9d\xd0\xb0\xd1\x81\xd0\xbb\xd0\xbe\xd0\xb2"); // this part right here\nnaziv.setValue("Naslov"); // it works like this\nRun Code Online (Sandbox Code Playgroud)\n\n当我的输入是拉丁字母时,它工作得很好。但我还需要处理西里尔字母输入。\n我该怎么做?
\n\nps这是我得到的异常:\n由以下原因引起:java.lang.IllegalArgumentException:U+043D(\'afii10079\')在此字体Helvetica编码中不可用:WinAnsiEncoding
\n我有使用 Adobe Acrobat Standard DC 创建的带有 acroForm 的 PDF。
我使用 Java iText 5 填充了 Chekcbox 字段。当我在“属性”中创建它时,我将其“复选框样式”设置为“检查”,因此在选中时它会放置“V”样式符号。

但是当我使用 iText 5 将此字段设置为选中状态时,它会检查它是否为 Cross:

我不明白为什么它会改变风格?
我的代码很简单:
void populateCheckBox(AcroFields form, String searchKey, String value) throws IOException, DocumentException {
if (form.getFieldType(searchKey) == AcroFields.FIELD_TYPE_CHECKBOX) {
String[] states = form.getAppearanceStates(searchKey);
if (ArrayUtils.contains(states, "On") && ArrayUtils.contains(states, "Off")) {
value = (value.equals("1")) ? "On" : "Off";
form.setField(searchKey, value);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个可填写的PDF包含CheckBoxes和RadioButtons和TextBox.
我如何获得CheckBox名称及其值,我们如何知道它是一个复选框/单选按钮?
我正在使用iTextSharp并查看我的下面的代码
PdfReader pdfReader = new PdfReader(FileName);
pdfReader.SelectPages("37");
MemoryStream oStream = new MemoryStream();
PdfStamper stamper = new PdfStamper(pdfReader, oStream);
AcroFields form = stamper.AcroFields;
if (form.Fields.Count() > 0)
{
IDictionary<string,AcroFields.Item> oDic= form.Fields;
foreach (string FieldName in oDic.Keys)
{
//FieldName - CheckBox name; i need to confirm that is a Checkbox...
}
foreach (AcroFields.Item oItem in oDic.Values)
{
// how do we get check box values
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个将内容表插入现有Acroform的过程,并且我能够跟踪启动该内容所需的位置.但是,根据我插入的表的高度,我在该点之下存在需要向上或向下移动的Acrofield.有了这个,我怎样才能改变Acrofield的位置?下面是我可以用来"获得"位置的代码......但是现在我还需要能够"设置"它.
....
// Initialize Stamper ("output" is a MemoryStream object)
PdfStamper stamper = new PdfStamper(pdf_rdr, output);
// Get Reference to PDF Document Fields
AcroFields fields = stamper.AcroFields;
//call method to get the field's current position
AcroFields.FieldPosition pos = GetFieldPosition(fields, "txt_footer");
Run Code Online (Sandbox Code Playgroud)
//**需要明确地为这里的田野设置一个新的位置
//assuming a call to "RegenerateField" will be required
fields.RegenerateField(txt_footer);
Run Code Online (Sandbox Code Playgroud)
....
//helper method for capturing the position of a field
private static AcroFields.FieldPosition GetFieldPosition(AcroFields fields, string field_nm)
{
////////////////////////////////////////////////////////////////////////////////////
//get the left margin of the page, and the "top" location …Run Code Online (Sandbox Code Playgroud) 我正在使用LibreOffice 4.1.3.2生成可填写的PDF:
使用Acrobar Reader打开pdf文件显示正确的可填写pdf.
接下来我使用iTextSharp 5.4.5填充字段并保存展平文档:
var pdf = new PdfReader(srcFilename);
using (var fw = new FileStream(dstFilename, FileMode.Create))
{
var stamper = new PdfStamper(pdf, fw);
var f = stamper.AcroFields;
f.SetField("field1", "John Doe");
f.SetField("field2", "12/04/2013");
stamper.FormFlattening = true;
stamper.Close();
}
pdf.Close();
Run Code Online (Sandbox Code Playgroud)
问题是填充的字段值在新文档中完全消失!
我认为没有找到或填充字段,但发现stamper.FormFlattening = true在保存的pdf中有评论字段值!
当然,我需要一个扁平化的PDF格式...
这有解决方案吗?
acrofields ×10
pdf ×6
itextsharp ×5
itext ×4
c# ×3
java ×3
.net ×1
adobe ×1
annotations ×1
c#-4.0 ×1
field ×1
fonts ×1
forms ×1
javascript ×1
pdfbox ×1
signature ×1