如何将页面大小设置为信封,在Itextsharp中显示风景 [英] How Do I Set Page Size As Envelope , Landscape In Itextsharp
本文介绍了如何将页面大小设置为信封,在Itextsharp中显示风景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
美好的一天所有,
我在使用页面设置为信封,横向格式创建.pdf文件时遇到问题。
这是我在Itextsharp中将asp页面转换为pdf的代码
Good Day All,
I have problem on creating .pdf file with the Page settings as Envelope ,landscape format.
Here is my Code to convert the asp page into pdf in Itextsharp
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Receipt.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
bind_Data();
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4.Rotate(), 10f, 10f, 100f, 0f);
//here i need to set Pagesize as Envelope.
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
i googled it但我找不到信封大小。我怎么设置页面大小为信封,动态景观
在此先感谢
i googled it but i couldn't find Envelope size.How do i set the page size as Envelope ,Landscape in dynamically
Thanks In Advance
推荐答案
iTextSharp与ASP.Net无关。这是由iText维护的第三方组件。
我宁愿建议查看他们的支持论坛,在那里你可以吸引更多有这个组件经验的人。看看他们对支持的看法:
http://itextpdf.com/support [ ^ ]
iTextSharp has nothing to do with ASP.Net. It's a 3rd party Component maintained by iText.
I would rather suggest to look at their support forum where you can get more people with experience with this component. Look here what they say about support:
http://itextpdf.com/support[^]
有世界各地都使用了很多信封大小,因此iTextSharp可能没有为它们预定义的常量...
PageSize.A4.Rotate()方法返回一个Rectangle,因此你可以创建一个具有您自己所需大小的新矩形并将其传递给Document ...
There is a lot of envelope sizes used all over the world, so it possible iTextSharp has no predefined constants for them...
The PageSize.A4.Rotate() method returns a Rectangle, so you can create a new Rectangle with your own desired size and pass it to Document...
Rectangel rect = new Rectangle(x1, y1, x2, y2, 90);
Document doc = new Documnet(rect, m1, m2, m3, m4);
这篇关于如何将页面大小设置为信封,在Itextsharp中显示风景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文