Inverted colours in tiff to PDF conversion

Posted by spiderdijon on Stack Overflow See other posts from Stack Overflow or by spiderdijon
Published on 2010-05-27T06:34:01Z Indexed on 2010/05/27 6:41 UTC
Read the original article Hit count: 299

Filed under:
|
|
|

I'm sure I'm making some kind of silly mistake here, but when converting a tiff file to PDF, the colours become reversed. I can't figure out why. Here's my code:

PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Image.pdf", FileMode.Create));

System.Drawing.Bitmap bm = new System.Drawing.Bitmap(@"C:\Temp\338814-00.tif");
int total = bm.GetFrameCount(FrameDimension.Page);                

document.Open();
PdfContentByte cb = writer.DirectContent;

for (int k = 0; k < total; ++k)
{
 bm.SelectActiveFrame(FrameDimension.Page, k);
 MemoryStream ms = new MemoryStream();
 bm.Save(ms, ImageFormat.Tiff);

 Image img = Image.GetInstance(ms.ToArray());

 img.ScalePercent(72f / (float)img.DpiX * 100);
 img.SetAbsolutePosition(0, 0);

 cb.AddImage(img);
 document.NewPage();     
}
document.Close();

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about pdf