服务端用iTextSharp产生图片内容PDF分页问题

nices 2010-10-12 05:03:53
服务端代码如下,其中 context.Request.InputStream是从Silverlight传过来的,从一个StackPanel转换为EditableImage的Stream。现在产生的PDF没有分页,所有的内容都在同一页。
System.IO.Stream incomingStream = context.Request.InputStream; //Get the incoming stream
System.Drawing.Image img = System.Drawing.Image.FromStream(incomingStream); //Create and image from the stream

int pageHeight = img.Height + (_Margin * 2);
int pageWidth = img.Width + (_Margin * 2);

iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(img, System.Drawing.Imaging.ImageFormat.Png);
System.IO.MemoryStream pdfStream = new System.IO.MemoryStream();
//iTextSharp.text.Font pdfFont = iTextSharp.text.Font.
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(new iTextSharp.text.Rectangle(pageWidth, pageHeight));

//iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4);
pdfDoc.NewPage();
iTextSharp.text.pdf.PdfWriter pdfWriter = iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, pdfStream);

//Insure this is set otherwise when the close method is called on the iTextSharp.text.Document the memory stream
//we are writting to will be closed
pdfWriter.CloseStream = false;

//Open PDF and add image to it
pdfDoc.Open();
pdfDoc.Add(pdfImage);

//Close the PDF document to commit the changes
pdfDoc.Close();

//Insure the stream is at the beginning
if (pdfStream.Position > 0) { pdfStream.Position = 0; };

int contentLength = (int)pdfStream.Length;
//Stream the exported pdf to the client this is needed since the file size could be large in size
Byte[] bytesRead = new Byte[contentLength];
pdfStream.Read(bytesRead, 0, contentLength);
...全文
704 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
foreveryimada 2012-03-02
  • 打赏
  • 举报
回复
是否已经解决这个问题??[Quote=引用楼主 nices 的回复:]
服务端代码如下,其中 context.Request.InputStream是从Silverlight传过来的,从一个StackPanel转换为EditableImage的Stream。现在产生的PDF没有分页,所有的内容都在同一页。
System.IO.Stream incomingStream = context.Request.InputStream; //Get the incomin……
[/Quote]
jv9 2010-10-13
  • 打赏
  • 举报
回复
没有用过iTextSharp控件,iTextSharp控件中是否有独立的分页控制可以有代码进行判断和分页呢?
内容概要:本文介绍了PCIe 3.x至4.0版本在物理层(PHY)逻辑层面的关键技术演进,重点包括从8b/10b编码向128b/130b编码的转变,以提升带宽效率并降低开销。新编码机制通过同步头与加扰技术实现数据块对齐、帧定界和边沿密度控制,同时引入发射端均衡(Tx Equalization)和多阶段训练流程,以应对高速信道下的信号完整性挑战。文档还详细阐述了测试性功能如合规性模式、环回机制以及有序集(Ordered Sets)的设计用途,并前瞻性地预览了PCIe 4.0支持16GT/s速率的技术方向,包括继续采用128b/130b编码、增强均衡流程和使用Retimer扩展通道能力。; 适合人群:从事高速接口设计、芯片开发或系统架构的硬件工程师,特别是参与PCIe协议实现、物理层验证及信号完整性优化的研发人员。; 使用场景及目标:①理解PCIe 3.0中128b/130b编码原理及其相较于8b/10b的优势;②掌握发射端自适应均衡机制与链路训练流程;③为开发兼容PCIe 4.0的产品提供前瞻技术参考;④用于硬件测试与合规性验证方案设计。; 阅读建议:此资料技术深度较高,建议结合PCIe Base Specification进行对照学习,重点关注编码结构、有序集格式、均衡状态机及错误恢复机制,在实际项目中可作为物理层设计与调试的重要参考依据。

8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧