Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Error: Attempted to read or write protected memory.
Started by SureshMittapalli at 03-05-2008 17:42. Topic has 3 replies.

Print Search « Previous Thread Next Thread »
  03-05-2008, 17:42
SureshMittapalli is not online. Last active: 2/29/2008 4:43:32 PM SureshMittapalli

Top 100 Posts
Joined on 02-29-2008
Posts 22
Error: Attempted to read or write protected memory.
Reply Quote

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."


   Report 
  03-06-2008, 9:15
Adam Boulad is not online. Last active: 11/13/2008 4:54:42 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 490
Re: Error: Attempted to read or write protected memory.
Reply Quote

I'm afraid our toolkit does not support setting the password on multi-page PDF files. This is a limitation in the toolkit and we have submitted a feature request to see if it can be changed. The request number is 6347AMN.


Adam Boulad
LEADTOOLS Technical Support

   Report 
  03-06-2008, 9:32
SureshMittapalli is not online. Last active: 2/29/2008 4:43:32 PM SureshMittapalli

Top 100 Posts
Joined on 02-29-2008
Posts 22
Re: Error: Attempted to read or write protected memory.
Reply Quote

Hi Adam,

 

Thanks for your reply, otherwise I could have ended up in investigating this. And also I have once question when I set some codecs options like below:

rasCodecs.Options.Pdf.Save.ModifyDocument = false;
 rasCodecs.Options.Pdf.Save.PrintDocument = false;
                rasCodecs.Options.Pdf.Save.ExtractText = false;
                rasCodecs.Options.Pdf.Save.FillForm = false;

These settings are not getting effected in genarated pdf until I set a owner password. Is it something a bug???

With this weird behavior believe I am struggling a lot.

Thanks,

Suresh

 

 


   Report 
  03-09-2008, 11:52
Adam Boulad is not online. Last active: 11/13/2008 4:54:42 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 490
Re: Error: Attempted to read or write protected memory.
Reply Quote

Suresh,

This behavior is by design. These options are only enabled when you set the owner password.

Since setting this password does not prevent the user from reading the document, this should not be a problem.


Adam Boulad
LEADTOOLS Technical Support

   Report 
Post
LEAD Support Fo... » Developer » PDF » Error: Attempted to read or write protected memory.

Powered by Community Server, by Telligent Systems