我有一个Class,PDF 文件复制问题

ballatong 2016-03-25 12:57:50
Class 如下: 功能是上传一个PDF文件,然后把它拆分成每一页一个PDF文件存放到相关目录

现在想改成不需要拆分,直接复制这个上传的文件到特定目录,请问如何更改

public class PdfExtractorUtility
{

public void ExtractPages(string sourcePdfPath, string OutputPath, string OrderNumber)
{
try
{
// Intialize a new PdfReader instance with the contents of the source Pdf file:
PdfReader reader = new PdfReader(sourcePdfPath);

int pageQuantity = reader.NumberOfPages;

for (int i = 1; i <= pageQuantity; i++)
{
string OutputPathPdf = OutputPath + OrderNumber + "_Page_" + i + ".pdf";
Document sourceDocument = new Document(reader.GetPageSizeWithRotation(i));
PdfCopy pdfCopyProvider = new PdfCopy(sourceDocument, new System.IO.FileStream(OutputPathPdf, System.IO.FileMode.Create));
sourceDocument.Open();
PdfImportedPage importedPage = pdfCopyProvider.GetImportedPage(reader, i);
pdfCopyProvider.AddPage(importedPage);
sourceDocument.Close();

}

reader.Close();

}
catch (Exception ex)
{
throw ex;
}
}

}
...全文
61 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧