I'm not sure what the question is. Is it about tiff or about using ASP.NET?

Paulo
  ----- Original Message ----- 
  From: Roger Schweppe 
  To: [email protected] 
  Sent: Friday, June 25, 2010 10:59 PM
  Subject: [iText-questions] tiff to pdf converter help need soon


  Hi all,

   

  I am trying to use the iTextSharp dll to convert a tiff image that is in 
binary format in memory to a pdf and then display it in a web page using a c# 
web page.  I don’t want to save any files to the hard drive; I want to keep 
everything in memory.   I am having trouble with the line of code 
“System.Drawing.Bitmap bm = new 
System.Drawing.Bitmap((Stream)((byte[])command.Parameters[8].Value));”, not 
sure what to do at this point.  Hoping to use the 
“Response.BinaryWrite(ByteArray);” command to display on a web page.  See code 
below.

   

  Thanks

   

   

   

   

   

          // creation of the document with a certain size and certain margins

          iTextSharp.text.Document document = new 
iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);

          

          // creation of the different writers

          iTextSharp.text.pdf.PdfWriter writer = 
iTextSharp.text.pdf.PdfWriter.GetInstance(document, new 
System.IO.FileStream(Server.MapPath("~result.pdf"), System.IO.FileMode.Create));

   

   

   

          // load the tiff image and count the total pages

          //System.Drawing.Bitmap bm = new 
System.Drawing.Bitmap(Server.MapPath("~/App_Data/source.tif"));

          

          System.Drawing.Bitmap bm = new 
System.Drawing.Bitmap((Stream)((byte[])command.Parameters[8].Value));

          

          

          

          int total = 
bm.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);

   

          document.Open();

          iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;

          for (int k = 0; k < total; ++k)

          {

              bm.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, 
k);

              iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bm, 
System.Drawing.Imaging.ImageFormat.Bmp);

              // scale the image to fit in the page

              img.ScalePercent(72f / img.DpiX * 100);

              img.SetAbsolutePosition(0, 0);

              cb.AddImage(img);

              document.NewPage();

          }

          document.Close();

   

   

   

   
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to