- Posts: 2
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Windows 8.1, 10, WindowsPhone, Windows UWP
Error when removing annotations
IP: 85.249.26.143
4 years 3 months ago - 4 years 3 months ago #15652
by никкуз1
Error when removing annotations was created by никкуз1
Hi.
I open pdf via PDFStream.
I am successfully creating an annotation with text highlighting. I can save pdf with changes. But I cannot remove annotations
I am getting unhandled exception.
I open pdf via PDFStream.
Code:
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();
}
}
Code:
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
Code:
public void OnPDFAnnotClicked(PDFPage page, PDFAnnot annot)
{
m_view.vAnnotRemove(); or annot.RemoveFromPage();
}
I am getting unhandled exception.
Code:
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.
Last edit: 4 years 3 months ago by никкуз1.
IP: 111.196.244.137
4 years 3 months ago #15653
by radaee
Replied by radaee on topic Error when removing annotations
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.
what version are you using? the last version on my side seems no method vAnnotRemove()
and we sure, that remove annotation works fine.
Time to create page: 0.394 seconds