先感谢技术大牛帮忙查看:
1:如何设置插入页的大小。 pdfDocument6.Pages.Insert(2,pdfDocument3.Pages[1]);
Aspose.Pdf.Document pdfDocument6 = new Aspose.Pdf.Document(pdflj);
//打开第二个文件
Aspose.Pdf.Document pdfDocument3 = new Aspose.Pdf.Document("wordTpdf.PDF");
//指定位子放入pdf文件里
pdfDocument6.Pages.Insert(2, pdfDocument3.Pages[1]);
//在pdf最后插入
//pdfDocument6.Pages.Add(pdfDocument3.Pages[1]);
pdfDocument6.Save("cc.pdf");
QQ截图20190827211211.jpg (103.6 KB)
2: 使用pdfOutline.Insert()方法如何将书签插入到第一个书签的位置。
这样使用pdfOutline.Insert(1, pdfOutline);报这个错误:
System.ArgumentException:“索引无效:索引应该在[1 … n]范围内,其中n等于大纲项目计数。”
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;
//设定目标页面
pdfOutline.Action = new GoToAction(pdfDocument.Pages[1]);
//在文档集合中添加书签。
//获取书签对象
//pdfOutline.Insert(pdfDocument.Outlines[1], pdfOutline);
pdfOutline.Insert(1, pdfOutline);
pdfDocument.Save("output.pdf");
QQ截图20190827204139.jpg (117.8 KB)
@fhn123456
感谢您与支持人员联系。
请分享您的源文件,以便我们可以尝试对其进行调查并为您提供帮助。
这两源文件:
pdflj.pdf (4.0 MB)
wordTpdf.PDF (28.8 KB)
代码如下,复制就能用:
1:如何设置插入页的大小.pdfDocument6.Pages.Insert(2,pdfDocument3.Pages [1]);
//1,插入代码如下:
Aspose.Pdf.Document pdfDocument6 = new Aspose.Pdf.Document(“pdflj.pdf”);
//打开第二个文件
Aspose.Pdf.Document pdfDocument3 = new Aspose.Pdf.Document(“wordTpdf.PDF”);
//指定位子放入pdf文件里
pdfDocument6.Pages.Insert(1,pdfDocument3.Pages[1]);
//保存
pdfDocument6.Save(“cc.pdf”);
2:使用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]);
emphasized text//在指定位置添加书签
pdfOutline.Insert(1, pdfOutline);
pdfDocument.Outlines.Add(pdfOutline);
//保存
pdfDocument.Save(“output.pdf”);
@fhn123456
感谢您分享所请求的数据。
您可以使用以下代码插入相同大小的页面。
Aspose.Pdf.Document pdfDocument6 = new Aspose.Pdf.Document(dataDir + "pdflj.pdf");
//Open the second file
Aspose.Pdf.Document pdfDocument3 = new Aspose.Pdf.Document(dataDir + "wordTpdf.PDF");
PdfFileInfo info = new PdfFileInfo(pdfDocument6);
var Height = info.GetPageHeight(1);
var Width = info.GetPageWidth(1);
Page page = pdfDocument3.Pages[1];
page.SetPageSize(Width , Height);
// specify the position into the pdf file
pdfDocument6.Pages.Insert(1, page);
// save
pdfDocument6.Save(dataDir + "cc_19.8.pdf");
cc_19.8.pdf
对于书签,我们已在相应主题中回复了您。
先谢谢技术大哥的代码,小弟有礼了。
源文件:
pdflj.pdf (4.0 MB)
wordTpdf.PDF (28.8 KB)
小弟用的是Aspose.pdf版本是17.7.0.0的
"PdfFileInfo"不包含采用1个参数的构造方法。
所以参考大哥的代码,可以插入相同大小的页面,页面是相同大小了,但是页面里面的表格数据很小如下截图:
cc_19.8.jpg (76.7 KB)
用小弟的代码如下,复制就可以使用,如何将页面里面的表格数据放大到整个页面,如下截图:
QQ截图20190828232721.jpg (16.5 KB)
Aspose.Pdf.Document pdfDocument6 = new Aspose.Pdf.Document(pdflj);
//打开第二个文件
Aspose.Pdf.Document pdfDocument3 = new
Aspose.Pdf.Document("wordTpdf.PDF");
//指定位子放入pdf文件里
var Height = pdfDocument6.Pages[1].GetPageRect(false).Height;
var Width = pdfDocument6.Pages[1].GetPageRect(false).Width;
Aspose.Pdf.Page page = pdfDocument3.Pages[1];
page.SetPageSize(Width, Height);
pdfDocument6.Pages.Insert(1, page);
//在pdf最后插入
//pdfDocument6.Pages.Add(pdfDocument3.Pages[1]);
pdfDocument6.Save("cc.pdf");
@fhn123456
您可以使用下面的代码段调整页面内容的大小,您可以根据自己的要求调整参数。
int[] pages = { 1 };
// Create PdfFileEditor Object
PdfFileEditor fileEditor = new PdfFileEditor();
// Open PDF Document
Document doc = new Document(dataDir + "cc (1).pdf");
// Specify Parameter to be used for resizing
PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
PdfFileEditor.ContentsResizeValue.Percents(0), null,
PdfFileEditor.ContentsResizeValue.Percents(0),
PdfFileEditor.ContentsResizeValue.Percents(0), null,
PdfFileEditor.ContentsResizeValue.Percents(-30));
// Resize Page Contents
fileEditor.ResizeContents(doc, pages ,parameters);
// Save document into new location.
doc.Save(dataDir + "ResizePageContents_19.8.pdf");
如果您需要任何进一步的帮助,请随时与我们联系。
谢谢,大哥,还是大哥厉害,帮我完美的解决的问题,给大哥一个赞!
@fhn123456
谢谢你的反馈。
很高兴知道您的问题通过使用建议的方法得到解决。请继续使用我们的API,如有任何进一步的帮助,请随时告诉我们。