public static InMemoryPdfDocument Open(Stream stream, string password = null) { using var memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] buffer = memoryStream.ToArray(); var handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); NativeMethods.DocumentHandle documentHandle = NativeMethods.LoadDocument(handle.AddrOfPinnedObject(), buffer.Length, password); return(new InMemoryPdfDocument(documentHandle, handle)); }
internal InMemoryPdfDocument(NativeMethods.DocumentHandle documentHandle, GCHandle handle) : base(documentHandle) { _handle = handle; }
internal PdfDocument(NativeMethods.DocumentHandle documentHandle) { _documentHandle = documentHandle; }