C# aspose.pdf
需要把PDF中的某页复制到另一个PDF中第2页中。也就是在一个pdf文件中的第二页插入一个已存在的pdf。
QQ截图20190826130709.jpg (98.9 KB)
感谢您与支持人员联系。
您可以使用insert方法将页面插入PDF文档。 请尝试以下代码,然后与我们分享您的反馈。
Document source = new Document(dataDir + "source.pdf");
Document destination = new Document(dataDir + "destination.pdf");
destination.Pages.Insert(2, source.Pages[1]);
destination.Save(dataDir + "updated_19.8.pdf");
如果您需要任何进一步的帮助,请联系我们。
谢谢你,小弟还有一个小问题,aspose.pdf如何向已有书签插入书签到指定位置
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("cc.pdf");
//创建书签对象
Aspose.Pdf.OutlineItemCollection pdfOutline = new
OutlineItemCollection(pdfDocument.Outlines);
pdfOutline.Title = "目录";
//pdfOutline.Italic1 = true;
//pdfOutline.Bold = true;pdfDocument.Pages[2], 700 InteractiveFeatures.FitHExplicitDestination
pdfOutline.Destination = new FitExplicitDestination(2);
//设定目标页面
pdfOutline.Action = new GoToAction(pdfDocument.Pages[1]);
//在文档集合中添加书签。
pdfDocument.Outlines.Add(pdfOutline);
pdfDocument.Save("output.pdf");
这个之前小弟用过了,报错: pdfOutline.Insert(2, pdfOutline);
System.ArgumentException:“Invalid index: index should be in the range [1…n] where n equals to the outline items count.”
QQ截图20190827071350.jpg (59.8 KB)
哥,小弟有一个问题还没解决呢,
这个之前小弟用过了,报错:pdfOutline.Insert(2,pdfOutline);
System.ArgumentException:“索引无效:索引应该在[1 … n]范围内,其中n等于大纲项目计数。”
源文件:cc.pdf (4.0 MB)
1:使用pdfOutline.Insert()方法如何将书签插入到第一个书签的位置。
使用pdfOutline.Insert(1,pdfOutline);报这个错误:
System.ArgumentException:“索引无效:索引应该在[1 … n ]的范围内,其中ñ等于大纲项目计数“。
// 2,添加书签代码如下:
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(“cc.pdf”);
//创建书签对象
Aspose.Pdf.OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
pdfOutline.Title =“目录”;
//设定目标页面
pdfOutline.Action = new GoToAction(pdfDocument.Pages [1]);
强调文本 //在指定位置添加书签
pdfOutline.Insert(1,pdfOutline);
pdfDocument.Outlines.Add(pdfOutline);
//保存
pdfDocument.Save(“输出.pdf”);