本文介绍了使用pdfsharp在pdf文档中的几个pdf页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在每次循环时添加一个包含其内容的页面。但它只是添加了最后一页,其数据删除了所有以前的数据和页面。结果只有1页。



我想根据循环创建pdf页面



Hi
I want to add a page with its content each time I loop. but it just adds the last page with its data removing all previous data and pages. and the result is only 1 page.

I want to create pdf pages according to the loop

foreach(item in list){
PdfPage page = new PdfPage();
                                Size pageSize = bmp.Size;
                                page.Width = 1700;
                                page.Height = 1800;


                                document.AddPage(page);

                                XGraphics gfx = XGraphics.FromPdfPage(page);
                                gfx.DrawImage(bmp, 0, 0);

 using (MemoryStream memoryStream = new MemoryStream())
                    {
                        //Save the Watermarked image to the MemoryStream.
                        document.Save(memoryStream, false);

                        memoryStream.Position = 0;

                        //Start file download.
                        Response.Clear();
                        Response.ContentType = "application/pdf";
                        Response.AddHeader("Content-Disposition", "inline; filename=" + filename);

                        //Write the MemoryStream to the Response.
                        Response.BinaryWrite(memoryStream.ToArray());
                        memoryStream.Close();
                        Response.Flush();
                        Response.Close();
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                    }
}





提前致谢



我尝试了什么:



我使用了pdfsharper ..循环列表中的项目

i write在图像上然后将其转换为pdf内容。



Thanks in advance

What I have tried:

I used a pdfsharper .. looped over items in list
i write on images then convert it to pdf content.

推荐答案


这篇关于使用pdfsharp在pdf文档中的几个pdf页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 07:41