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();

 

 

<http://www.kscharitycheck>  

 

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
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