private void LoadFile(Stream stream, string password) { PdfLibrary.EnsureLoaded(); _stream = stream ?? throw new ArgumentNullException(nameof(stream)); _id = StreamManager.Register(stream); var document = NativeMethods.FPDF_LoadCustomDocument(stream, password, _id); if (document == IntPtr.Zero) { throw new PdfException((PdfError)NativeMethods.FPDF_GetLastError()); } LoadDocument(document); }
public static bool FPDF_SaveWithVersion(IntPtr doc, Stream output, FPDF_SAVE_FLAGS flags, int fileVersion) { int id = StreamManager.Register(output); try { var write = new FPDF_FILEWRITE { stream = (IntPtr)id, version = 1, WriteBlock = Marshal.GetFunctionPointerForDelegate(_saveBlockDelegate) }; lock (LockString) { return(Imports.FPDF_SaveWithVersion(doc, write, flags, fileVersion)); } } finally { StreamManager.Unregister(id); } }