30 internal readonly IntPtr NativeContext;
39 return (
long)NativeMethods.GetCurrentStoreSize(this.NativeContext);
50 return (
long)NativeMethods.GetMaxStoreSize(this.NativeContext);
62 if (value < 0 || value > 8)
64 throw new ArgumentOutOfRangeException(nameof(value), value,
"The anti-aliasing level must range between 0 and 8 (inclusive).");
67 NativeMethods.SetAALevel(this.NativeContext, value, -1, -1);
78 NativeMethods.GetAALevel(this.NativeContext, out _, out _, out
int tbr);
84 if (value < 0 || value > 8)
86 throw new ArgumentOutOfRangeException(nameof(value), value,
"The anti-aliasing level must range between 0 and 8 (inclusive).");
89 NativeMethods.SetAALevel(this.NativeContext, -1, -1, value);
100 NativeMethods.GetAALevel(this.NativeContext, out _, out
int tbr, out _);
106 if (value < 0 || value > 8)
108 throw new ArgumentOutOfRangeException(nameof(value), value,
"The anti-aliasing level must range between 0 and 8 (inclusive).");
112 NativeMethods.SetAALevel(this.NativeContext, -1, value, prevTxt);
122 ExitCodes result = (
ExitCodes)NativeMethods.CreateContext((ulong)storeSize, ref NativeContext);
128 case ExitCodes.ERR_CANNOT_CREATE_CONTEXT:
130 case ExitCodes.ERR_CANNOT_REGISTER_HANDLERS:
131 throw new MuPDFException(
"Cannot register document handlers", result);
143 this.NativeContext = nativeContext;
151 NativeMethods.EmptyStore(this.NativeContext);
164 else if (Math.Round(fraction * 100) < 100)
166 NativeMethods.ShrinkStore(this.NativeContext, (uint)Math.Round(fraction * 100));
170 private bool disposedValue;
173 protected virtual void Dispose(
bool disposing)
182 NativeMethods.DisposeContext(NativeContext);
183 disposedValue =
true;
190 Dispose(disposing:
false);
194 public void Dispose()
196 Dispose(disposing:
true);
197 GC.SuppressFinalize(
this);
A wrapper around a MuPDF context object, which contains the exception stack and the resource cache st...
int AntiAliasing
Sets the current anti-aliasing level. Changing this value will affect both the TextAntiAliasing and t...
int GraphicsAntiAliasing
Gets or sets the current graphics anti-aliasing level.
void ClearStore()
Evict all items from the resource cache store (freeing the memory where they were held).
void ShrinkStore(double fraction)
Evict items from the resource cache store (freeing the memory where they were held) until the the siz...
long StoreMaxSize
The maximum size in bytes of the resource cache store. Read-only.
int TextAntiAliasing
Gets or sets the current text anti-aliasing level.
MuPDFContext(uint storeSize=256<< 20)
Create a new MuPDFContext instance with the specified cache store size.
long StoreSize
The current size in bytes of the resource cache store. Read-only.
The exception that is thrown when a MuPDF operation fails.
ExitCodes
Exit codes returned by native methods describing various errors that can occur.