|
Hi,
When tried twith the code you have given, its giving object reference not set tio an instance error when it is calling getpallette method.
Can you look into this? Here is my code:
stream = new MemoryStream(); RasterCodecs.Startup(); RasterImageFormat imgFormat = GetRasFormatType(inputFile); rasCodecs = new RasterCodecs(); RasterSupport.Unlock(RasterSupportType.PdfRead, pdfReadKey); //unlock PDF_READ RasterSupport.Unlock(RasterSupportType.PdfSave, pdfSaveKey); //unlock PDF_SAVE
rasImage = rasCodecs.Load(inputFile); //Load input file
for (int pageIndex = 1; pageIndex <= rasImage.PageCount; pageIndex++) { rasImage.Page = pageIndex; // Draw text on PDF. container = rasImage.CreateGdiPlusGraphics(); container.Graphics.SmoothingMode = SmoothingMode.None; container.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; Brush brush = new LinearGradientBrush(Point.Empty, new Point(200, 200), Color.Black, Color.Black); Font textFont = new Font(FontFamily.GenericSansSerif, 15); PointF point = new PointF(100, rasImage.Height - 80); container.Graphics.DrawString("Generated By EIP Document Viewer at " + DateTime.Now.ToString(), textFont, brush, point);
RasterColor[] img1Palette = rasImage.GetPalette(); RasterColor[] reversedPalette = new RasterColor[2] { img1Palette[1], img1Palette[0] }; rasImage.SetPalette(reversedPalette, 0, reversedPalette.Length);
}
// Save the generated pdf rasCodecs.Save(rasImage, stream, imgFormat, 0, 1, -1, 1, CodecsSavePageMode.Overwrite);
Thanks,
Suresh
|