我们如何使用 PDFsharp 将外部 PDF 添加到当前页面?
How can we add an external PDF to the current page with PDFsharp?
我得到了一个 PDF 文件流,我正在尝试将其添加到我当前的 PDF 中。
byte[] pdfBytes = interview.Application.CandidateResumeFile.File.FileBinary.ToArray();
Stream pdfstream = new MemoryStream(imgBytes);
这为我提供了要添加到我的页面的 PDF 文件流。
PdfDocument doc = new PdfDocument();
doc.Info.Title = "Test PDFSharp";
PdfPage page = doc.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
////////content
const string filename = "test.pdf";
doc.Save(filename);
Process.Start(filename);
我的页面设置如下,页面加载正常。我只想将 PDF 文件添加到页面。
PDFsharp 附带了几个以不同方式解决此任务的示例。
查看串联文档:
http://pdfsharp.net/wiki/ConcatenateDocuments-sample.ashx
查看合并文档:
http://pdfsharp.net/wiki/CombineDocuments-sample.ashx
基本上有两种选择:将现有页面绘制到新页面上,允许您调整大小和缩放它。或者将页面添加到新文档,创建一个精确的副本。
我得到了一个 PDF 文件流,我正在尝试将其添加到我当前的 PDF 中。
byte[] pdfBytes = interview.Application.CandidateResumeFile.File.FileBinary.ToArray();
Stream pdfstream = new MemoryStream(imgBytes);
这为我提供了要添加到我的页面的 PDF 文件流。
PdfDocument doc = new PdfDocument();
doc.Info.Title = "Test PDFSharp";
PdfPage page = doc.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
////////content
const string filename = "test.pdf";
doc.Save(filename);
Process.Start(filename);
我的页面设置如下,页面加载正常。我只想将 PDF 文件添加到页面。
PDFsharp 附带了几个以不同方式解决此任务的示例。
查看串联文档:
http://pdfsharp.net/wiki/ConcatenateDocuments-sample.ashx
查看合并文档:
http://pdfsharp.net/wiki/CombineDocuments-sample.ashx
基本上有两种选择:将现有页面绘制到新页面上,允许您调整大小和缩放它。或者将页面添加到新文档,创建一个精确的副本。