Пример #1
0
 public static bool FPDF_SaveAsCopy(IntPtr document, FPDF_FILEWRITE saveData, int flag)
 {
     lock (LockObj)
     {
         return(Imports.FPDF_SaveAsCopy(document, saveData, flag));
     }
 }
Пример #2
0
        public byte[] GetPDFPage(int pageNumber)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            IntPtr newDocument = NativePdfiumMethods.FPDF_CreateNewDocument();

            var bl = NativePdfiumMethods.FPDF_ImportPages(newDocument, _document, pageNumber.ToString(), 0);

            int pageCount = NativePdfiumMethods.FPDF_GetPageCount(newDocument);


            using (MemoryStream ms = new MemoryStream())
            {
                FPDF_FILEWRITE saveData = new FPDF_FILEWRITE();
                saveData.WriteBlock = (WriteBlockCallback)((pThis, buffer, buflen) =>
                {
                    ms.Write(buffer, 0, buffer.Length);
                    return(true);
                });
                try
                {
                    NativePdfiumMethods.FPDF_SaveAsCopy(newDocument, saveData, 1);
                }
                finally
                {
                    GC.KeepAlive((object)saveData);
                }

                NativePdfiumMethods.FPDF_CloseDocument(newDocument);

                return(ms.ToArray());
            }
        }
Пример #3
0
 public static extern bool FPDF_SaveAsCopy(IntPtr document, [MarshalAs(UnmanagedType.LPStruct)] FPDF_FILEWRITE saveData, int flag);