【发布时间】:2015-09-20 19:48:07
【问题描述】:
我有一个 .pdf 文档,例如有 7 页。我将此文档拆分为 7 个 .pdf 文档,因此这意味着每个文档只有一页。但主要是我需要适应页面的内容。所以删除空格、边距、调整大小。你有什么简单的建议吗?我添加了图像链接以及拆分 pdf 文档的代码。感谢您的回复。
输入:
http://i.imgur.com/tgQK3hI.png
期望的输出:
http://i.imgur.com/v6cZDwg.png
代码:
public void PdfSplitDocument(string filename)
{
String path = "C:/Doc/" + filename;
String result = "d:/output/result";
PdfCopy copy;
PdfReader reader = new PdfReader(path);
for (int i = 1; i <= reader.NumberOfPages; i++)
{
Document document = new Document(PageSize.A4, 0, 0, 0, 0);
copy = new PdfCopy(document, new FileStream(result + i + ".pdf", FileMode.Create));
document.Open();
copy.AddPage(copy.GetImportedPage(reader, i));
document.Close();
}
}
【问题讨论】:
标签: c# pdf split resize itextsharp