class mineTest
{
string pdfTemplate = @"c:\us.pdf";
public mineTest(Customer c, string output)
{
StreamReader sr = new StreamReader(pdfTemplate);
StreamWriter sw = new StreamWriter(output);
string content = sr.ReadToEnd();
content.Replace("(Customer name)/DA(/Verdana 10 Tf 0 g)/FT/Tx/Type/Annot/MK<<>>/V()/AP<</N 13 0 R>>>>", "(Customer name)/DA(/Verdana 10 Tf 0 g)/FT/Tx/Type/Annot/MK<<>>/V(John Johnson)/AP<</N 13 0 R>>>>");
sw.Write(content);
sw.Close();
sr.Close();
}
}
为什么上面的代码在生成有效PDF时失败?在没有API的情况下在.NET中填充PDF字段,例如iTextSharp
我虽然我将不得不支付PDFSharp的商业许可证。谢谢! 但是,只是为了好奇,为了编辑没有库的PDF文件,这是一个真正的问题吗? – 2010-06-14 16:44:30
有许多免费和开放源代码的PDF库。 iText.NET是另一个。我没有必要使用它们,几年前我使用了一个商业产品(Dynamic PDF)。 – 2010-06-14 17:21:27
要编辑没有PDF库的PDF文档,需要了解PDF文件格式。然后你可以写你自己的图书馆。 :) 对不起,我对此知之甚少。 – 2010-06-14 17:23:53