|
Hi there,
I am getting very weird error. This occurs only in particular case. I am load multipage tif and converting to pdf using leadtools in .net v15. When I set
rasCodecs.Options.Pdf.Save.OwnerPassword = "passw0rd"; this is reulting in the above said error. without this property it works fine. Even with this property set, it is working for single page tiff. So I am just wondering whats going wrong. Below is error details: Please help.
Thanks,
Suresh
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
//int newRes = 200; //rasCodecs.Options.Pdf.Load.XResolution = rasCodecs.Options.Pdf.Load.YResolution = newRes; //rasCodecs.Options.Pdf.Load.DisplayDepth = 1;
//rasCodecs.Options.Pdf.Save.UserPassword = "passw0rd"; rasCodecs.Options.Load.Compressed = true; rasCodecs.Options.Load.TiledMemory = true;
rasImage = rasCodecs.Load(inputFile); //load input file
// Draw text on PDF. container = rasImage.CreateGdiPlusGraphics(); container.Graphics.SmoothingMode = SmoothingMode.None; //container.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; Brush br = new LinearGradientBrush(Point.Empty, new Point(200, 200), Color.Black, Color.Black); Font textFont = new Font(FontFamily.GenericSansSerif, 15); PointF point = new PointF(100, 50); container.Graphics.DrawString("Generated By EIP Document Viewer at " + DateTime.Now.ToString(), textFont, br, point);
// Xolor-res it to 4 bits per pixel using the Netscape palette // Note: Not sure how the lead tools stuff works. Without this "ColorResolutionCommand" code // Generated pdf is displaying in inverted color like background is becoming black and letters // are displaying in white. With this piece of code it worked fine. ColorResolutionCommand cmd = new ColorResolutionCommand(); cmd.Mode = ColorResolutionCommandMode.InPlace; cmd.BitsPerPixel = 4; cmd.Order = RasterByteOrder.Rgb; cmd.DitheringMethod = RasterDitheringMethod.None; cmd.PaletteFlags = ColorResolutionCommandPaletteFlags.Optimized; cmd.SetPalette(RasterPalette.Netscape()); cmd.Run(rasImage);
rasCodecs.Options.Pdf.Save.ModifyDocument = false; rasCodecs.Options.Pdf.Save.PrintDocument = false; rasCodecs.Options.Pdf.Save.ExtractText = false; rasCodecs.Options.Pdf.Save.FillForm = false; rasCodecs.Options.Pdf.Save.Use128BitEncryption = true; rasCodecs.Options.Pdf.Save.OwnerPassword = "passw0rd";
rasCodecs.Save(rasImage, stream, imgFormat, 0, 1, -1, 1, CodecsSavePageMode.Overwrite);
pdfByteArray = stream.ToArray();
Error:
StackTrace " at fltSavePDF(_SAVEDISPATCH* )\r\n at Leadtools.Codecs.Pdf.PdfCodec.fltSave(IntPtr dispatch)\r\n at ManagedFLTSAVE(Int32 fmt, _SAVEDISPATCH* dis)\r\n at L_SaveFile(Char* , _BITMAPHANDLE* , Int32 , Int32 , Int32 , UInt32 , IntPtr , Void* , _SAVEFILEOPTION* )\r\n at Leadtools.Codecs.RasterCodecs.SaveOnePage(Int32 page, SaveParams saveParams)\r\n at Leadtools.Codecs.RasterCodecs.DoSave(SaveParams saveParams)\r\n at Leadtools.Codecs.RasterCodecs.Save(RasterImage image, Stream stream, RasterImageFormat format, Int32 bitsPerPixel, Int32 firstPage, Int32 lastPage, Int32 firstSavePageNumber, CodecsSavePageMode pageMode)\r\n at WPDocumentViewer.WPDocumentViewerHelper.ConvertToPDF(String inputFile) in H:\\WPDocumentViewerProj\\WPDocumentViewer\\WPDocumentViewerHelper.cs:line 98" string
Source "Leadtools.Codecs.Pdf" string
Message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
|