Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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 but i couldn't find Envelope size.How do i set the page size as Envelope ,Landscape in dynamically



Thanks In Advance
Posted
Updated 16-Sep-14 22:03pm
v2

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[^]
 
Share this answer
 
Comments
King Fisher 17-Sep-14 5:11am    
Thank you
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...
C#
Rectangel rect = new Rectangle(x1, y1, x2, y2, 90);
Document doc = new Documnet(rect, m1, m2, m3, m4);
 
Share this answer
 
Comments
King Fisher 17-Sep-14 5:10am    
i need to set the Envelope#10 and landscape format like exact in IE8

Border :Left 0.75,right 0.75,Top 0.16,Bottom 0.236 in Internet Explorer. it doesn't accept Decimal values Respected to x1,y1,...

Guide me right way sir
Kornfeld Eliyahu Peter 17-Sep-14 5:12am    
I think we got to the point where YOU should do the work...
King Fisher 17-Sep-14 5:22am    
Example Format

have a look on this File sir .this is what exact i'm trying.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900