SP App附加文本问题的PDF文件 [英] SP App to append PDF files with Text issue
问题描述
目前我的应用程序保存了pdf文件非常好。 Currently my application saves the pdf file perfectly fine. File.WriteAllBytes(路径,pdfEntity.Data); File.WriteAllBytes(path, pdfEntity.Data); 我想在现有的pdf中添加2-3行文本。 .aspx页面包含以下文本,并尝试附加文本,然后尝试创建新页面,但它可用于创建页面,但我不知道如何添加内容。 test.aspx具有以下内容 I want to add 2-3 lines of text to the existing pdf. The .aspx page has the following text and tried to append text and then tried to create new page but it works on creating page but I dont know how to add the content. test.aspx has the following content divMessage.InnerHtml = @"通过生成此文件,员工确认使用管理器读取此评估及其内容。"; divMessage.InnerHtml = @"By generating this file, the Employee acknowledges reading this evaluation and its content with the Manager."; test.aspx.cs具有创建pdf的所有功能。我试图创建 The test.aspx.cs has all functionality to create pdf. I tried to create doc.Pages.Add(); doc.Pages.Add(); 它添加新页面并正确保存。 It adds the new page and saves correctly. 我只需要现有的pdf文件,我只需要添加 最后几行。 All I need is the existing pdf file, I just need to add couple of lines at the end. protected byte [] SignPdf(PdfEntity pdfEntity,bool genPDFUser) protected byte[] SignPdf(PdfEntity pdfEntity, bool genPDFUser) string fileName = string.Format(@" {0} .pdf",Guid.NewGuid()); string fileName = string.Format(@"{0}.pdf", Guid.NewGuid()); File.WriteAllBytes(路径,pdfEntity.Data); File.WriteAllBytes(path, pdfEntity.Data); doc.Pages.Add(); doc.Pages.Add(); signedPdf = File.ReadAllBytes(path); signedPdf = File.ReadAllBytes(path); } } 请帮忙。 您可以使用iTextSharp库将文本附加到现有的Pdf文件中: You could use iTextSharp library to append text to an existing Pdf file: 谢谢 最好的问候 这篇关于SP App附加文本问题的PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
PdfDocument DOC =新PdfDocument(路径);
PdfDocument doc = new PdfDocument(path);
doc.Save(路径);
doc.Save(path);
我尝试过File.AppendText = divMessage.InnerHtml;它说路径中的illigal字符
我也试过File.AppendAllLines, File.AppendAllText但是这些一直出错"System.Exception:找不到目录对象。"
I tried File.AppendText = divMessage.InnerHtml; it said illigal characters in the path
I also tried File.AppendAllLines, File.AppendAllText but these keeps on erroring out "System.Exception: Catalog object not found."
{
{
$
string path = Server.MapPath(fileName);
字节[] signedPdf;
string path = Server.MapPath(fileName);
byte[] signedPdf;
PdfDocument DOC =新PdfDocument(路径);
PdfDocument doc = new PdfDocument(path);
doc.Save(路径);
doc.Save(path);
返回签名的pdf;
return signed pdf;
推荐答案