Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Windows 8.1, 10, WindowsPhone, Windows UWP
  • Page:
  • 1

TOPIC:

Error when removing annotations 1 week 5 days ago #15652

  • никкуз1
  • никкуз1's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
Hi.
I open pdf via PDFStream. 
public class DecryptPdfStream : PDFStream
    {

        public const int BLOCK_SIZE = 4096;
        private Stream m_stream = null;
        private char m_key;
        private bool m_fix = false;

        public void Open(Stream stream, String key)
        {
            m_stream = stream;
            m_key = key.ToCharArray();

            string type_name = m_stream.GetType().ToString();
            m_fix = (type_name.LastIndexOf("NativeFileStream") > 0);
        }

        public bool Writeable()
        {
            if (m_stream == null) return false;
            return m_stream.CanWrite;
        }

        public long GetLength()
        {
            if (m_stream == null) return 0;
            return m_stream.Length;
        }

        public long GetPosition()
        {
            if (m_stream == null) return 0;
            return m_stream.Position;
        }

        public bool SetPosition(long pos)
        {
            if (m_stream == null) return false;
            string type_name = m_stream.GetType().ToString();
            if (m_fix)
            {
                ulong uoffset = (ulong)pos;
                ulong fix = ((uoffset & 0xffffffffL) << 32) | ((uoffset & 0xffffffff00000000L) >> 32);
                m_stream.Seek((long)fix, SeekOrigin.Begin);
            }
            else
                m_stream.Seek(pos, SeekOrigin.Begin);
            return true;
        }

        public int Read(byte buf)
        {
            if (m_stream == null) return 0;
            int read = m_stream.Read(buf, 0, buf.Length);
            return read;
// read encrypted pdf...
        }

        public int Write(byte buf)
        {
            if (m_stream == null) return 0;
            long prev = m_stream.Position;
            m_stream.Write(buf, 0, buf.Length);
            return (int)(m_stream.Position - prev);
        }

        public void Close()
        {
            if (m_stream != null)
            {
                m_stream.Dispose();
                m_stream = null;
            }
        }

        public void Flush()
        {
            if (m_stream != null)
                m_stream.Flush();
        }
    }



            if (file != null)
            {
                IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite);

                if (stream != null)
                {
                    DecryptPdfStream decryptPdfStream = new DecryptPdfStream();
                    string accessToken = App.RestUserRepository.User.AccessToken;
                    string key = accessToken.Substring(0, 16);
                    decryptPdfStream.Open(stream.AsStream(), key);
                    return decryptPdfStream;
                }

            }

...

m_doc = new PDFDoc();
PDF_ERROR err = m_doc.OpenStream(m_stream, "");
m_view.vOpen(m_doc, 4, 0xFFCCCCCC, this);



I am successfully creating an annotation with text highlighting. I can save pdf with changes. But I cannot remove annotations


        public void OnPDFAnnotClicked(PDFPage page, PDFAnnot annot)
        {
            m_view.vAnnotRemove();      or       annot.RemoveFromPage();
        }



I am getting unhandled exception. 
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

I also tried to work with non-encrypted pdfs using a stream. The same error.

Please Log in or Create an account to join the conversation.

Last edit: by никкуз1.

Error when removing annotations 1 week 4 days ago #15653

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1081
  • Thank you received: 68
dear user:
what version are you using? the last version on my side seems no method vAnnotRemove()
and we sure, that remove annotation works fine.
 

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum