1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using System;
- using Paroxe.PdfRenderer.Internal;
- namespace Paroxe.PdfRenderer
- {
- #if !UNITY_WEBGL
- /// <summary>
- /// Represents the annotation link in a PDF page.
- /// </summary>
- public class PDFLink : IDisposable
- {
- private bool m_Disposed;
- private IntPtr m_NativePointer;
- private PDFPage m_Page;
- public PDFLink(PDFPage page, IntPtr nativePointer)
- {
- if (page == null)
- throw new NullReferenceException();
- if (nativePointer == IntPtr.Zero)
- throw new NullReferenceException();
- PDFLibrary.AddRef("PDFLink");
- m_Page = page;
- m_NativePointer = nativePointer;
- }
- ~PDFLink()
- {
- Dispose(false);
- }
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
- protected virtual void Dispose(bool disposing)
- {
- if (!m_Disposed)
- {
- m_NativePointer = IntPtr.Zero;
- PDFLibrary.RemoveRef("PDFLink");
- m_Disposed = true;
- }
- }
- public PDFPage Page
- {
- get { return m_Page; }
- }
- public IntPtr NativePointer
- {
- get { return m_NativePointer; }
- }
- /// <summary>
- /// Gets the named destination assigned to a link. Return null if there is no destination associated with the link,
- /// in this case the application should try GetAction() instead.
- /// </summary>
- /// <returns></returns>
- public PDFDest GetDest()
- {
- IntPtr destPtr = NativeMethods.FPDFLink_GetDest(m_Page.Document.NativePointer, m_NativePointer);
- if (destPtr != IntPtr.Zero)
- return new PDFDest(this, destPtr);
- return null;
- }
- /// <summary>
- /// Gets the PDF action assigned to a link.
- /// </summary>
- /// <returns></returns>
- public PDFAction GetAction()
- {
- IntPtr actionPtr = NativeMethods.FPDFLink_GetAction(m_NativePointer);
- if (actionPtr != IntPtr.Zero)
- return new PDFAction(this, actionPtr);
- return null;
- }
- }
- #endif
- }
|