SP App附加文本问题的PDF文件 [英] SP App to append PDF files with Text issue

查看:139
本文介绍了SP App附加文本问题的PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


目前我的应用程序保存了pdf文件非常好。

Currently my application saves the pdf file perfectly fine.

File.WriteAllBytes(路径,pdfEntity.Data);

PdfDocument DOC =新PdfDocument(路径);

File.WriteAllBytes(path, pdfEntity.Data);
PdfDocument doc = new PdfDocument(path);

我想在现有的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.Save(路径);

  doc.Pages.Add();
  doc.Save(path);

它添加新页面并正确保存。

It adds the new page and saves correctly.



我尝试过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."

我只需要现有的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 path = Server.MapPath(fileName);

字节[] signedPdf;

string fileName = string.Format(@"{0}.pdf", Guid.NewGuid());
string path = Server.MapPath(fileName);
byte[] signedPdf;

File.WriteAllBytes(路径,pdfEntity.Data);

PdfDocument DOC =新PdfDocument(路径);

File.WriteAllBytes(path, pdfEntity.Data);
PdfDocument doc = new PdfDocument(path);

  doc.Pages.Add();

  doc.Save(路径);

  doc.Pages.Add();
  doc.Save(path);

signedPdf = File.ReadAllBytes(path);

返回签名的pdf;

signedPdf = File.ReadAllBytes(path);
return signed pdf;

}

}

请帮忙。

推荐答案

您可以使用iTextSharp库将文本附加到现有的Pdf文件中:

You could use iTextSharp library to append text to an existing Pdf file:

ITextSharp将文本插入现有的pdf

谢谢

最好的问候


这篇关于SP App附加文本问题的PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆