diff --git a/Documentation/Documentation.shfbproj b/Documentation/Documentation.shfbproj index dec66b8..188b11d 100644 --- a/Documentation/Documentation.shfbproj +++ b/Documentation/Documentation.shfbproj @@ -115,7 +115,7 @@ - + ..\PDFiumSharp.GdiPlus\bin\Release\System.ValueTuple.dll True diff --git a/Nuget/PDFium.LinuxV2.nuspec b/Nuget/PDFium.LinuxV2.nuspec new file mode 100644 index 0000000..633068a --- /dev/null +++ b/Nuget/PDFium.LinuxV2.nuspec @@ -0,0 +1,23 @@ + + + + PDFium.LinuxV2 + 1.1.4 + Foxit, Google + Zubastic + false + MS-RL + https://github.com/chromium/pdfium/ + + PDFium library binaries for linux (pdfium_x64.so, pdfium_x86.so, libpdfium.so). Libs from repo: https://github.com/bblanchon/pdfium-binaries + + + PDF PDFium Renderer Rendering + + + + + + + + \ No newline at end of file diff --git a/Nuget/PDFium.LinuxV2.props b/Nuget/PDFium.LinuxV2.props new file mode 100644 index 0000000..c3fa85f --- /dev/null +++ b/Nuget/PDFium.LinuxV2.props @@ -0,0 +1,17 @@ + + + + + pdfium_x64.so + PreserveNewest + + + pdfium_x86.so + PreserveNewest + + + libpdfium.so + PreserveNewest + + + \ No newline at end of file diff --git a/Nuget/PDFium.Windows.nuspec b/Nuget/PDFium.Windows.nuspec deleted file mode 100644 index 47f517e..0000000 --- a/Nuget/PDFium.Windows.nuspec +++ /dev/null @@ -1,21 +0,0 @@ - - - - PDFium.Windows - 1.0.0 - Foxit, Google - ArgusMagnus - false - https://pdfium.googlesource.com/pdfium/+/master/LICENSE - https://pdfium.googlesource.com/pdfium/ - PDFium library binaries for windows (pdfium_x64.dll, pdfium_x86.dll). - - - PDF PDFium Renderer Rendering - - - - - - - \ No newline at end of file diff --git a/Nuget/PDFium.WindowsV2.nuspec b/Nuget/PDFium.WindowsV2.nuspec new file mode 100644 index 0000000..24b48d5 --- /dev/null +++ b/Nuget/PDFium.WindowsV2.nuspec @@ -0,0 +1,22 @@ + + + + PDFium.WindowsV2 + 1.1.4 + Foxit, Google + ArgusMagnus + false + MS-RL + https://github.com/chromium/pdfium/ + + PDFium library binaries for windows (pdfium_x64.dll, pdfium_x86.dll). Libs from repo: https://github.com/bblanchon/pdfium-binaries + + + PDF PDFium Renderer Rendering + + + + + + + \ No newline at end of file diff --git a/Nuget/PDFium.Windows.targets b/Nuget/PDFium.WindowsV2.props similarity index 63% rename from Nuget/PDFium.Windows.targets rename to Nuget/PDFium.WindowsV2.props index 2664745..4d58af1 100644 --- a/Nuget/PDFium.Windows.targets +++ b/Nuget/PDFium.WindowsV2.props @@ -1,10 +1,11 @@ - + + pdfium_x64.dll PreserveNewest - + pdfium_x86.dll PreserveNewest diff --git a/Nuget/PDFiumSharp.GdiPlus.nuspec b/Nuget/PDFiumSharp.GdiPlus.nuspec deleted file mode 100644 index c7c795c..0000000 --- a/Nuget/PDFiumSharp.GdiPlus.nuspec +++ /dev/null @@ -1,24 +0,0 @@ - - - - PDFiumSharp.GdiPlus - 0.1.1-beta - ArgusMagnus - ArgusMagnus - true - https://github.com/ArgusMagnus/PDFiumSharp/blob/master/LICENSE - https://github.com/ArgusMagnus/PDFiumSharp - GDI+ (System.Drawing) extensions for PDFiumSharp. - - Copyright 2017 - C# PDF PDFium Renderer Rendering - - - - - - - - - - \ No newline at end of file diff --git a/Nuget/PDFiumSharp.GdiPlusV2.nuspec b/Nuget/PDFiumSharp.GdiPlusV2.nuspec new file mode 100644 index 0000000..fb1de5d --- /dev/null +++ b/Nuget/PDFiumSharp.GdiPlusV2.nuspec @@ -0,0 +1,25 @@ + + + + PDFiumSharp.GdiPlusV2 + 1.1.4 + ArgusMagnus + Zubastic + true + MS-RL + https://github.com/Zubastic/PDFiumSharp + + GDI+ (System.Drawing) extensions for PDFiumSharp. + + Copyright 2023 + C# PDF PDFium Renderer Rendering + + + + + + + + + + \ No newline at end of file diff --git a/Nuget/PDFiumSharp.Wpf.nuspec b/Nuget/PDFiumSharp.Wpf.nuspec deleted file mode 100644 index 369c3f3..0000000 --- a/Nuget/PDFiumSharp.Wpf.nuspec +++ /dev/null @@ -1,24 +0,0 @@ - - - - PDFiumSharp.Wpf - 0.1.0-beta - ArgusMagnus - ArgusMagnus - true - https://github.com/ArgusMagnus/PDFiumSharp/blob/master/LICENSE - https://github.com/ArgusMagnus/PDFiumSharp - WPF extensions for PDFiumSharp. - - Copyright 2017 - C# PDF PDFium Renderer Rendering - - - - - - - - - - \ No newline at end of file diff --git a/Nuget/PDFiumSharp.WpfV2.nuspec b/Nuget/PDFiumSharp.WpfV2.nuspec new file mode 100644 index 0000000..73743d8 --- /dev/null +++ b/Nuget/PDFiumSharp.WpfV2.nuspec @@ -0,0 +1,25 @@ + + + + PDFiumSharp.WpfV2 + 1.1.4 + ArgusMagnus + Zubastic + true + MS-RL + https://github.com/Zubastic/PDFiumSharp + + WPF extensions for PDFiumSharp. + + Copyright 2023 + C# PDF PDFium Renderer Rendering + + + + + + + + + + \ No newline at end of file diff --git a/Nuget/PDFiumSharp.Xwt.nuspec b/Nuget/PDFiumSharp.Xwt.nuspec deleted file mode 100644 index 82b033e..0000000 --- a/Nuget/PDFiumSharp.Xwt.nuspec +++ /dev/null @@ -1,25 +0,0 @@ - - - - PDFiumSharp.Xwt - 0.1.0-beta - ArgusMagnus - ArgusMagnus - true - https://github.com/ArgusMagnus/PDFiumSharp/blob/master/LICENSE - https://github.com/ArgusMagnus/PDFiumSharp - Mono XWT extensions for PDFiumSharp. - - Copyright 2017 - C# PDF PDFium Renderer Rendering - - - - - - - - - - - \ No newline at end of file diff --git a/Nuget/PDFiumSharp.XwtV2.nuspec b/Nuget/PDFiumSharp.XwtV2.nuspec new file mode 100644 index 0000000..b6662bb --- /dev/null +++ b/Nuget/PDFiumSharp.XwtV2.nuspec @@ -0,0 +1,26 @@ + + + + PDFiumSharp.XwtV2 + 1.1.4 + ArgusMagnus + Zubastic + true + MS-RL + https://github.com/Zubastic/PDFiumSharp + + Mono XWT extensions for PDFiumSharp. + + Copyright 2023 + C# PDF PDFium Renderer Rendering + + + + + + + + + + + \ No newline at end of file diff --git a/Nuget/PDFiumSharp.nuspec b/Nuget/PDFiumSharp.nuspec deleted file mode 100644 index 48f8981..0000000 --- a/Nuget/PDFiumSharp.nuspec +++ /dev/null @@ -1,27 +0,0 @@ - - - - PDFiumSharp - 0.1.1-beta - ArgusMagnus - ArgusMagnus - true - https://github.com/ArgusMagnus/PDFiumSharp/blob/master/LICENSE - https://github.com/ArgusMagnus/PDFiumSharp - C#/.NET Wrapper for the PDFium library. Add also a package for the native binaries (currently only PDFium.Windows is provided) or provide them (pdfium_x64.dll, pdfium_x86.dll) yourself. - Added methods to save PDFiumBitmaps in the BMP format and expose them as streams. - Copyright 2017 - C# PDF PDFium Renderer Rendering - - - - - - - - - - - - - \ No newline at end of file diff --git a/Nuget/PDFiumSharpV2.nuspec b/Nuget/PDFiumSharpV2.nuspec new file mode 100644 index 0000000..2f8ce09 --- /dev/null +++ b/Nuget/PDFiumSharpV2.nuspec @@ -0,0 +1,28 @@ + + + + PDFiumSharpV2 + 1.1.4 + ArgusMagnus + Zubastic + true + MS-RL + https://github.com/Zubastic/PDFiumSharp + + C#/.NET Wrapper for the PDFium library. Add also a package for the native binaries (currently only PDFium.Windows is provided) or provide them (pdfium_x64.dll, pdfium_x86.dll) yourself. + Updated for 5907 pdfium version. + Copyright 2023 + C# PDF PDFium Renderer Rendering + + + + + + + + + + + + + \ No newline at end of file diff --git a/Nuget/libpdfium.so b/Nuget/libpdfium.so new file mode 100644 index 0000000..ec1dce4 Binary files /dev/null and b/Nuget/libpdfium.so differ diff --git a/Nuget/nuget.exe b/Nuget/nuget.exe index 305300a..13dbd7b 100644 Binary files a/Nuget/nuget.exe and b/Nuget/nuget.exe differ diff --git a/Nuget/nuget_pack.bat b/Nuget/nuget_pack.bat index b0ca7a1..b4a37df 100644 --- a/Nuget/nuget_pack.bat +++ b/Nuget/nuget_pack.bat @@ -1,6 +1,8 @@ -nuget pack PDFium.Windows.nuspec -nuget pack PDFiumSharp.nuspec -nuget pack PDFiumSharp.GdiPlus.nuspec -nuget pack PDFiumSharp.Wpf.nuspec -nuget pack PDFiumSharp.Xwt.nuspec +@echo off +nuget pack PDFium.LinuxV2.nuspec +nuget pack PDFium.WindowsV2.nuspec +nuget pack PDFiumSharpV2.nuspec +nuget pack PDFiumSharp.GdiPlusV2.nuspec +nuget pack PDFiumSharp.WpfV2.nuspec +nuget pack PDFiumSharp.XwtV2.nuspec pause \ No newline at end of file diff --git a/Nuget/pdfium_x64.dll b/Nuget/pdfium_x64.dll index 86377cc..9f28658 100644 Binary files a/Nuget/pdfium_x64.dll and b/Nuget/pdfium_x64.dll differ diff --git a/Nuget/pdfium_x64.so b/Nuget/pdfium_x64.so new file mode 100644 index 0000000..ec1dce4 Binary files /dev/null and b/Nuget/pdfium_x64.so differ diff --git a/Nuget/pdfium_x86.dll b/Nuget/pdfium_x86.dll index b0457fe..b97a156 100644 Binary files a/Nuget/pdfium_x86.dll and b/Nuget/pdfium_x86.dll differ diff --git a/Nuget/pdfium_x86.so b/Nuget/pdfium_x86.so new file mode 100644 index 0000000..ddf1f1d Binary files /dev/null and b/Nuget/pdfium_x86.so differ diff --git a/PDFiumSharp.GdiPlus/PDFiumSharp.GdiPlus.csproj b/PDFiumSharp.GdiPlus/PDFiumSharp.GdiPlus.csproj index b097900..6416957 100644 --- a/PDFiumSharp.GdiPlus/PDFiumSharp.GdiPlus.csproj +++ b/PDFiumSharp.GdiPlus/PDFiumSharp.GdiPlus.csproj @@ -54,7 +54,7 @@ - 4.3.0 + 4.5.0 diff --git a/PDFiumSharp.GdiPlus/Properties/AssemblyInfo.cs b/PDFiumSharp.GdiPlus/Properties/AssemblyInfo.cs index 519d924..7bd3c38 100644 --- a/PDFiumSharp.GdiPlus/Properties/AssemblyInfo.cs +++ b/PDFiumSharp.GdiPlus/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/PDFiumSharp.GdiPlus/RenderingExtensionsGdiPlus.cs b/PDFiumSharp.GdiPlus/RenderingExtensionsGdiPlus.cs index 66fdbad..47a677a 100644 --- a/PDFiumSharp.GdiPlus/RenderingExtensionsGdiPlus.cs +++ b/PDFiumSharp.GdiPlus/RenderingExtensionsGdiPlus.cs @@ -6,11 +6,8 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Drawing; +using PDFiumSharp.Enums; namespace PDFiumSharp { @@ -40,7 +37,7 @@ public static void Render(this PdfPage page, Bitmap renderTarget, (int left, int /// Renders the page to a /// /// The page which is to be rendered. - /// The bitmap to which the page is to be rendered. + /// The bitmap to which the page is to be rendered. /// The orientation at which the page is to be rendered. /// The flags specifying how the page is to be rendered. public static void Render(this PdfPage page, Bitmap bitmap, PageOrientations orientation = PageOrientations.Normal, RenderingFlags flags = RenderingFlags.None) @@ -48,15 +45,19 @@ public static void Render(this PdfPage page, Bitmap bitmap, PageOrientations ori page.Render(bitmap, (0, 0, bitmap.Width, bitmap.Height), orientation, flags); } - static BitmapFormats GetBitmapFormat(System.Drawing.Bitmap bitmap) + static BitmapFormats GetBitmapFormat(Bitmap bitmap) { - if (bitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format24bppRgb) - return BitmapFormats.FPDFBitmap_BGR; - if (bitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb) - return BitmapFormats.FPDFBitmap_BGRA; - if (bitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppRgb) - return BitmapFormats.FPDFBitmap_BGRx; - throw new NotSupportedException($"Pixel format {bitmap.PixelFormat} is not supported."); - } + switch (bitmap.PixelFormat) + { + case System.Drawing.Imaging.PixelFormat.Format24bppRgb: + return BitmapFormats.BGR; + case System.Drawing.Imaging.PixelFormat.Format32bppArgb: + return BitmapFormats.BGRA; + case System.Drawing.Imaging.PixelFormat.Format32bppRgb: + return BitmapFormats.BGRx; + default: + throw new NotSupportedException($"Pixel format {bitmap.PixelFormat} is not supported."); + } + } } } diff --git a/PDFiumSharp.Wpf/PDFiumSharp.Wpf.csproj b/PDFiumSharp.Wpf/PDFiumSharp.Wpf.csproj index 5f28183..fc2e478 100644 --- a/PDFiumSharp.Wpf/PDFiumSharp.Wpf.csproj +++ b/PDFiumSharp.Wpf/PDFiumSharp.Wpf.csproj @@ -55,7 +55,7 @@ - 4.3.0 + 4.5.0 diff --git a/PDFiumSharp.Wpf/Properties/AssemblyInfo.cs b/PDFiumSharp.Wpf/Properties/AssemblyInfo.cs index 7cff08b..0a7d82e 100644 --- a/PDFiumSharp.Wpf/Properties/AssemblyInfo.cs +++ b/PDFiumSharp.Wpf/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/PDFiumSharp.Wpf/RenderingExtensionsWpf.cs b/PDFiumSharp.Wpf/RenderingExtensionsWpf.cs index 52ee925..cf46eaf 100644 --- a/PDFiumSharp.Wpf/RenderingExtensionsWpf.cs +++ b/PDFiumSharp.Wpf/RenderingExtensionsWpf.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; +using PDFiumSharp.Enums; namespace PDFiumSharp { @@ -65,13 +62,13 @@ public static void Render(this PdfPage page, WriteableBitmap renderTarget, PageO static BitmapFormats GetBitmapFormat(PixelFormat pixelFormat) { if (pixelFormat == PixelFormats.Bgra32) - return BitmapFormats.FPDFBitmap_BGRA; + return BitmapFormats.BGRA; if (pixelFormat == PixelFormats.Bgr32) - return BitmapFormats.FPDFBitmap_BGRx; + return BitmapFormats.BGRx; if (pixelFormat == PixelFormats.Bgr24) - return BitmapFormats.FPDFBitmap_BGR; + return BitmapFormats.BGR; if (pixelFormat == PixelFormats.Gray8) - return BitmapFormats.FPDFBitmap_Gray; + return BitmapFormats.Gray; throw new NotSupportedException($"Pixel format {pixelFormat} is not supported."); } } diff --git a/PDFiumSharp.Xwt/PDFiumSharp.Xwt.csproj b/PDFiumSharp.Xwt/PDFiumSharp.Xwt.csproj index 08d0f8d..39c4004 100644 --- a/PDFiumSharp.Xwt/PDFiumSharp.Xwt.csproj +++ b/PDFiumSharp.Xwt/PDFiumSharp.Xwt.csproj @@ -46,7 +46,7 @@ - 0.2.5 + 0.2.218 diff --git a/PDFiumSharp.Xwt/Properties/AssemblyInfo.cs b/PDFiumSharp.Xwt/Properties/AssemblyInfo.cs index 935130e..be377fc 100644 --- a/PDFiumSharp.Xwt/Properties/AssemblyInfo.cs +++ b/PDFiumSharp.Xwt/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/PDFiumSharp.Xwt/RenderingExtensionsXwt.cs b/PDFiumSharp.Xwt/RenderingExtensionsXwt.cs index 85fd0f1..393e1e8 100644 --- a/PDFiumSharp.Xwt/RenderingExtensionsXwt.cs +++ b/PDFiumSharp.Xwt/RenderingExtensionsXwt.cs @@ -6,11 +6,7 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Xwt; +using PDFiumSharp.Enums; using Xwt.Drawing; namespace PDFiumSharp @@ -30,11 +26,11 @@ public static void Render(this PdfPage page, BitmapImage renderTarget, (int left if (renderTarget == null) throw new ArgumentNullException(nameof(renderTarget)); - (var left, var top, var width, var height) = rectDest; + var (left, top, width, height) = rectDest; byte[] pixelBuffer = new byte[width * height * 4]; using (var pin = PinnedGCHandle.Pin(pixelBuffer)) - using (var tmpBitamp = new PDFiumBitmap(rectDest.width, rectDest.height, BitmapFormats.FPDFBitmap_BGRA, pin.Pointer, rectDest.width * 4)) + using (var tmpBitamp = new PDFiumBitmap(rectDest.width, rectDest.height, BitmapFormats.BGRA, pin.Pointer, rectDest.width * 4)) { page.Render(tmpBitamp, (0, 0, width, height), orientation, flags); for (int y = Math.Max(0, top); y < Math.Min(renderTarget.PixelHeight, top + height); y++) diff --git a/PDFiumSharp/ActionTypes.cs b/PDFiumSharp/Enums/ActionTypes.cs similarity index 89% rename from PDFiumSharp/ActionTypes.cs rename to PDFiumSharp/Enums/ActionTypes.cs index edca86a..f24b799 100644 --- a/PDFiumSharp/ActionTypes.cs +++ b/PDFiumSharp/Enums/ActionTypes.cs @@ -5,11 +5,7 @@ License: Microsoft Reciprocal License (MS-RL) */ # endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { /// /// PDF Action Types diff --git a/PDFiumSharp/BitmapFormats.cs b/PDFiumSharp/Enums/BitmapFormats.cs similarity index 73% rename from PDFiumSharp/BitmapFormats.cs rename to PDFiumSharp/Enums/BitmapFormats.cs index 1e299fc..b41e660 100644 --- a/PDFiumSharp/BitmapFormats.cs +++ b/PDFiumSharp/Enums/BitmapFormats.cs @@ -5,32 +5,28 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum BitmapFormats : int + public enum BitmapFormats { /// /// Gray scale bitmap, one byte per pixel. /// - FPDFBitmap_Gray = 1, + Gray = 1, /// /// 3 bytes per pixel, byte order: blue, green, red. /// - FPDFBitmap_BGR = 2, + BGR = 2, /// /// 4 bytes per pixel, byte order: blue, green, red, unused. /// - FPDFBitmap_BGRx = 3, + BGRx = 3, /// /// 4 bytes per pixel, byte order: blue, green, red, alpha. /// - FPDFBitmap_BGRA = 4 + BGRA = 4 } } diff --git a/PDFiumSharp/DocumentPermissions.cs b/PDFiumSharp/Enums/DocumentPermissions.cs similarity index 97% rename from PDFiumSharp/DocumentPermissions.cs rename to PDFiumSharp/Enums/DocumentPermissions.cs index f91e011..64b151b 100644 --- a/PDFiumSharp/DocumentPermissions.cs +++ b/PDFiumSharp/Enums/DocumentPermissions.cs @@ -6,10 +6,8 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Text; -namespace PDFiumSharp +namespace PDFiumSharp.Enums { /// /// Flags specifying document permissions. diff --git a/PDFiumSharp/DuplexTypes.cs b/PDFiumSharp/Enums/DuplexTypes.cs similarity index 71% rename from PDFiumSharp/DuplexTypes.cs rename to PDFiumSharp/Enums/DuplexTypes.cs index 962b299..d041c98 100644 --- a/PDFiumSharp/DuplexTypes.cs +++ b/PDFiumSharp/Enums/DuplexTypes.cs @@ -5,13 +5,9 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum DuplexTypes : int + public enum DuplexTypes { DuplexUndefined = 0, Simplex, diff --git a/PDFiumSharp/FlattenFlags.cs b/PDFiumSharp/Enums/FlattenFlags.cs similarity index 79% rename from PDFiumSharp/FlattenFlags.cs rename to PDFiumSharp/Enums/FlattenFlags.cs index 23b2fef..4cb5a90 100644 --- a/PDFiumSharp/FlattenFlags.cs +++ b/PDFiumSharp/Enums/FlattenFlags.cs @@ -5,14 +5,10 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum FlattenFlags : int - { + public enum FlattenFlags + { /// /// Flatten for normal display. /// @@ -24,8 +20,8 @@ public enum FlattenFlags : int Print = 1 } - public enum FlattenResults : int - { + public enum FlattenResults + { /// /// Flatten operation failed. /// diff --git a/PDFiumSharp/FontTypes.cs b/PDFiumSharp/Enums/FontTypes.cs similarity index 67% rename from PDFiumSharp/FontTypes.cs rename to PDFiumSharp/Enums/FontTypes.cs index e6b6c79..d6d1eff 100644 --- a/PDFiumSharp/FontTypes.cs +++ b/PDFiumSharp/Enums/FontTypes.cs @@ -5,14 +5,10 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum FontTypes : int - { + public enum FontTypes + { Type1 = 1, TrueType = 2 } diff --git a/PDFiumSharp/MetadataTags.cs b/PDFiumSharp/Enums/MetadataTags.cs similarity index 79% rename from PDFiumSharp/MetadataTags.cs rename to PDFiumSharp/Enums/MetadataTags.cs index 6beb694..d70610b 100644 --- a/PDFiumSharp/MetadataTags.cs +++ b/PDFiumSharp/Enums/MetadataTags.cs @@ -5,11 +5,7 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { public enum MetadataTags { diff --git a/PDFiumSharp/Enums/ObjectTypes.cs b/PDFiumSharp/Enums/ObjectTypes.cs new file mode 100644 index 0000000..7e74a08 --- /dev/null +++ b/PDFiumSharp/Enums/ObjectTypes.cs @@ -0,0 +1,19 @@ +namespace PDFiumSharp.Enums +{ + /// + /// PDF object types + /// + public enum ObjectTypes + { + Unknown = 0, + Boolean = 1, + Number = 2, + String = 3, + Name = 4, + Array = 5, + Dictionary = 6, + Stream = 7, + Nullobj = 8, + Reference = 9 + } +} diff --git a/PDFiumSharp/PageModes.cs b/PDFiumSharp/Enums/PageModes.cs similarity index 87% rename from PDFiumSharp/PageModes.cs rename to PDFiumSharp/Enums/PageModes.cs index f90367d..d854e3d 100644 --- a/PDFiumSharp/PageModes.cs +++ b/PDFiumSharp/Enums/PageModes.cs @@ -5,14 +5,10 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum PageModes : int - { + public enum PageModes + { /// /// Unknown page mode. /// diff --git a/PDFiumSharp/Enums/PageObjTypes.cs b/PDFiumSharp/Enums/PageObjTypes.cs new file mode 100644 index 0000000..81f044c --- /dev/null +++ b/PDFiumSharp/Enums/PageObjTypes.cs @@ -0,0 +1,12 @@ +namespace PDFiumSharp.Enums +{ + public enum PageObjTypes + { + Unknown = 0, + Text = 1, + Path = 2, + Image = 3, + Shading = 4, + Form = 5, + } +} diff --git a/PDFiumSharp/PageOrientations.cs b/PDFiumSharp/Enums/PageOrientations.cs similarity index 70% rename from PDFiumSharp/PageOrientations.cs rename to PDFiumSharp/Enums/PageOrientations.cs index 63457a1..de5fdd0 100644 --- a/PDFiumSharp/PageOrientations.cs +++ b/PDFiumSharp/Enums/PageOrientations.cs @@ -5,13 +5,9 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum PageOrientations : int + public enum PageOrientations { Normal = 0, Rotated90CW = 1, diff --git a/PDFiumSharp/PathFillModes.cs b/PDFiumSharp/Enums/PathFillModes.cs similarity index 69% rename from PDFiumSharp/PathFillModes.cs rename to PDFiumSharp/Enums/PathFillModes.cs index 16013d7..f49a48d 100644 --- a/PDFiumSharp/PathFillModes.cs +++ b/PDFiumSharp/Enums/PathFillModes.cs @@ -5,13 +5,9 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum PathFillModes : int + public enum PathFillModes { NoFill = 0, Alternate = 1, diff --git a/PDFiumSharp/RenderingFlags.cs b/PDFiumSharp/Enums/RenderingFlags.cs similarity index 93% rename from PDFiumSharp/RenderingFlags.cs rename to PDFiumSharp/Enums/RenderingFlags.cs index 9b594ad..881d038 100644 --- a/PDFiumSharp/RenderingFlags.cs +++ b/PDFiumSharp/Enums/RenderingFlags.cs @@ -6,14 +6,12 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Text; -namespace PDFiumSharp +namespace PDFiumSharp.Enums { [Flags] - public enum RenderingFlags : int - { + public enum RenderingFlags + { None = 0, /// diff --git a/PDFiumSharp/RenderingStatus.cs b/PDFiumSharp/Enums/RenderingStatus.cs similarity index 78% rename from PDFiumSharp/RenderingStatus.cs rename to PDFiumSharp/Enums/RenderingStatus.cs index 293e82a..2eb3e37 100644 --- a/PDFiumSharp/RenderingStatus.cs +++ b/PDFiumSharp/Enums/RenderingStatus.cs @@ -5,11 +5,7 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { public enum RenderingStatus : int { diff --git a/PDFiumSharp/SaveFlags.cs b/PDFiumSharp/Enums/SaveFlags.cs similarity index 71% rename from PDFiumSharp/SaveFlags.cs rename to PDFiumSharp/Enums/SaveFlags.cs index cf19747..5c4bbb8 100644 --- a/PDFiumSharp/SaveFlags.cs +++ b/PDFiumSharp/Enums/SaveFlags.cs @@ -5,14 +5,10 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { - public enum SaveFlags : int - { + public enum SaveFlags + { None = 0, Incremental = 1, NotIncremental = 2, diff --git a/PDFiumSharp/SearchFlags.cs b/PDFiumSharp/Enums/SearchFlags.cs similarity index 84% rename from PDFiumSharp/SearchFlags.cs rename to PDFiumSharp/Enums/SearchFlags.cs index 6c5fd6c..7784065 100644 --- a/PDFiumSharp/SearchFlags.cs +++ b/PDFiumSharp/Enums/SearchFlags.cs @@ -5,11 +5,7 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp +namespace PDFiumSharp.Enums { public enum SearchFlags : uint { diff --git a/PDFiumSharp/Enums/ZoomModes.cs b/PDFiumSharp/Enums/ZoomModes.cs new file mode 100644 index 0000000..0250e40 --- /dev/null +++ b/PDFiumSharp/Enums/ZoomModes.cs @@ -0,0 +1,15 @@ +namespace PDFiumSharp.Enums +{ + public enum ZoomModes + { + Unknown = 0, + XYZ = 1, + Fit = 2, + FitH = 3, + FitV = 4, + FitR = 5, + FitB = 6, + FitBH = 7, + FitBV = 8 + } +} diff --git a/PDFiumSharp/PDFium.cs b/PDFiumSharp/PDFium.cs index 76b164d..4f8dd2e 100644 --- a/PDFiumSharp/PDFium.cs +++ b/PDFiumSharp/PDFium.cs @@ -1,394 +1,431 @@ #region Copyright and License + /* This file is part of PDFiumSharp, a wrapper around the PDFium library for the .NET framework. Copyright (C) 2017 Tobias Meyer License: Microsoft Reciprocal License (MS-RL) */ + #endregion + using System; -using System.Runtime.InteropServices; -using PDFiumSharp.Types; +using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; -using System.Globalization; +using System.Runtime.InteropServices; using System.Text; -using System.Collections.Generic; +using PDFiumSharp.Enums; +using PDFiumSharp.Types; namespace PDFiumSharp { - /// - /// Static class containing the native (imported) PDFium functions. - /// In case of missing documentation, refer to the PDFium header files. - /// - public static partial class PDFium + /// + /// Static class containing the native (imported) PDFium functions. + /// In case of missing documentation, refer to the + /// PDFium header files. + /// + public static partial class PDFium { - /// - /// Gets a value indicating whether the PDFium library is available. - /// false is returned if the native libraries could not be - /// loaded for some reason. - /// - public static bool IsAvailable { get; } - - static PDFium() - { - IsAvailable = Initialize(); - } - - static bool Initialize() - { - try { PDFium.FPDF_InitLibrary(); } - catch { return false; } - return true; - } - - delegate int GetStringHandler(ref byte buffer, int length); - - static string GetUtf16String(GetStringHandler handler, int lengthUnit, bool lengthIncludesTerminator) - { - byte b = 0; - int length = handler(ref b, 0); - var buffer = new byte[length * lengthUnit]; - handler(ref buffer[0], length); - length *= lengthUnit; - if (lengthIncludesTerminator) - length -= 2; - return Encoding.Unicode.GetString(buffer, 0, length); - } - - static string GetAsciiString(GetStringHandler handler) - { - byte b = 0; - int length = handler(ref b, 0); - var buffer = new byte[length]; - handler(ref buffer[0], length); - return Encoding.ASCII.GetString(buffer, 0, (int)length - 1); - } - - static string GetUtf8String(GetStringHandler handler) - { - byte b = 0; - int length = handler(ref b, 0); - var buffer = new byte[length]; - handler(ref buffer[0], length); - return Encoding.UTF8.GetString(buffer, 0, (int)length - 1); - } - - #region https://pdfium.googlesource.com/pdfium/+/master/public/fpdfview.h - - /// - /// Loads a PDF document from memory. - /// - /// The data to load the document from. - /// The index of the first byte to be copied from . - /// The number of bytes to copy from or a negative value to copy all bytes. - public static FPDF_DOCUMENT FPDF_LoadDocument(byte[] data, int index = 0, int count = -1, string password = null) - { - if (count < 0) - count = data.Length - index; - return FPDF_LoadMemDocument(ref data[index], count, password); - } + /// + /// Gets a value indicating whether the PDFium library is available. + /// false is returned if the native libraries could not be + /// loaded for some reason. + /// + public static bool IsAvailable { get; } + + static PDFium() => IsAvailable = Initialize(); + + private static bool Initialize() + { + try + { + FPDF_InitLibrary(); + } + catch + { + return false; + } + + return true; + } + + private delegate int GetStringHandler(ref byte buffer, int length); + + private static string GetUtf16String(GetStringHandler handler, int lengthUnit, bool lengthIncludesTerminator) + { + byte b = 0; + var length = handler(ref b, 0); + if (length == 0) + { + return string.Empty; + } + + var buffer = new byte[length * lengthUnit]; + handler(ref buffer[0], length); + length *= lengthUnit; + if (lengthIncludesTerminator) + { + length -= 2; + } + + return Encoding.Unicode.GetString(buffer, 0, length); + } + + private static string GetAsciiString(GetStringHandler handler) + { + byte b = 0; + var length = handler(ref b, 0); + if (length == 0) + { + return string.Empty; + } + + var buffer = new byte[length]; + handler(ref buffer[0], length); + return Encoding.ASCII.GetString(buffer, 0, length - 1); + } + + private static string GetUtf8String(GetStringHandler handler) + { + byte b = 0; + var length = handler(ref b, 0); + if (length == 0) + { + return string.Empty; + } + + var buffer = new byte[length]; + handler(ref buffer[0], length); + return Encoding.UTF8.GetString(buffer, 0, length - 1); + } + + #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdfview.h /// - /// Loads a PDF document from '' bytes read from a stream. + /// Loads a PDF document from memory. + /// + /// The data to load the document from. + /// The index of the first byte to be copied from . + /// The number of bytes to copy from or a negative value to copy all bytes. + /// Pdf password + public static FPDF_DOCUMENT FPDF_LoadDocument(byte[] data, int index = 0, int count = -1, string password = null) + { + if (count < 0) + { + count = data.Length - index; + } + + return FPDF_LoadMemDocument(ref data[index], count, password); + } + + /// + /// Loads a PDF document from '' bytes read from a stream. /// /// /// - /// The number of bytes to read from the . - /// If the value is equal to or smaller than 0, the stream is read to the end. + /// The number of bytes to read from the . + /// If the value is equal to or smaller than 0, the stream is read to the end. /// /// + /// Pdf password public static FPDF_DOCUMENT FPDF_LoadDocument(Stream stream, FPDF_FILEREAD fileRead, int count = 0, string password = null) + => FPDF_LoadCustomDocument(fileRead, password); + + //public static string FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document, string key) + //{ + // byte b = 0; + // uint length = FPDF_VIEWERREF_GetName(document, key, ref b, 0); + // if (length == 0) + // return null; + // var buffer = new byte[length]; + // FPDF_VIEWERREF_GetName(document, key, ref buffer[0], length); + // return Encoding.UTF8.GetString(buffer); + //} + + /// + /// Get the named destination by index. + /// + /// Handle to a document. + /// The index of a named destination. + /// + /// The destination handle and name for a given index, or (, null) + /// if there is no named destination corresponding to . + /// + /// + /// + public static (FPDF_DEST Destination, string Name) FPDF_GetNamedDest(FPDF_DOCUMENT document, int index) + { + FPDF_GetNamedDest(document, index, IntPtr.Zero, out var length); + if (length < 1) + { + return (FPDF_DEST.Null, null); + } + + var buffer = new byte[length]; + var dest = FPDF_GetNamedDest(document, index, ref buffer[0], ref length); + if (length < 1) + { + return (FPDF_DEST.Null, null); + } + + return (dest, Encoding.Unicode.GetString(buffer, 0, length - 2)); + } + + #endregion + + #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdf_doc.h + + /// + /// Get the title of . + /// + /// Handle to the bookmark. + /// The title of the bookmark. + public static string FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark) + => GetUtf16String((ref byte buffer, int length) => (int)FPDFBookmark_GetTitle(bookmark, ref buffer, (uint)length), sizeof(byte), true); + + /// + /// Gets the file path of a of type or + /// . + /// + /// + /// Handle to the action. Must be of type or + /// . + /// + /// The file path of . + /// + public static string FPDFAction_GetFilePath(FPDF_ACTION action) + => GetUtf16String((ref byte buffer, int length) => (int)FPDFAction_GetFilePath(action, ref buffer, (uint)length), sizeof(byte), true); + + /// + /// Gets URI path of a of type . + /// + /// Handle to the document. + /// Handle to the action. Must be of type . + /// The URI path of . + /// + public static string FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION action) + => GetAsciiString((ref byte buffer, int length) => (int)FPDFAction_GetURIPath(document, action, ref buffer, (uint)length)); + + /// + /// Enumerates all the link annotations in . + /// + /// Handle to the page. + /// All the link annotations in . + public static IEnumerable FPDFLink_Enumerate(FPDF_PAGE page) { - return FPDF_LoadCustomDocument(fileRead, password); + var pos = 0; + while (FPDFLink_Enumerate(page, ref pos, out var link)) + { + yield return link; + } } - //public static string FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document, string key) - //{ - // byte b = 0; - // uint length = FPDF_VIEWERREF_GetName(document, key, ref b, 0); - // if (length == 0) - // return null; - // var buffer = new byte[length]; - // FPDF_VIEWERREF_GetName(document, key, ref buffer[0], length); - // return Encoding.UTF8.GetString(buffer); - //} - - /// - /// Get the named destination by index. - /// - /// Handle to a document. - /// The index of a named destination. - /// - /// The destination handle and name for a given index, or (, null) - /// if there is no named destination corresponding to . - /// - /// - /// - public static (FPDF_DEST Destination, string Name) FPDF_GetNamedDest(FPDF_DOCUMENT document, int index) - { - FPDF_GetNamedDest(document, index, IntPtr.Zero, out int length); - if (length < 1) - return (FPDF_DEST.Null, null); - var buffer = new byte[length]; - var dest = FPDF_GetNamedDest(document, index, ref buffer[0], ref length); - if (length < 1) - return (FPDF_DEST.Null, null); - return (dest, Encoding.Unicode.GetString(buffer, 0, (int)length - 2)); - } - - #endregion - - #region https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_doc.h - - /// - /// Get the title of . - /// - /// Handle to the bookmark. - /// The title of the bookmark. - public static string FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark) - { - return GetUtf16String((ref byte buffer, int length) => (int)FPDFBookmark_GetTitle(bookmark, ref buffer, (uint)length), sizeof(byte), true); - } - - /// - /// Gets the file path of a of type or . - /// - /// Handle to the action. Must be of type or . - /// The file path of . - /// - public static string FPDFAction_GetFilePath(FPDF_ACTION action) - { - return GetUtf16String((ref byte buffer, int length) => (int)FPDFAction_GetFilePath(action, ref buffer, (uint)length), sizeof(byte), true); - } - - /// - /// Gets URI path of a of type . - /// - /// Handle to the document. - /// Handle to the action. Must be of type . - /// The URI path of . - /// - public static string FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION action) - { - return GetAsciiString((ref byte buffer, int length) => (int)FPDFAction_GetURIPath(document, action, ref buffer, (uint)length)); - } - - /// - /// Enumerates all the link annotations in . - /// - /// Handle to the page. - /// All the link annotations in . - public static IEnumerable FPDFLink_Enumerate(FPDF_PAGE page) - { - int pos = 0; - while (FPDFLink_Enumerate(page, ref pos, out var link)) - yield return link; - } - - /// - /// Get meta-data content from . - /// - /// Handle to the document. - /// - /// The tag to retrieve. The tag can be one of: - /// Title, Author, Subject, Keywords, Creator, Producer, - /// CreationDate, or ModDate. - /// - /// The meta-data. - /// - /// For detailed explanations of these tags and their respective - /// values, please refer to PDF Reference 1.6, section 10.2.1, - /// 'Document Information Dictionary'. - /// - /// PDF Reference - /// - public static string FPDF_GetMetaText(FPDF_DOCUMENT document, string tag) - { - return GetUtf16String((ref byte buffer, int length) => (int)FPDF_GetMetaText(document, tag, ref buffer, (uint)length), sizeof(byte), true); - } - - /// - /// Get meta-data content from . - /// - /// Handle to the document. - /// The tag to retrieve. - /// The meta-data. - /// - /// For detailed explanations of these tags and their respective - /// values, please refer to PDF Reference 1.6, section 10.2.1, - /// 'Document Information Dictionary'. - /// - /// PDF Reference - /// - public static string FPDF_GetMetaText(FPDF_DOCUMENT document, MetadataTags tag) => FPDF_GetMetaText(document, tag.ToString()); - - /// - /// Get the page label for from . - /// - /// Handle to the document. - /// The zero-based index of the page. - /// The page label. - /// - //public static string FPDF_GetPageLabel(FPDF_DOCUMENT document, int page_index) - //{ - // return GetUtf16String((ref byte buffer, int length) => (int)FPDF_GetPageLabel(document, page_index, ref buffer, (uint)length), sizeof(byte), true); - //} - - #endregion - - #region https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_edit.h - - /// - /// Insert into . - /// - /// Handle to a page. - /// Handle to a page object. The will be automatically freed. - public static void FPDFPage_InsertObject(FPDF_PAGE page, ref FPDF_PAGEOBJECT page_obj) - { - FPDFPage_InsertObject(page, page_obj); - page_obj = FPDF_PAGEOBJECT.Null; - } - - /// - /// Load an image from a JPEG image file and then set it into . - /// - /// All loaded pages, may be null. - /// Handle to an image object. - /// Stream which provides access to an JPEG image. - /// The number of bytes to read from or 0 to read to the end. - /// - /// If true, this function loads the JPEG image inline, so the image - /// content is copied to the file. This allows - /// to be closed after this function returns. - /// - /// true on success. - /// - /// The image object might already have an associated image, which is shared and - /// cached by the loaded pages. In that case, we need to clear the cached image - /// for all the loaded pages. Pass to this API - /// to clear the image cache. If the image is not previously shared, null is a - /// valid value. - /// - public static bool FPDFImageObj_LoadJpegFile(FPDF_PAGE[] loadedPages, FPDF_PAGEOBJECT image_object, Stream stream, int count = 0, bool inline = true) - { - if (inline) - return FPDFImageObj_LoadJpegFileInline(ref loadedPages[0], loadedPages.Length, image_object, FPDF_FILEREAD.FromStream(stream, count)); - else - return FPDFImageObj_LoadJpegFile(ref loadedPages[0], loadedPages.Length, image_object, FPDF_FILEREAD.FromStream(stream, count)); - } - - /// - /// Set to . - /// - /// All loaded pages, may be null. - /// Handle to an image object. - /// Handle of the bitmap. - /// true on success. - public static bool FPDFImageObj_SetBitmap(FPDF_PAGE[] loadedPages, FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap) - { - return FPDFImageObj_SetBitmap(ref loadedPages[0], loadedPages.Length, image_object, bitmap); - } - - /// - /// Returns a font object loaded from a stream of data. The font is loaded - /// into the document. The caller does not need to free the returned object. - /// - /// Handle to the document. - /// A value specifying if the font is a CID font or not. - /// The data, which will be copied by the font object. - /// The index of the first byte to be copied from . - /// The number of bytes to copy from or a negative value to copy all bytes. - /// Returns NULL on failure. - public static FPDF_FONT FPDFText_LoadFont(FPDF_DOCUMENT document, FontTypes font_type, bool cid, byte[] data, int index = -1, int count = 0) - { - if (count < 0) - count = data.Length - index; - return FPDFText_LoadFont(document, ref data[index], (uint)count, font_type, cid); - } - - #endregion - - #region https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_ppo.h - - /// - /// Imports pages from to - /// - /// Zero-based index of where the imported pages should be inserted in the destination document. - /// Zero-based indices of the pages to import in the source document - public static bool FPDF_ImportPages(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc, int index, params int[] srcPageIndices) - { - string pageRange = null; - if (srcPageIndices != null && srcPageIndices.Length > 0) - pageRange = string.Join(",", srcPageIndices.Select(p => (p + 1).ToString(CultureInfo.InvariantCulture))); - return FPDF_ImportPages(dest_doc, src_doc, pageRange, index); - } - - #endregion - - #region https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_save.h - - /// - /// Saves a PDF document to a stream. - /// - /// - /// The new PDF file version of the saved file. - /// 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored. - /// - /// - /// - public static bool FPDF_SaveAsCopy(FPDF_DOCUMENT document, Stream stream, SaveFlags flags, int version = 0) - { - byte[] buffer = null; - FPDF_FILEWRITE fileWrite = new FPDF_FILEWRITE((ignore, data, size) => - { - if (buffer == null || buffer.Length < size) - buffer = new byte[size]; - Marshal.Copy(data, buffer, 0, size); - stream.Write(buffer, 0, size); - return true; - }); - - if (version >= 10) - return FPDF_SaveWithVersion(document, fileWrite, flags, version); - else - return FPDF_SaveAsCopy(document, fileWrite, flags); - } - - #endregion - - #region https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_structtree.h - - /// - /// Get the alternative text for a given element. - /// - /// Handle to the struct element. - /// The alternative text for . - public static string FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element) - { - return GetUtf16String((ref byte buffer, int length) => (int)FPDF_StructElement_GetAltText(struct_element, ref buffer, (uint)length), sizeof(byte), true); - } - - #endregion - - #region https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_text.h - - public static string FPDFText_GetText(FPDF_TEXTPAGE text_page, int start_index, int count) - { - var buffer = new byte[2 * (count + 1)]; - int length = FPDFText_GetText(text_page, start_index, count, ref buffer[0]); - return Encoding.Unicode.GetString(buffer, 0, (length - 1) * 2); - } - - public static string FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, double left, double top, double right, double bottom) - { - return GetUtf16String((ref byte buffer, int length) => FPDFText_GetBoundedText(text_page, left, top, right, bottom, ref buffer, length), sizeof(ushort), false); - } - - public static string FPDFLink_GetURL(FPDF_PAGELINK link_page, int link_index) - { - return GetUtf16String((ref byte buffer, int length) => FPDFLink_GetURL(link_page, link_index, ref buffer, length), sizeof(ushort), true); - } - - #endregion - } -} + /// + /// Get meta-data content from . + /// + /// Handle to the document. + /// + /// The tag to retrieve. The tag can be one of: + /// Title, Author, Subject, Keywords, Creator, Producer, + /// CreationDate, or ModDate. + /// + /// The meta-data. + /// + /// For detailed explanations of these tags and their respective + /// values, please refer to PDF Reference 1.6, section 10.2.1, + /// 'Document Information Dictionary'. + /// + /// PDF Reference + /// + public static string FPDF_GetMetaText(FPDF_DOCUMENT document, string tag) => GetUtf16String((ref byte buffer, int length) + => (int)FPDF_GetMetaText(document, tag, ref buffer, (uint)length), sizeof(byte), true); + + /// + /// Get meta-data content from . + /// + /// Handle to the document. + /// The tag to retrieve. + /// The meta-data. + /// + /// For detailed explanations of these tags and their respective + /// values, please refer to PDF Reference 1.6, section 10.2.1, + /// 'Document Information Dictionary'. + /// + /// PDF Reference + /// + public static string FPDF_GetMetaText(FPDF_DOCUMENT document, MetadataTags tag) => FPDF_GetMetaText(document, tag.ToString()); + + /*/// + /// Get the page label for from . + /// + /// Handle to the document. + /// The zero-based index of the page. + /// The page label. + /// + public static string FPDF_GetPageLabel(FPDF_DOCUMENT document, int page_index) + { + return GetUtf16String((ref byte buffer, int length) => (int)FPDF_GetPageLabel(document, page_index, ref buffer, (uint)length), sizeof(byte), true); + }*/ + + #endregion + + #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdf_edit.h + + /// + /// Insert into . + /// + /// Handle to a page. + /// Handle to a page object. The will be automatically freed. + public static void FPDFPage_InsertObject(FPDF_PAGE page, ref FPDF_PAGEOBJECT page_obj) + { + FPDFPage_InsertObject(page, page_obj); + page_obj = FPDF_PAGEOBJECT.Null; + } + + /// + /// Load an image from a JPEG image file and then set it into . + /// + /// All loaded pages, may be null. + /// Handle to an image object. + /// Stream which provides access to an JPEG image. + /// The number of bytes to read from or 0 to read to the end. + /// + /// If true, this function loads the JPEG image inline, so the image + /// content is copied to the file. This allows + /// to be closed after this function returns. + /// + /// true on success. + /// + /// The image object might already have an associated image, which is shared and + /// cached by the loaded pages. In that case, we need to clear the cached image + /// for all the loaded pages. Pass to this API + /// to clear the image cache. If the image is not previously shared, null is a + /// valid value. + /// + public static bool FPDFImageObj_LoadJpegFile(FPDF_PAGE[] loadedPages, FPDF_PAGEOBJECT image_object, Stream stream, int count = 0, bool inline = true) + => inline + ? FPDFImageObj_LoadJpegFileInline(ref loadedPages[0], loadedPages.Length, image_object, FPDF_FILEREAD.FromStream(stream, count)) + : FPDFImageObj_LoadJpegFile(ref loadedPages[0], loadedPages.Length, image_object, FPDF_FILEREAD.FromStream(stream, count)); + + /// + /// Set to . + /// + /// All loaded pages, may be null. + /// Handle to an image object. + /// Handle of the bitmap. + /// true on success. + public static bool FPDFImageObj_SetBitmap(FPDF_PAGE[] loadedPages, FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap) + => FPDFImageObj_SetBitmap(ref loadedPages[0], loadedPages.Length, image_object, bitmap); + + /// + /// Returns a font object loaded from a stream of data. The font is loaded + /// into the document. The caller does not need to free the returned object. + /// + /// Handle to the document. + /// Font type. + /// A value specifying if the font is a CID font or not. + /// The data, which will be copied by the font object. + /// The index of the first byte to be copied from . + /// The number of bytes to copy from or a negative value to copy all bytes. + /// Returns NULL on failure. + public static FPDF_FONT FPDFText_LoadFont(FPDF_DOCUMENT document, FontTypes font_type, bool cid, byte[] data, int index = -1, int count = 0) + { + if (count < 0) + { + count = data.Length - index; + } + + return FPDFText_LoadFont(document, ref data[index], (uint)count, font_type, cid); + } + + #endregion + + #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdf_ppo.h + + /// + /// Imports pages from to + /// + /// Source document. + /// Destination document. + /// Zero-based index of where the imported pages should be inserted in the destination document. + /// Zero-based indices of the pages to import in the source document + public static bool FPDF_ImportPages(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc, int index, params int[] srcPageIndices) + { + string pageRange = null; + if (srcPageIndices != null && srcPageIndices.Length > 0) + { + pageRange = string.Join(",", srcPageIndices.Select(p => (p + 1).ToString(CultureInfo.InvariantCulture))); + } + + return FPDF_ImportPages(dest_doc, src_doc, pageRange, index); + } + + #endregion + + #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdf_save.h + + /// + /// Saves a PDF document to a stream. + /// + /// Save flags. + /// + /// The new PDF file version of the saved file. + /// 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored. + /// + /// Pdf document. + /// Output stream. + /// + /// + public static bool FPDF_SaveAsCopy(FPDF_DOCUMENT document, Stream stream, SaveFlags flags, int version = 0) + { + byte[] buffer = null; + var fileWrite = new FPDF_FILEWRITE((ignore, data, size) => + { + if (buffer == null || buffer.Length < size) + { + buffer = new byte[size]; + } + + Marshal.Copy(data, buffer, 0, size); + stream.Write(buffer, 0, size); + return true; + }); + + return version >= 10 ? FPDF_SaveWithVersion(document, fileWrite, flags, version) : FPDF_SaveAsCopy(document, fileWrite, flags); + } + + #endregion + + #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdf_structtree.h + + /// + /// Get the alternative text for a given element. + /// + /// Handle to the struct element. + /// The alternative text for . + public static string FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element) + => GetUtf16String((ref byte buffer, int length) => (int)FPDF_StructElement_GetAltText(struct_element, ref buffer, (uint)length), sizeof(byte), true); + + #endregion + + #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdf_text.h + + public static string FPDFText_GetText(FPDF_TEXTPAGE text_page, int start_index, int count) + { + var buffer = new byte[2 * (count + 1)]; + var length = FPDFText_GetText(text_page, start_index, count, ref buffer[0]); + return length == 0 + ? string.Empty + : Encoding.Unicode.GetString(buffer, 0, (length - 1) * 2); + } + + public static string FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, double left, double top, double right, double bottom) + => GetUtf16String((ref byte buffer, int length) => FPDFText_GetBoundedText(text_page, left, top, right, bottom, ref buffer, length), sizeof(ushort), false); + + public static string FPDFLink_GetURL(FPDF_PAGELINK link_page, int link_index) => GetUtf16String((ref byte buffer, int length) + => FPDFLink_GetURL(link_page, link_index, ref buffer, length), sizeof(ushort), true); + + #endregion + } +} \ No newline at end of file diff --git a/PDFiumSharp/PDFium.tt b/PDFiumSharp/PDFium.tt index 46239f9..5155885 100644 --- a/PDFiumSharp/PDFium.tt +++ b/PDFiumSharp/PDFium.tt @@ -12,7 +12,7 @@ License: Microsoft Reciprocal License (MS-RL) <# // ------------------------------------------------------ Code Start ------------------------------------------------------ const string DllName32 = "pdfium_x86"; const string DllName64 = "pdfium_x64"; -const string CallingConvention = "CallingConvention.StdCall"; +const string CallingConvention = "CallingConvention.Cdecl"; var Imports = new[] { // https://pdfium.googlesource.com/pdfium/+/master/public/fpdfview.h @@ -31,7 +31,17 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_DOCUMENT FPDF_LoadDocument([MarshalAs(UnmanagedType.LPStr)] string file_path, [MarshalAs(UnmanagedType.LPStr)] string password)", + new { Method = "void FPDF_SetSandBoxPolicy(int policy, bool enable)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_SetPrintMode(int mode)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_DOCUMENT FPDF_LoadDocument([MarshalAs(UnmanagedType.LPUTF8Str)] string file_path, [MarshalAs(UnmanagedType.LPStr)] string password)", AccessModifier = "public", Documentation = new[] { "" }, Attributes = new string[] { } }, @@ -41,6 +51,11 @@ var Imports = new[] { Documentation = new[] { "" }, Attributes = new string[] { } }, + new { Method = "FPDF_DOCUMENT FPDF_LoadMemDocument64(ref byte data_buf, long size, [MarshalAs(UnmanagedType.LPStr)] string password)", + AccessModifier = "private", + Documentation = new[] { "" }, + Attributes = new string[] { } }, + new { Method = "FPDF_DOCUMENT FPDF_LoadCustomDocument(FPDF_FILEREAD fileRead, [MarshalAs(UnmanagedType.LPStr)] string password)", AccessModifier = "public", Documentation = new[] { "" }, @@ -56,11 +71,26 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "bool FPDF_DocumentHasValidCrossReferenceTable(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_GetTrailerEnds(FPDF_DOCUMENT document, out uint buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "DocumentPermissions FPDF_GetDocPermissions(FPDF_DOCUMENT document)", AccessModifier = "public", Documentation = new[] { "" }, Attributes = new string[] { } }, + new { Method = "DocumentPermissions FPDF_GetDocUserPermissions(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "int FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document)", AccessModifier = "public", Documentation = new string[] { "" }, @@ -73,7 +103,12 @@ var Imports = new[] { new { Method = "FPDF_PAGE FPDF_LoadPage(FPDF_DOCUMENT document, int page_index)", AccessModifier = "public", - Documentation = new string[] { "", "" }, + Documentation = new string[] { "", "" }, + Attributes = new string[] { } }, + + new { Method = "float FPDF_GetPageWidthF(FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, Attributes = new string[] { } }, new { Method = "double FPDF_GetPageWidth(FPDF_PAGE page)", @@ -81,16 +116,36 @@ var Imports = new[] { Documentation = new string[] { "" }, Attributes = new string[] { } }, + new { Method = "float FPDF_GetPageHeightF(FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "double FPDF_GetPageHeight(FPDF_PAGE page)", AccessModifier = "public", Documentation = new string[] { "" }, Attributes = new string[] { } }, + new { Method = "bool FPDF_GetPageBoundingBox(FPDF_PAGE page, FS_RECTF rect)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_GetPageSizeByIndexF(FPDF_DOCUMENT document, int page_index, FS_SIZEF size)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "bool FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, out double width, out double height)", AccessModifier = "public", Documentation = new string[] { "" }, Attributes = new string[] { } }, + new { Method = "void FPDF_RenderPage(IntPtr hdc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotation, RenderingFlags flags)", + AccessModifier = "public", + Documentation = new string[] { "" }, + Attributes = new string[] { } }, + new { Method = "void FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotation, RenderingFlags flags)", AccessModifier = "public", Documentation = new string[] { "" }, @@ -101,6 +156,11 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "FPDF_RECORDER FPDF_RenderPageSkp(FPDF_PAGE page, int size_x, int size_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "void FPDF_ClosePage(FPDF_PAGE page)", AccessModifier = "public", Documentation = new string[] { "" }, @@ -111,14 +171,14 @@ var Imports = new[] { Documentation = new string[] { "" }, Attributes = new string[] { } }, - new { Method = "void FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotate, int device_x, int device_y, out double page_x, out double page_y)", + new { Method = "bool FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotate, int device_x, int device_y, out double page_x, out double page_y)", AccessModifier = "public", - Documentation = new string[] { "" }, + Documentation = new string[] { "" }, Attributes = new string[] { } }, - new { Method = "void FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotate, double page_x, double page_y, out int device_x, out int device_y)", + new { Method = "bool FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotate, double page_x, double page_y, out int device_x, out int device_y)", AccessModifier = "public", - Documentation = new string[] { "" }, + Documentation = new string[] { "" }, Attributes = new string[] { } }, new { Method = "FPDF_BITMAP FPDFBitmap_Create(int width, int height, bool hasAlpha)", @@ -131,6 +191,11 @@ var Imports = new[] { Documentation = new string[] { "" }, Attributes = new string[] { } }, + new { Method = "BitmapFormats FPDFBitmap_GetFormat(FPDF_BITMAP bitmap)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "void FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, int width, int height, FPDF_COLOR color)", AccessModifier = "public", Documentation = new string[] { "", "" }, @@ -176,13 +241,23 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "uint FPDF_VIEWERREF_GetPrintPageRangeCount(FPDF_PAGERANGE pagerange)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_VIEWERREF_GetPrintPageRangeElement(FPDF_PAGERANGE pagerange, uint index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "DuplexTypes FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document)", AccessModifier = "public", Documentation = new string[] { "" }, Attributes = new string[] { } }, - new { Method = "uint FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPStr)] string key, ref byte buffer, uint length)", // Entry not found in Dll - AccessModifier = "private", + new { Method = "ulong FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPStr)] string key, ref byte buffer, ulong length)", + AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, @@ -193,19 +268,54 @@ var Imports = new[] { new { Method = "FPDF_DEST FPDF_GetNamedDestByName(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPStr)] string name)", AccessModifier = "public", - Documentation = new string[] { "", "" }, + Documentation = new string[] { "", "" }, Attributes = new string[] { } }, - new { Method = "FPDF_DEST FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, IntPtr buffer, out int buflen)", + new { Method = "FPDF_DEST FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, IntPtr buffer, out int buflen)", AccessModifier = "private", Documentation = new string[] { "" }, Attributes = new string[] { } }, - - new { Method = "FPDF_DEST FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, ref byte buffer, ref int buflen)", + + new { Method = "FPDF_DEST FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, ref byte buffer, ref int buflen)", AccessModifier = "private", Documentation = new string[] { "" }, Attributes = new string[] { } }, + new { Method = "int FPDF_GetXFAPacketCount(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_GetXFAPacketName(FPDF_DOCUMENT document, int index, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_GetXFAPacketContent(FPDF_DOCUMENT document, int index, ref byte buffer, ulong buflen, out ulong out_buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "IntPtr FPDF_GetArrayBufferAllocatorSharedInstance()", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_RESULT FPDF_BStr_Init(ref FPDF_BSTR bstr)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_RESULT FPDF_BStr_Set(ref FPDF_BSTR bstr, ref char cstr, int length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_RESULT FPDF_BStr_Clear(ref FPDF_BSTR bstr)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_doc.h new { Method = "FPDF_BOOKMARK FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)", AccessModifier = "public", @@ -217,11 +327,16 @@ var Imports = new[] { Documentation = new string[] { "", "" }, Attributes = new string[] { } }, - new { Method = "uint FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, ref byte buffer, uint buflen)", + new { Method = "ulong FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, ref byte buffer, ulong buflen)", AccessModifier = "private", Documentation = new string[] { "" }, Attributes = new string[] { } }, + new { Method = "int FPDFBookmark_GetCount(FPDF_BOOKMARK bookmark)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "FPDF_BOOKMARK FPDFBookmark_Find(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPWStr)] string title)", AccessModifier = "public", Documentation = new string[] { "" }, @@ -257,11 +372,16 @@ var Imports = new[] { Documentation = new string[] { "" }, Attributes = new string[] { } }, - new { Method = "int FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest)", + new { Method = "int FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest)", AccessModifier = "public", Documentation = new string[] { "", "" }, Attributes = new string[] { } }, + new { Method = "ZoomModes FPDFDest_GetView(FPDF_DEST dest, out uint pNumParams, float pParams)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "bool FPDFDest_GetLocationInPage(FPDF_DEST dest, out bool hasXCoord, out bool hasYCoord, out bool hasZoom, out float x, out float y, out float zoom)", AccessModifier = "public", Documentation = new string[] { "", "" }, @@ -292,6 +412,11 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "FPDF_ANNOTATION FPDFLink_GetAnnot(FPDF_PAGE page, FPDF_LINK linkAnnot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "bool FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, out FS_RECTF rect)", AccessModifier = "public", Documentation = new string[] { }, @@ -307,14 +432,23 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "FPDF_ACTION FPDF_GetPageAAction(FPDF_PAGE page, int aa_type)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_GetFileIdentifier(FPDF_DOCUMENT document, FPDF_FILEIDTYPE id_type, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "uint FPDF_GetMetaText(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPStr)] string tag, ref byte buffer, uint buflen)", AccessModifier = "public", Documentation = new string[] { "", "" }, Attributes = new string[] { } }, - // Entry point not found new { Method = "uint FPDF_GetPageLabel(FPDF_DOCUMENT document, int page_index, ref byte buffer, uint buflen)", - AccessModifier = "private", + AccessModifier = "public", Documentation = new string[] { "" }, Attributes = new string[] { } }, @@ -334,6 +468,11 @@ var Imports = new[] { Documentation = new string[] { "", "" }, Attributes = new string[] { } }, + new { Method = "bool FPDF_MovePages(FPDF_DOCUMENT document, ref int page_indices, ulong page_indices_len, int dest_page_index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "PageOrientations FPDFPage_GetRotation(FPDF_PAGE page)", AccessModifier = "public", Documentation = new string[] { "" }, @@ -344,13 +483,18 @@ var Imports = new[] { Documentation = new string[] { "" }, Attributes = new string[] { } }, - // The |page_obj| will be automatically freed. + // The |page_obj| will be automatically freed. new { Method = "void FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj)", AccessModifier = "private", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFPage_CountObject(FPDF_PAGE page)", + new { Method = "bool FPDFPage_RemoveObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFPage_CountObjects(FPDF_PAGE page)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, @@ -370,16 +514,36 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "void FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "bool FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "PageObjTypes FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "void FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, double a, double b, double c, double d, double e, double f)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, + new { Method = "bool FPDFPageObj_GetMatrix(FPDF_PAGEOBJECT page_object, FS_MATRIX matrix)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPageObj_SetMatrix(FPDF_PAGEOBJECT path, [MarshalAs(UnmanagedType.LPStruct)] FS_MATRIX matrix)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + new { Method = "void FPDFPage_TransformAnnots(FPDF_PAGE page, double a, double b, double c, double d, double e, double f)", AccessModifier = "public", Documentation = new string[] { }, @@ -390,349 +554,1643 @@ var Imports = new[] { Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFImageObj_LoadJpegFile(ref FPDF_PAGE pages, int nCount, FPDF_PAGEOBJECT image_object, FPDF_FILEREAD fileRead)", - AccessModifier = "private", + new { Method = "int FPDFPageObj_CountMarks(FPDF_PAGEOBJECT page_object)", + AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFImageObj_LoadJpegFileInline(ref FPDF_PAGE pages, int nCount, FPDF_PAGEOBJECT image_object, FPDF_FILEREAD fileRead)", - AccessModifier = "private", + new { Method = "FPDF_PAGEOBJECTMARK FPDFPageObj_GetMark(FPDF_PAGEOBJECT page_object, ulong index)", + AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, double a, double b, double c, double d, double e, double f)", + new { Method = "FPDF_PAGEOBJECTMARK FPDFPageObj_AddMark(FPDF_PAGEOBJECT page_object, [MarshalAs(UnmanagedType.LPStr)] string name)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFImageObj_SetBitmap(ref FPDF_PAGE pages, int nCount, FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap)", + new { Method = "bool FPDFPageObj_RemoveMark(FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_PAGEOBJECT FPDFPageObj_CreateNewPath(float x, float y)", + new { Method = "bool FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark, ref byte buffer, ulong buflen, out ulong out_buflen)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_PAGEOBJECT FPDFPageObj_CreateNewRect(float x, float y, float w, float h)", + new { Method = "int FPDFPageObjMark_CountParams(FPDF_PAGEOBJECTMARK mark)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path, uint R, uint G, uint B, uint A)", + new { Method = "bool FPDFPageObjMark_GetParamKey(FPDF_PAGEOBJECTMARK mark, ulong index, ref byte buffer, ulong buflen, out ulong out_buflen)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width)", + new { Method = "ObjectTypes FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_SetFillColor(FPDF_PAGEOBJECT path, uint R, uint G, uint B, uint A)", + new { Method = "bool FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key, out int out_value)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_MoveTo(FPDF_PAGEOBJECT path, float x, float y)", + new { Method = "bool FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key, ref byte buffer, ulong buflen, out ulong out_buflen)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y)", + new { Method = "bool FPDFPageObjMark_GetParamBlobValue(FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key, ref byte buffer, ulong buflen, out ulong out_buflen)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_BezierTo(FPDF_PAGEOBJECT path, float x1, float y1, float x2, float y2, float x3, float y3)", + new { Method = "bool FPDFPageObjMark_SetIntParam(FPDF_DOCUMENT document, FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key, int value)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_Close(FPDF_PAGEOBJECT path)", + new { Method = "bool FPDFPageObjMark_SetStringParam(FPDF_DOCUMENT document, FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPStr)] string value)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, PathFillModes fillmode, bool stroke)", + new { Method = "bool FPDFPageObjMark_SetBlobParam(FPDF_DOCUMENT document, FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key, ref byte value, ulong value_len)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_PAGEOBJECT FPDFPageObj_NewTextObj(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPStr)] string font, float font_size)", + new { Method = "bool FPDFPageObjMark_RemoveParam(FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark, [MarshalAs(UnmanagedType.LPStr)] string key)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFText_SetText(FPDF_PAGEOBJECT text_object, [MarshalAs(UnmanagedType.LPStr)] string text)", - AccessModifier = "public", + new { Method = "bool FPDFImageObj_LoadJpegFile(ref FPDF_PAGE pages, int nCount, FPDF_PAGEOBJECT image_object, FPDF_FILEREAD fileRead)", + AccessModifier = "private", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_FONT FPDFText_LoadFont(FPDF_DOCUMENT document, ref byte data, uint size, FontTypes font_type, bool cid)", + new { Method = "bool FPDFImageObj_LoadJpegFileInline(ref FPDF_PAGE pages, int nCount, FPDF_PAGEOBJECT image_object, FPDF_FILEREAD fileRead)", AccessModifier = "private", Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_ext.h - new { Method = "PageModes FPDFDoc_GetPageMode(FPDF_DOCUMENT document)", + new { Method = "bool FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, double a, double b, double c, double d, double e, double f)", AccessModifier = "public", - Documentation = new string[] { "" }, + Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_flatten.h - new { Method = "FlattenResults FPDFPage_Flatten(FPDF_PAGE page, FlattenFlags nFlag)", + new { Method = "bool FPDFImageObj_SetBitmap(ref FPDF_PAGE pages, int count, FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap)", AccessModifier = "public", - Documentation = new string[] { "" }, + Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_ppo.h - new { Method = "bool FPDF_ImportPages(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc, [MarshalAs(UnmanagedType.LPStr)] string pagerange, int index)", + new { Method = "FPDF_BITMAP FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object)", AccessModifier = "public", - Documentation = new string[] { "", "", "" }, + Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc)", + new { Method = "FPDF_BITMAP FPDFImageObj_GetRenderedBitmap(FPDF_DOCUMENT document, FPDF_PAGE page, FPDF_PAGEOBJECT image_object)", AccessModifier = "public", - Documentation = new string[] { "" }, + Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_progressive.h - new { Method = "RenderingStatus FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotate, RenderingFlags flags, IFSDK_PAUSE pause)", + new { Method = "ulong FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object, ref byte buffer, ulong buflen)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "RenderingStatus FPDF_RenderPage_Continue(FPDF_PAGE page, IFSDK_PAUSE pause)", + new { Method = "ulong FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object, ref byte buffer, ulong buflen)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDF_RenderPage_Close(FPDF_PAGE page)", + new { Method = "int FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_save.h - new { Method = "bool FPDF_SaveAsCopy(FPDF_DOCUMENT document, FPDF_FILEWRITE fileWrite, SaveFlags flags)", + new { Method = "ulong FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object, int index, ref byte buffer, ulong buflen)", AccessModifier = "public", - Documentation = new string[] { "", "" }, + Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDF_SaveWithVersion(FPDF_DOCUMENT document, FPDF_FILEWRITE fileWrite, SaveFlags flags, int fileVersion)", + new { Method = "bool FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object, FPDF_PAGE page, out FPDF_IMAGEOBJ_METADATA metadata)", AccessModifier = "public", - Documentation = new string[] { "", "" }, + Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_searchex.h - new { Method = "int FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex)", + new { Method = "bool FPDFImageObj_GetImagePixelSize(FPDF_PAGEOBJECT image_object, out uint width, out uint height)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_GetTextIndexFromCharIndex(FPDF_TEXTPAGE text_page, int nCharIndex)", + new { Method = "FPDF_PAGEOBJECT FPDFPageObj_CreateNewPath(float x, float y)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_structtree.h - new { Method = "FPDF_STRUCTTREE FPDF_StructTree_GetForPage(FPDF_PAGE page)", + new { Method = "FPDF_PAGEOBJECT FPDFPageObj_CreateNewRect(float x, float y, float w, float h)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDF_StructTree_Close(FPDF_STRUCTTREE struct_tree)", + new { Method = "bool FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object, out float left, out float bottom, out float right, out float top)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDF_StructTree_CountChildren(FPDF_STRUCTTREE struct_tree)", + new { Method = "bool FPDFPageObj_GetRotatedBounds(FPDF_PAGEOBJECT page_object, FS_QUADPOINTSF quad_points)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_STRUCTELEMENT FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index)", + new { Method = "void FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object, [MarshalAs(UnmanagedType.LPStr)] string blend_mode)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "uint FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element, ref byte buffer, uint buflen)", - AccessModifier = "private", + new { Method = "bool FPDFPageObj_SetStrokeColor(FPDF_PAGEOBJECT page_object, uint R, uint G, uint B, uint A)", + AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDF_StructElement_CountChildren(FPDF_STRUCTELEMENT struct_element)", + new { Method = "bool FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object, out uint R, out uint G, out uint B, out uint A)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_STRUCTELEMENT FPDF_StructElement_GetChildAtIndex(FPDF_STRUCTELEMENT struct_element, int index)", + new { Method = "bool FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_text.h - new { Method = "FPDF_TEXTPAGE FPDFText_LoadPage(FPDF_PAGE page)", + new { Method = "bool FPDFPageObj_GetStrokeWidth(FPDF_PAGEOBJECT page_object, out float width)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFText_ClosePage(FPDF_TEXTPAGE text_page)", + new { Method = "int FPDFPageObj_GetLineJoin(FPDF_PAGEOBJECT page_object)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_CountChars(FPDF_TEXTPAGE text_page)", + new { Method = "bool FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "char FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index)", + new { Method = "int FPDFPageObj_GetLineCap(FPDF_PAGEOBJECT page_object)", AccessModifier = "public", Documentation = new string[] { }, - Attributes = new string[] { "[return: MarshalAs(UnmanagedType.U4)]" } }, + Attributes = new string[] { } }, - new { Method = "double FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, int index)", + new { Method = "bool FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, int index, out double left, out double right, out double bottom, out double top)", + new { Method = "bool FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object, uint R, uint G, uint B, uint A)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, double x, double y, double xTolerance, double yTolerance)", + new { Method = "bool FPDFPageObj_GetFillColor(FPDF_PAGEOBJECT page_object, out uint R, out uint G, out uint B, out uint A)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_GetText(FPDF_TEXTPAGE text_page, int start_index, int count, ref byte result)", - AccessModifier = "private", + new { Method = "bool FPDFPageObj_GetDashPhase(FPDF_PAGEOBJECT page_object, out float phase)", + AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_CountRects(FPDF_TEXTPAGE text_page, int start_index, int count)", + new { Method = "bool FPDFPageObj_SetDashPhase(FPDF_PAGEOBJECT page_object, float phase)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFText_GetRect(FPDF_TEXTPAGE text_page, int rect_index, out double left, out double top, out double right, out double bottom)", + new { Method = "int FPDFPageObj_GetDashCount(FPDF_PAGEOBJECT page_object)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, double left, double top, double right, double bottom, ref byte buffer, int buflen)", - AccessModifier = "private", + new { Method = "bool FPDFPageObj_GetDashArray(FPDF_PAGEOBJECT page_object, out float dash_array, uint dash_count)", + AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_SCHHANDLE FPDFText_FindStart(FPDF_TEXTPAGE text_page, [MarshalAs(UnmanagedType.LPWStr)] string findwhat, SearchFlags flags, int start_index)", + new { Method = "bool FPDFPageObj_SetDashArray(FPDF_PAGEOBJECT page_object, ref float dash_array, uint dash_count, float phase)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFText_FindNext(FPDF_SCHHANDLE handle)", + new { Method = "int FPDFPath_CountSegments(FPDF_PAGEOBJECT path)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFText_FindPrev(FPDF_SCHHANDLE handle)", + new { Method = "FPDF_PATHSEGMENT FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle)", + new { Method = "bool FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, out float x, out float y)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFText_GetSchCount(FPDF_SCHHANDLE handle)", + new { Method = "int FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFText_FindClose(FPDF_SCHHANDLE handle)", + new { Method = "bool FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_PAGELINK FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page)", + new { Method = "bool FPDFPath_MoveTo(FPDF_PAGEOBJECT path, float x, float y)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFLink_CountWebLinks(FPDF_PAGELINK link_page)", + new { Method = "bool FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFLink_GetURL(FPDF_PAGELINK link_page, int link_index, ref byte buffer, int buflen)", - AccessModifier = "private", + new { Method = "bool FPDFPath_BezierTo(FPDF_PAGEOBJECT path, float x1, float y1, float x2, float y2, float x3, float y3)", + AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "int FPDFLink_CountRects(FPDF_PAGELINK link_page, int link_index)", + new { Method = "bool FPDFPath_Close(FPDF_PAGEOBJECT path)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFLink_GetRect(FPDF_PAGELINK link_page, int link_index, int rect_index, out double left, out double top, out double right, out double bottom)", + new { Method = "bool FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, PathFillModes fillmode, bool stroke)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page)", + new { Method = "bool FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, out PathFillModes fillmode, out bool stroke)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_transformpage.h - new { Method = "void FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bottom, float right, float top)", + new { Method = "FPDF_PAGEOBJECT FPDFPageObj_NewTextObj(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPStr)] string font, float font_size)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFPage_SetCropBox(FPDF_PAGE page, float left, float bottom, float right, float top)", + new { Method = "bool FPDFText_SetText(FPDF_PAGEOBJECT text_object, [MarshalAs(UnmanagedType.LPWStr)] string text)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPage_GetMediaBox(FPDF_PAGE page, out float left, out float bottom, out float right, out float top)", + new { Method = "bool FPDFText_SetCharcodes(FPDF_PAGEOBJECT text_object, ref uint charcodes, uint count)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPage_GetCropBox(FPDF_PAGE page, out float left, out float bottom, out float right, out float top)", + new { Method = "FPDF_FONT FPDFText_LoadFont(FPDF_DOCUMENT document, ref byte data, uint size, FontTypes font_type, bool cid)", + AccessModifier = "private", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_FONT FPDFText_LoadStandardFont(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPStr)] string font)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "bool FPDFPage_TransFormWithClip(FPDF_PAGE page, [MarshalAs(UnmanagedType.LPStruct)] FS_MATRIX matrix, [MarshalAs(UnmanagedType.LPStruct)] FS_RECTF clipRect)", + new { Method = "bool FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text, out float size)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, double a, double b, double c, double d, double e, double f)", + new { Method = "void FPDFFont_Close(FPDF_FONT font)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "FPDF_CLIPPATH FPDF_CreateClipPath(float left, float bottom, float right, float top)", + new { Method = "FPDF_PAGEOBJECT FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, FPDF_FONT font, float font_size)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath)", + new { Method = "FPDF_TEXT_RENDERMODE FPDFTextObj_GetTextRenderMode(FPDF_PAGEOBJECT text)", AccessModifier = "public", Documentation = new string[] { }, Attributes = new string[] { } }, - new { Method = "void FPDFPage_InsertClipPath(FPDF_PAGE page, FPDF_CLIPPATH clipPath)", + new { Method = "bool FPDFTextObj_SetTextRenderMode(FPDF_PAGEOBJECT text, FPDF_TEXT_RENDERMODE render_mode)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object, FPDF_TEXTPAGE text_page, out FPDF_WCHAR buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_BITMAP FPDFTextObj_GetRenderedBitmap(FPDF_DOCUMENT document, FPDF_PAGE page, FPDF_PAGEOBJECT text_object, float scale)", AccessModifier = "public", Documentation = new string[] { }, - Attributes = new string[] { } } + Attributes = new string[] { } }, + + new { Method = "FPDF_FONT FPDFTextObj_GetFont(FPDF_PAGEOBJECT text)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFFont_GetFontName(FPDF_FONT font, ref byte buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFFont_GetFontData(FPDF_FONT font, ref byte buffer, uint buflen, out uint out_buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFFont_GetIsEmbedded(FPDF_FONT font)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFFont_GetFlags(FPDF_FONT font)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFFont_GetWeight(FPDF_FONT font)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFFont_GetItalicAngle(FPDF_FONT font, out int angle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFFont_GetAscent(FPDF_FONT font, float font_size, out float ascent)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFFont_GetDescent(FPDF_FONT font, float font_size, out float descent)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFFont_GetGlyphWidth(FPDF_FONT font, uint glyph, float font_size, out float width)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_GLYPHPATH FPDFFont_GetGlyphPath(FPDF_FONT font, uint glyph, float font_size)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFGlyphPath_CountGlyphSegments(FPDF_GLYPHPATH glyphpath)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_PATHSEGMENT FPDFGlyphPath_GetGlyphPathSegment(FPDF_GLYPHPATH glyphpath, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_PAGEOBJECT FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, ulong index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_ext.h + new { Method = "bool FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO unsp_info)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "PageModes FPDFDoc_GetPageMode(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { "" }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_flatten.h + new { Method = "FlattenResults FPDFPage_Flatten(FPDF_PAGE page, FlattenFlags nFlag)", + AccessModifier = "public", + Documentation = new string[] { "" }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_ppo.h + new { Method = "bool FPDF_ImportPagesByIndex(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc, ref int page_indices, ulong length, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_ImportPages(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc, [MarshalAs(UnmanagedType.LPStr)] string pagerange, int index)", + AccessModifier = "public", + Documentation = new string[] { "", "", "" }, + Attributes = new string[] { } }, + + new { Method = "FPDF_DOCUMENT FPDF_ImportNPagesToOne(FPDF_DOCUMENT src_doc, float output_width, float output_height, uint num_pages_on_x_axis, uint num_pages_on_y_axis)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_XOBJECT FPDF_NewXObjectFromPage(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc, int src_page_index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_CloseXObject(FPDF_XOBJECT xobject)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_PAGEOBJECT FPDF_NewFormObjectFromXObject(FPDF_XOBJECT xobject)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc)", + AccessModifier = "public", + Documentation = new string[] { "" }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_progressive.h + new { Method = "RenderingStatus FPDF_RenderPageBitmapWithColorScheme_Start(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotate, RenderingFlags flags, ref FPDF_COLORSCHEME color_scheme, IFSDK_PAUSE pause)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "RenderingStatus FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotate, RenderingFlags flags, IFSDK_PAUSE pause)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "RenderingStatus FPDF_RenderPage_Continue(FPDF_PAGE page, IFSDK_PAUSE pause)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_RenderPage_Close(FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_save.h + new { Method = "bool FPDF_SaveAsCopy(FPDF_DOCUMENT document, FPDF_FILEWRITE fileWrite, SaveFlags flags)", + AccessModifier = "public", + Documentation = new string[] { "", "" }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_SaveWithVersion(FPDF_DOCUMENT document, FPDF_FILEWRITE fileWrite, SaveFlags flags, int fileVersion)", + AccessModifier = "public", + Documentation = new string[] { "", "" }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_searchex.h + new { Method = "int FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_GetTextIndexFromCharIndex(FPDF_TEXTPAGE text_page, int nCharIndex)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_structtree.h + new { Method = "FPDF_STRUCTTREE FPDF_StructTree_GetForPage(FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_StructTree_Close(FPDF_STRUCTTREE struct_tree)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructTree_CountChildren(FPDF_STRUCTTREE struct_tree)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_STRUCTELEMENT FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetActualText(FPDF_STRUCTELEMENT struct_element, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetID(FPDF_STRUCTELEMENT struct_element, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetLang(FPDF_STRUCTELEMENT struct_element, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetStringAttribute(FPDF_STRUCTELEMENT struct_element, [MarshalAs(UnmanagedType.LPStr)] string attr_name, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructElement_GetMarkedContentID(FPDF_STRUCTELEMENT struct_element)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetType(FPDF_STRUCTELEMENT struct_element, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetObjType(FPDF_STRUCTELEMENT struct_element, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDF_StructElement_GetTitle(FPDF_STRUCTELEMENT struct_element, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructElement_CountChildren(FPDF_STRUCTELEMENT struct_element)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_STRUCTELEMENT FPDF_StructElement_GetChildAtIndex(FPDF_STRUCTELEMENT struct_element, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructElement_GetChildMarkedContentID(FPDF_STRUCTELEMENT struct_element, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_STRUCTELEMENT FPDF_StructElement_GetParent(FPDF_STRUCTELEMENT struct_element)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructElement_GetAttributeCount(FPDF_STRUCTELEMENT struct_element)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_STRUCTELEMENT_ATTR FPDF_StructElement_GetAttributeAtIndex(FPDF_STRUCTELEMENT struct_element, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructElement_Attr_GetCount(FPDF_STRUCTELEMENT_ATTR struct_attribute)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_StructElement_Attr_GetName(FPDF_STRUCTELEMENT_ATTR struct_attribute, int index, ref byte buffer, ulong buflen, out ulong out_buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_OBJECT_TYPE FPDF_StructElement_Attr_GetType(FPDF_STRUCTELEMENT_ATTR struct_attribute, [MarshalAs(UnmanagedType.LPStr)] string name)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_StructElement_Attr_GetBooleanValue(FPDF_STRUCTELEMENT_ATTR struct_attribute, [MarshalAs(UnmanagedType.LPStr)] string name, out bool out_value)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_StructElement_Attr_GetNumberValue(FPDF_STRUCTELEMENT_ATTR struct_attribute, [MarshalAs(UnmanagedType.LPStr)] string name, out float out_value)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_StructElement_Attr_GetStringValue(FPDF_STRUCTELEMENT_ATTR struct_attribute, [MarshalAs(UnmanagedType.LPStr)] string name, ref byte buffer, ulong buflen, out ulong out_buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_StructElement_Attr_GetBlobValue(FPDF_STRUCTELEMENT_ATTR struct_attribute, [MarshalAs(UnmanagedType.LPStr)] string name, ref byte buffer, ulong buflen, out ulong out_buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructElement_GetMarkedContentIdCount(FPDF_STRUCTELEMENT struct_element)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_StructElement_GetMarkedContentIdAtIndex(FPDF_STRUCTELEMENT struct_element, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_text.h + new { Method = "FPDF_TEXTPAGE FPDFText_LoadPage(FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFText_ClosePage(FPDF_TEXTPAGE text_page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_CountChars(FPDF_TEXTPAGE text_page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "char FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { "[return: MarshalAs(UnmanagedType.U4)]" } }, + + new { Method = "int FPDFText_IsGenerated(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_IsHyphen(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_HasUnicodeMapError(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "double FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFText_GetFontInfo(FPDF_TEXTPAGE text_page, int index, ref byte buffer, ulong buflen, out int flags)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_GetFontWeight(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_TEXT_RENDERMODE FPDFText_GetTextRenderMode(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_GetFillColor(FPDF_TEXTPAGE text_page, int index, out uint R, out uint G, out uint B, out uint A)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_GetStrokeColor(FPDF_TEXTPAGE text_page, int index, out uint R, out uint G, out uint B, out uint A)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "float FPDFText_GetCharAngle(FPDF_TEXTPAGE text_page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, int index, out double left, out double right, out double bottom, out double top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_GetLooseCharBox(FPDF_TEXTPAGE text_page, int index, FS_RECTF rect)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_GetMatrix(FPDF_TEXTPAGE text_page, int index, FS_MATRIX matrix)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_GetCharOrigin(FPDF_TEXTPAGE text_page, int index, out double x, out double y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, double x, double y, double xTolerance, double yTolerance)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_GetText(FPDF_TEXTPAGE text_page, int start_index, int count, ref byte result)", + AccessModifier = "private", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_CountRects(FPDF_TEXTPAGE text_page, int start_index, int count)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_GetRect(FPDF_TEXTPAGE text_page, int rect_index, out double left, out double top, out double right, out double bottom)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, double left, double top, double right, double bottom, ref byte buffer, int buflen)", + AccessModifier = "private", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_SCHHANDLE FPDFText_FindStart(FPDF_TEXTPAGE text_page, [MarshalAs(UnmanagedType.LPWStr)] string findwhat, SearchFlags flags, int start_index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_FindNext(FPDF_SCHHANDLE handle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFText_FindPrev(FPDF_SCHHANDLE handle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFText_GetSchCount(FPDF_SCHHANDLE handle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFText_FindClose(FPDF_SCHHANDLE handle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_PAGELINK FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFLink_CountWebLinks(FPDF_PAGELINK link_page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFLink_GetURL(FPDF_PAGELINK link_page, int link_index, ref byte buffer, int buflen)", + AccessModifier = "private", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFLink_CountRects(FPDF_PAGELINK link_page, int link_index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFLink_GetRect(FPDF_PAGELINK link_page, int link_index, int rect_index, out double left, out double top, out double right, out double bottom)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFLink_GetTextRange(FPDF_PAGELINK link_page, int link_index, out int start_char_index, out int char_count)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_transformpage.h + new { Method = "void FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bottom, float right, float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFPage_SetCropBox(FPDF_PAGE page, float left, float bottom, float right, float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFPage_SetBleedBox(FPDF_PAGE page, float left, float bottom, float right, float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFPage_SetTrimBox(FPDF_PAGE page, float left, float bottom, float right, float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFPage_SetArtBox(FPDF_PAGE page, float left, float bottom, float right, float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPage_GetMediaBox(FPDF_PAGE page, out float left, out float bottom, out float right, out float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPage_GetCropBox(FPDF_PAGE page, out float left, out float bottom, out float right, out float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPage_GetBleedBox(FPDF_PAGE page, out float left, out float bottom, out float right, out float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPage_GetTrimBox(FPDF_PAGE page, out float left, out float bottom, out float right, out float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPage_GetArtBox(FPDF_PAGE page, out float left, out float bottom, out float right, out float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPage_TransFormWithClip(FPDF_PAGE page, [MarshalAs(UnmanagedType.LPStruct)] FS_MATRIX matrix, [MarshalAs(UnmanagedType.LPStruct)] FS_RECTF clipRect)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, double a, double b, double c, double d, double e, double f)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_CLIPPATH FPDFPageObj_GetClipPath(FPDF_PAGEOBJECT page_object)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFClipPath_CountPaths(FPDF_CLIPPATH clip_path)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFClipPath_CountPathSegments(FPDF_CLIPPATH clip_path, int path_index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_PATHSEGMENT FPDFClipPath_GetPathSegment(FPDF_CLIPPATH clip_path, int path_index, int segment_index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_CLIPPATH FPDF_CreateClipPath(float left, float bottom, float right, float top)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFPage_InsertClipPath(FPDF_PAGE page, FPDF_CLIPPATH clipPath)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_annot.h + new { Method = "bool FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_ANNOTATION FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFPage_GetAnnotCount(FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_ANNOTATION FPDFPage_GetAnnot(FPDF_PAGE page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFPage_GetAnnotIndex(FPDF_PAGE page, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFPage_CloseAnnot(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFPage_RemoveAnnot(FPDF_PAGE page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_ANNOTATION_SUBTYPE FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_AddInkStroke(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStruct)] FS_POINTF points, uint point_count)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_RemoveInkList(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_PAGEOBJECT FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetColor(FPDF_ANNOTATION annot, FPDFANNOT_COLORTYPE type, uint R, uint G, uint B, uint A)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetColor(FPDF_ANNOTATION annot, FPDFANNOT_COLORTYPE type, out uint R, out uint G, out uint B, out uint A)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, uint quad_index, [MarshalAs(UnmanagedType.LPStruct)] FS_QUADPOINTSF quad_points)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_AppendAttachmentPoints(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStruct)] FS_QUADPOINTSF quad_points)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "uint FPDFAnnot_CountAttachmentPoints(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, uint quad_index, FS_QUADPOINTSF quad_points)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetRect(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStruct)] FS_RECTF rect)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetRect(FPDF_ANNOTATION annot, FS_RECTF rect)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetVertices(FPDF_ANNOTATION annot, FS_POINTF buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetInkListCount(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot, ulong path_index, FS_POINTF buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetLine(FPDF_ANNOTATION annot, FS_POINTF start, FS_POINTF end)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetBorder(FPDF_ANNOTATION annot, float horizontal_radius, float vertical_radius, float border_width)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetBorder(FPDF_ANNOTATION annot, out float horizontal_radius, out float vertical_radius, out float border_width)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetFormAdditionalActionJavaScript(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, int evnt, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_HasKey(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStr)] string key)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_OBJECT_TYPE FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStr)] string key)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPWStr)] string value)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStr)] string key, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetNumberValue(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStr)] string key, out float value)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetAP(FPDF_ANNOTATION annot, FPDF_ANNOT_APPEARANCEMODE appearanceMode, [MarshalAs(UnmanagedType.LPWStr)] string value)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetAP(FPDF_ANNOTATION annot, FPDF_ANNOT_APPEARANCEMODE appearanceMode, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_ANNOTATION FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, [MarshalAs(UnmanagedType.LPStr)] string key)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetFlags(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetFlags(FPDF_ANNOTATION annot, int flags)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetFormFieldFlags(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_ANNOTATION FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, [MarshalAs(UnmanagedType.LPStruct)] FS_POINTF point)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetFormFieldValue(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetOptionCount(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetOptionLabel(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, int index, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_IsOptionSelected(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetFontSize(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, out float value)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_IsChecked(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetFocusableSubtypes(FPDF_FORMHANDLE hHandle, ref FPDF_ANNOTATION_SUBTYPE subtypes, uint count)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetFocusableSubtypesCount(FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_GetFocusableSubtypes(FPDF_FORMHANDLE hHandle, out FPDF_ANNOTATION_SUBTYPE subtypes, uint count)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_LINK FPDFAnnot_GetLink(FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetFormControlCount(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAnnot_GetFormControlIndex(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAnnot_GetFormFieldExportValue(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAnnot_SetURI(FPDF_ANNOTATION annot, ref char uri)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_attachment.h + new { Method = "int FPDFDoc_GetAttachmentCount(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_ATTACHMENT FPDFDoc_AddAttachment(FPDF_DOCUMENT document, [MarshalAs(UnmanagedType.LPWStr)] string name)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_ATTACHMENT FPDFDoc_GetAttachment(FPDF_DOCUMENT document, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAttachment_GetName(FPDF_ATTACHMENT attachment, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAttachment_HasKey(FPDF_ATTACHMENT attachment, [MarshalAs(UnmanagedType.LPStr)] string key)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_OBJECT_TYPE FPDFAttachment_GetValueType(FPDF_ATTACHMENT attachment, [MarshalAs(UnmanagedType.LPStr)] string key)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAttachment_SetStringValue(FPDF_ATTACHMENT attachment, [MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPWStr)] string value)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFAttachment_GetStringValue(FPDF_ATTACHMENT attachment, [MarshalAs(UnmanagedType.LPStr)] string key, out FPDF_WCHAR buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment, FPDF_DOCUMENT document, ref byte contents, ulong len)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDFAttachment_GetFile(FPDF_ATTACHMENT attachment, ref byte buffer, ulong buflen, out ulong out_buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_catalog.h + new { Method = "bool FPDFCatalog_IsTagged(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_dataavail.h + new { Method = "FPDF_AVAIL FPDFAvail_Create(out FX_FILEAVAIL file_avail, out FPDF_FILEACCESS file)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFAvail_Destroy(FPDF_AVAIL avail)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAvail_IsDocAvail(FPDF_AVAIL avail, out FX_DOWNLOADHINTS hints)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_DOCUMENT FPDFAvail_GetDocument(FPDF_AVAIL avail, [MarshalAs(UnmanagedType.LPStr)] string password)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAvail_IsPageAvail(FPDF_AVAIL avail, int page_index, out FX_DOWNLOADHINTS hints)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAvail_IsFormAvail(FPDF_AVAIL avail, out FX_DOWNLOADHINTS hints)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFAvail_IsLinearized(FPDF_AVAIL avail)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_formfill.h + new { Method = "FPDF_FORMHANDLE FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO formInfo)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, FPDFDOC_AACTION aaType)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandle, int aaType)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnMouseWheel(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, [MarshalAs(UnmanagedType.LPStruct)] FS_POINTF page_coord, int delta_x, int delta_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnFocus(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnLButtonDoubleClick(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nKeyCode, int modifier)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nKeyCode, int modifier)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FORM_GetFocusedText(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FORM_GetSelectedText(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_ReplaceAndKeepSelection(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, [MarshalAs(UnmanagedType.LPWStr)] string wsText)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, [MarshalAs(UnmanagedType.LPWStr)] string wsText)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_SelectAllText(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_CanUndo(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_CanRedo(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_Undo(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_Redo(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_GetFocusedAnnot(FPDF_FORMHANDLE handle, out int page_index, out FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_SetFocusedAnnot(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, ulong color)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, byte alpha)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, PageOrientations rotation, RenderingFlags flags)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_FFLDrawSkia(FPDF_FORMHANDLE hHandle, FPDF_SKIA_CANVAS canvas, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, int rotate, int flags)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "int FPDF_GetFormType(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_SetIndexSelected(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int index, bool selected)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FORM_IsIndexSelected(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "bool FPDF_LoadXFA(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_signature.h + new { Method = "int FPDF_GetSignatureCount(FPDF_DOCUMENT document)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_SIGNATURE FPDF_GetSignatureObject(FPDF_DOCUMENT document, int index)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFSignatureObj_GetContents(FPDF_SIGNATURE signature, ref byte buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFSignatureObj_GetByteRange(FPDF_SIGNATURE signature, out int buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFSignatureObj_GetSubFilter(FPDF_SIGNATURE signature, out char buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFSignatureObj_GetReason(FPDF_SIGNATURE signature, ref byte buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFSignatureObj_GetTime(FPDF_SIGNATURE signature, out char buffer, ulong length)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "uint FPDFSignatureObj_GetDocMDPPermission(FPDF_SIGNATURE signature)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { "[return: MarshalAs(UnmanagedType.U4)]" } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_sysfontinfo.h + new { Method = "void FPDF_AddInstalledFont(ref byte mapper, ref char face, int charset)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_SetSystemFontInfo(out FPDF_SYSFONTINFO pFontInfo)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "IntPtr FPDF_GetDefaultSystemFontInfo()", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "void FPDF_FreeDefaultSystemFontInfo(out FPDF_SYSFONTINFO pFontInfo)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + // https://pdfium.googlesource.com/pdfium/+/master/public/fpdf_thumbnail.h + new { Method = "ulong FPDFPage_GetDecodedThumbnailData(FPDF_PAGE page, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "ulong FPDFPage_GetRawThumbnailData(FPDF_PAGE page, ref byte buffer, ulong buflen)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + + new { Method = "FPDF_BITMAP FPDFPage_GetThumbnailAsBitmap(FPDF_PAGE page)", + AccessModifier = "public", + Documentation = new string[] { }, + Attributes = new string[] { } }, + }; // --------------------------------------------------------- Code End ----------------------------------------------------- #> #region Copyright and License @@ -747,6 +2205,7 @@ License: Microsoft Reciprocal License (MS-RL) // DO NOT MODIFY using System; using System.Runtime.InteropServices; +using PDFiumSharp.Enums; using PDFiumSharp.Types; namespace PDFiumSharp @@ -771,6 +2230,8 @@ foreach (var import in Imports) foreach (var tmp in tmpArgList) { var argDecl = tmp.Split('=')[0].TrimEnd(); + if (argDecl.Contains("MarshalAs(UnmanagedType.LPUTF8Str")) + argumentList = argumentList.Replace("MarshalAs(UnmanagedType.LPUTF8Str)", "MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaler))"); if (argDecl.Contains("ref ")) args += "ref "; else if (argDecl.Contains("out ")) diff --git a/PDFiumSharp/PDFiumBitmap.cs b/PDFiumSharp/PDFiumBitmap.cs index ac5eb9a..c788811 100644 --- a/PDFiumSharp/PDFiumBitmap.cs +++ b/PDFiumSharp/PDFiumBitmap.cs @@ -6,11 +6,10 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Text; using PDFiumSharp.Types; using System.IO; using System.Runtime.InteropServices; +using PDFiumSharp.Enums; namespace PDFiumSharp { @@ -37,11 +36,11 @@ public sealed class PDFiumBitmap : NativeWrapper static int GetBytesPerPixel(BitmapFormats format) { - if (format == BitmapFormats.FPDFBitmap_BGR) + if (format == BitmapFormats.BGR) return 3; - if (format == BitmapFormats.FPDFBitmap_BGRA || format == BitmapFormats.FPDFBitmap_BGRx) + if (format == BitmapFormats.BGRA || format == BitmapFormats.BGRx) return 4; - if (format == BitmapFormats.FPDFBitmap_Gray) + if (format == BitmapFormats.Gray) return 1; throw new ArgumentOutOfRangeException(nameof(format)); } @@ -56,10 +55,10 @@ static int GetBytesPerPixel(BitmapFormats format) /// /// A bitmap created with this overload always uses 4 bytes per pixel. /// Depending on the is then either - /// or . + /// or . /// public PDFiumBitmap(int width, int height, bool hasAlpha) - : this(PDFium.FPDFBitmap_Create(width, height, hasAlpha), hasAlpha ? BitmapFormats.FPDFBitmap_BGRA : BitmapFormats.FPDFBitmap_BGRx) { } + : this(PDFium.FPDFBitmap_Create(width, height, hasAlpha), hasAlpha ? BitmapFormats.BGRA : BitmapFormats.BGRx) { } /// /// Creates a new using memory allocated by the caller. @@ -141,7 +140,7 @@ class BmpStream : Stream public BmpStream(PDFiumBitmap bitmap, double dpiX, double dpiY) { - if (bitmap.Format == BitmapFormats.FPDFBitmap_Gray) + if (bitmap.Format == BitmapFormats.Gray) throw new NotSupportedException($"Bitmap format {bitmap.Format} is not yet supported."); _bitmap = bitmap; @@ -179,7 +178,7 @@ static byte[] GetHeader(uint fileSize, PDFiumBitmap bitmap, double dpiX, double writer.Write(MaskR); writer.Write(MaskG); writer.Write(MaskB); - if (bitmap.Format == BitmapFormats.FPDFBitmap_BGRA) + if (bitmap.Format == BitmapFormats.BGRA) writer.Write(MaskA); } return header; diff --git a/PDFiumSharp/PDFiumException.cs b/PDFiumSharp/PDFiumException.cs index ea67739..5fed09e 100644 --- a/PDFiumSharp/PDFiumException.cs +++ b/PDFiumSharp/PDFiumException.cs @@ -6,8 +6,6 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Text; using PDFiumSharp.Types; namespace PDFiumSharp diff --git a/PDFiumSharp/PDFiumSharp.csproj b/PDFiumSharp/PDFiumSharp.csproj index 3a1ddde..9910c50 100644 --- a/PDFiumSharp/PDFiumSharp.csproj +++ b/PDFiumSharp/PDFiumSharp.csproj @@ -1,11 +1,19 @@  - netstandard1.4 + netstandard2.0 False - 0.1.2.0 - Copyright © Tobias Meyer 2017 + 1.1.4.0 + Copyright © Tobias Meyer 2023 AnyCPU;x64 + PDFiumSharp + PDFiumSharp.NetStandart2.0 + 1.1.4 + C#/.NET Wrapper for the PDFium library. Add also a package for the native binaries (currently only PDFium.Windows is provided) or provide them (pdfium_x64.dll, pdfium_x86.dll) yourself. + https://github.com/Zubastic/PDFiumSharp/blob/master/README.md + https://github.com/Zubastic/PDFiumSharp + PDF PDFium Rendering C# Renderer + CS1591;CS0419;CS1572;CS1573;CS1574;CS1580;$NoWarn @@ -17,12 +25,12 @@ - bin\Release\netstandard1.4\PDFiumSharp.xml + bin\Release\netstandard2.0\PDFiumSharp.xml True - bin\Release\netstandard1.4\PDFiumSharp.xml + bin\Release\netstandard2.0\PDFiumSharp.xml True @@ -36,7 +44,7 @@ - + diff --git a/PDFiumSharp/PdfAction.cs b/PDFiumSharp/PdfAction.cs index 2997219..a8b3278 100644 --- a/PDFiumSharp/PdfAction.cs +++ b/PDFiumSharp/PdfAction.cs @@ -6,8 +6,7 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Text; +using PDFiumSharp.Enums; using PDFiumSharp.Types; namespace PDFiumSharp diff --git a/PDFiumSharp/PdfBookmark.cs b/PDFiumSharp/PdfBookmark.cs index 152d7fb..83bbf4d 100644 --- a/PDFiumSharp/PdfBookmark.cs +++ b/PDFiumSharp/PdfBookmark.cs @@ -5,9 +5,7 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; using System.Collections.Generic; -using System.Text; using PDFiumSharp.Types; namespace PDFiumSharp diff --git a/PDFiumSharp/PdfDestination.cs b/PDFiumSharp/PdfDestination.cs index f6940e0..c6e3868 100644 --- a/PDFiumSharp/PdfDestination.cs +++ b/PDFiumSharp/PdfDestination.cs @@ -5,9 +5,6 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; using PDFiumSharp.Types; namespace PDFiumSharp @@ -17,7 +14,7 @@ public sealed class PdfDestination : NativeWrapper public PdfDocument Document { get; } public string Name { get; } - public int PageIndex => PDFium.FPDFDest_GetPageIndex(Document.Handle, Handle); + public int PageIndex => PDFium.FPDFDest_GetDestPageIndex(Document.Handle, Handle); public (float X, float Y, float Zoom) LocationInPage { diff --git a/PDFiumSharp/PdfDestinationCollection.cs b/PDFiumSharp/PdfDestinationCollection.cs index 7f59a53..22189cd 100644 --- a/PDFiumSharp/PdfDestinationCollection.cs +++ b/PDFiumSharp/PdfDestinationCollection.cs @@ -8,7 +8,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; namespace PDFiumSharp { diff --git a/PDFiumSharp/PdfDocument.cs b/PDFiumSharp/PdfDocument.cs index 2190fb0..adae6ae 100644 --- a/PDFiumSharp/PdfDocument.cs +++ b/PDFiumSharp/PdfDocument.cs @@ -7,89 +7,132 @@ #endregion using System; using System.Collections.Generic; -using System.Text; using PDFiumSharp.Types; using System.IO; -using System.Linq; +using System.Runtime.InteropServices; +using PDFiumSharp.Enums; namespace PDFiumSharp { public sealed class PdfDocument : NativeWrapper { - /// - /// Gets the pages in the current . - /// - public PdfPageCollection Pages { get; } + private FPDF_FORMFILLINFO formCallbacks; - public PdfDestinationCollection Destinations { get; } + private GCHandle formCallbacksHandle; + + private FPDF_FORMHANDLE form; + + internal FPDF_FORMHANDLE Form => this.form; + + /// + /// Gets the pages in the current . + /// + public PdfPageCollection Pages { get; } + + public PdfDestinationCollection Destinations { get; } + + /// + /// Gets the PDF file version. File version: 14 for 1.4, 15 for 1.5, ... + /// + public int FileVersion + { + get + { + PDFium.FPDF_GetFileVersion(this.Handle, out var fileVersion); + return fileVersion; + } + } + + /// + /// Gets the revision of the security handler. + /// + /// PDF Reference: Table 21 + public int SecurityHandlerRevision => PDFium.FPDF_GetSecurityHandlerRevision(this.Handle); + + public DocumentPermissions Permissions => PDFium.FPDF_GetDocPermissions(this.Handle); + + public bool PrintPrefersScaling => PDFium.FPDF_VIEWERREF_GetPrintScaling(this.Handle); + + public int PrintCopyCount => PDFium.FPDF_VIEWERREF_GetNumCopies(this.Handle); + + public DuplexTypes DuplexType => PDFium.FPDF_VIEWERREF_GetDuplex(this.Handle); + + public IEnumerable Bookmarks + { + get + { + var handle = PDFium.FPDFBookmark_GetFirstChild(this.Handle, FPDF_BOOKMARK.Null); + while (!handle.IsNull) + { + yield return new PdfBookmark(this, handle); + handle = PDFium.FPDFBookmark_GetNextSibling(this.Handle, handle); + } + } + } + + public PageModes PageMode => PDFium.FPDFDoc_GetPageMode(this.Handle); + + private PdfDocument(FPDF_DOCUMENT doc) + : base(doc) + { + if (doc.IsNull) + { + throw new PDFiumException(); + } + + // The version depends on whether PDFium was compiled with XFA (2) or without (1). + // Try in sequential order. + for (var version = 1; version <= 2; version++) + { + this.formCallbacks = new FPDF_FORMFILLINFO(version); + + // We have to pin the callbacks because the form references them (so they shouldn't ever be moved) + this.formCallbacksHandle = GCHandle.Alloc(this.formCallbacks, GCHandleType.Pinned); + this.form = PDFium.FPDFDOC_InitFormFillEnvironment(doc, this.formCallbacks); + if (!this.form.IsNull) + { + // copied from https://pdfium.googlesource.com/pdfium/+/refs/heads/main/samples/pdfium_test.cc#1272 + PDFium.FPDF_SetFormFieldHighlightColor(this.form, 0, 0xFFE4DD); + PDFium.FPDF_SetFormFieldHighlightAlpha(this.form, 100); + PDFium.FORM_DoDocumentJSAction(this.form); + PDFium.FORM_DoDocumentOpenAction(this.form); + break; + } + + // that's not a correct version - unpin the handle + this.formCallbacksHandle.Free(); + } + + this.Pages = new PdfPageCollection(this); + this.Destinations = new PdfDestinationCollection(this); + } + + /// + /// Creates a new . + /// must be called in order to free unmanaged resources. + /// + public PdfDocument() + : this(PDFium.FPDF_CreateNewDocument()) { } /// - /// Gets the PDF file version. File version: 14 for 1.4, 15 for 1.5, ... - /// - public int FileVersion { get { PDFium.FPDF_GetFileVersion(Handle, out int fileVersion); return fileVersion; } } - - /// - /// Gets the revision of the security handler. - /// - /// PDF Reference: Table 21 - public int SecurityHandlerRevision => PDFium.FPDF_GetSecurityHandlerRevision(Handle); - - public DocumentPermissions Permissions => PDFium.FPDF_GetDocPermissions(Handle); - - public bool PrintPrefersScaling => PDFium.FPDF_VIEWERREF_GetPrintScaling(Handle); - - public int PrintCopyCount => PDFium.FPDF_VIEWERREF_GetNumCopies(Handle); - - public DuplexTypes DuplexType => PDFium.FPDF_VIEWERREF_GetDuplex(Handle); - - public IEnumerable Bookmarks - { - get - { - FPDF_BOOKMARK handle = PDFium.FPDFBookmark_GetFirstChild(Handle, FPDF_BOOKMARK.Null); - while (!handle.IsNull) - { - yield return new PdfBookmark(this, handle); - handle = PDFium.FPDFBookmark_GetNextSibling(this.Handle, handle); - } - } - } - - public PageModes PageMode => PDFium.FPDFDoc_GetPageMode(Handle); - - PdfDocument(FPDF_DOCUMENT doc) - : base(doc) - { - if (doc.IsNull) - throw new PDFiumException(); - Pages = new PdfPageCollection(this); - Destinations = new PdfDestinationCollection(this); - } - - /// - /// Creates a new . - /// must be called in order to free unmanaged resources. - /// - public PdfDocument() - : this(PDFium.FPDF_CreateNewDocument()) { } - - /// - /// Loads a from the file system. - /// must be called in order to free unmanaged resources. - /// - /// Filepath of the PDF file to load. - public PdfDocument(string fileName, string password = null) - : this(PDFium.FPDF_LoadDocument(fileName, password)) { } - - /// - /// Loads a from memory. - /// must be called in order to free unmanaged resources. - /// - /// Byte array containing the bytes of the PDF document to load. - /// The index of the first byte to be copied from . - /// The number of bytes to copy from or a negative value to copy all bytes. - public PdfDocument(byte[] data, int index = 0, int count = -1, string password = null) - : this(PDFium.FPDF_LoadDocument(data, index, count, password)) { } + /// Loads a from the file system. + /// must be called in order to free unmanaged resources. + /// + /// Filepath of the PDF file to load. + /// Password. + public PdfDocument(string fileName, string password = null) + : this(PDFium.FPDF_LoadDocument(fileName, password)) { } + + /// + /// Loads a from memory. + /// must be called in order to free unmanaged resources. + /// + /// Byte array containing the bytes of the PDF document to load. + /// The index of the first byte to be copied from . + /// The number of bytes to copy from or a negative value to copy all bytes. + /// Password. + public PdfDocument(byte[] data, int index = 0, int count = -1, string password = null) + : this(PDFium.FPDF_LoadDocument(data, index, count, password)) { } /// /// Loads a from '' bytes read from a . @@ -105,50 +148,67 @@ public PdfDocument(byte[] data, int index = 0, int count = -1, string password = public PdfDocument(Stream stream, FPDF_FILEREAD fileRead, int count = 0, string password = null) : this(PDFium.FPDF_LoadDocument(stream, fileRead, count, password)) { } - /// - /// Closes the and frees unmanaged resources. - /// - public void Close() => ((IDisposable)this).Dispose(); - - /// - /// Saves the to a . - /// - /// - /// The new PDF file version of the saved file. - /// 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored. - /// - public bool Save(Stream stream, SaveFlags flags = SaveFlags.None, int version = 0) - { - return PDFium.FPDF_SaveAsCopy(Handle, stream, flags, version); - } - - /// - /// Saves the to the file system. - /// - /// - /// The new PDF file version of the saved file. - /// 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored. - /// - public bool Save(string filename, SaveFlags flags = SaveFlags.None, int version = 0) - { - using (var stream = new FileStream(filename, FileMode.Create)) - return Save(stream, flags, version); - } - - public PdfBookmark FindBookmark(string title) - { - var handle = PDFium.FPDFBookmark_Find(Handle, title); - return handle.IsNull ? null : new PdfBookmark(this, handle); - } - - public string GetMetaText(MetadataTags tag) => PDFium.FPDF_GetMetaText(Handle, tag); - - public void CopyViewerPreferencesFrom(PdfDocument srcDoc) => PDFium.FPDF_CopyViewerPreferences(Handle, srcDoc.Handle); - - protected override void Dispose(FPDF_DOCUMENT handle) - { - ((IDisposable)Pages).Dispose(); - PDFium.FPDF_CloseDocument(handle); - } - } -} + /// + /// Closes the and frees unmanaged resources. + /// + public void Close() => ((IDisposable)this).Dispose(); + + /// + /// Saves the to a . + /// + /// Flags + /// + /// The new PDF file version of the saved file. + /// 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored. + /// + /// Pdf stream. + public bool Save(Stream stream, SaveFlags flags = SaveFlags.None, int version = 0) + => PDFium.FPDF_SaveAsCopy(this.Handle, stream, flags, version); + + /// + /// Saves the to the file system. + /// + /// Save flags. + /// + /// The new PDF file version of the saved file. + /// 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored. + /// + /// File name. + public bool Save(string filename, SaveFlags flags = SaveFlags.None, int version = 0) + { + using (var stream = new FileStream(filename, FileMode.Create)) + { + return this.Save(stream, flags, version); + } + } + + public PdfBookmark FindBookmark(string title) + { + var handle = PDFium.FPDFBookmark_Find(this.Handle, title); + return handle.IsNull ? null : new PdfBookmark(this, handle); + } + + public string GetMetaText(MetadataTags tag) => PDFium.FPDF_GetMetaText(this.Handle, tag); + + public void CopyViewerPreferencesFrom(PdfDocument srcDoc) => PDFium.FPDF_CopyViewerPreferences(this.Handle, srcDoc.Handle); + + protected override void Dispose(FPDF_DOCUMENT handle) + { + if (!this.form.IsNull) + { + PDFium.FORM_DoDocumentAAction(this.form, FPDFDOC_AACTION.WC); + PDFium.FPDFDOC_ExitFormFillEnvironment(this.form); + this.form = FPDF_FORMHANDLE.Null; + this.formCallbacks = null; + + if (this.formCallbacksHandle.IsAllocated) + { + this.formCallbacksHandle.Free(); + } + } + + ((IDisposable)this.Pages).Dispose(); + PDFium.FPDF_CloseDocument(handle); + } + } +} \ No newline at end of file diff --git a/PDFiumSharp/PdfPage.cs b/PDFiumSharp/PdfPage.cs index 94350ea..7b5fd8f 100644 --- a/PDFiumSharp/PdfPage.cs +++ b/PDFiumSharp/PdfPage.cs @@ -6,10 +6,8 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Text; +using PDFiumSharp.Enums; using PDFiumSharp.Types; -using System.Runtime.InteropServices; namespace PDFiumSharp { @@ -91,7 +89,12 @@ public void Render(PDFiumBitmap renderTarget, (int left, int top, int width, int if (renderTarget == null) throw new ArgumentNullException(nameof(renderTarget)); + var form = this.Document.Form; + PDFium.FPDF_RenderPageBitmap(renderTarget.Handle, this.Handle, rectDest.left, rectDest.top, rectDest.width, rectDest.height, orientation, flags); + + if (!form.IsNull && flags.HasFlag(RenderingFlags.Annotations)) + PDFium.FPDF_FFLDraw(form, renderTarget.Handle, this.Handle, rectDest.left, rectDest.top, rectDest.width, rectDest.height, orientation, flags); } /// diff --git a/PDFiumSharp/PdfPageCollection.cs b/PDFiumSharp/PdfPageCollection.cs index 77fc0ec..9c9496c 100644 --- a/PDFiumSharp/PdfPageCollection.cs +++ b/PDFiumSharp/PdfPageCollection.cs @@ -8,7 +8,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; using System.Linq; namespace PDFiumSharp @@ -76,7 +75,7 @@ IEnumerator IEnumerable.GetEnumerator() /// public bool Insert(int index, PdfDocument sourceDocument, params int[] srcPageIndices) { - bool result = false; + bool result; if (index <= _pages.Count) { result = PDFium.FPDF_ImportPages(_doc.Handle, sourceDocument.Handle, index, srcPageIndices); @@ -110,7 +109,7 @@ public bool Add(PdfDocument sourceDocument, params int[] srcPageIndices) /// public PdfPage Insert(int index, double width, double height) { - PdfPage page=null; + PdfPage page; if (index <= _pages.Count) { page = PdfPage.New(_doc, index, width, height); diff --git a/PDFiumSharp/PinnedGCHandle.cs b/PDFiumSharp/PinnedGCHandle.cs index 2dbe4f0..849f2eb 100644 --- a/PDFiumSharp/PinnedGCHandle.cs +++ b/PDFiumSharp/PinnedGCHandle.cs @@ -6,8 +6,6 @@ */ #endregion using System; -using System.Collections.Generic; -using System.Text; using System.Runtime.InteropServices; namespace PDFiumSharp diff --git a/PDFiumSharp/Types/FPDFANNOT_COLORTYPE.cs b/PDFiumSharp/Types/FPDFANNOT_COLORTYPE.cs new file mode 100644 index 0000000..6f992df --- /dev/null +++ b/PDFiumSharp/Types/FPDFANNOT_COLORTYPE.cs @@ -0,0 +1,8 @@ +namespace PDFiumSharp.Types +{ // ReSharper disable InconsistentNaming + public enum FPDFANNOT_COLORTYPE : uint + { + Color = 0, + InteriorColor + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FPDFDOC_AACTION.cs b/PDFiumSharp/Types/FPDFDOC_AACTION.cs new file mode 100644 index 0000000..0295369 --- /dev/null +++ b/PDFiumSharp/Types/FPDFDOC_AACTION.cs @@ -0,0 +1,11 @@ +namespace PDFiumSharp.Types +{ + public enum FPDFDOC_AACTION + { + WC = 0x10, + WS = 0x11, + DS = 0x12, + WP = 0x13, + DP = 0x14 + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FPDF_ANNOTATION_SUBTYPE.cs b/PDFiumSharp/Types/FPDF_ANNOTATION_SUBTYPE.cs new file mode 100644 index 0000000..047bcd5 --- /dev/null +++ b/PDFiumSharp/Types/FPDF_ANNOTATION_SUBTYPE.cs @@ -0,0 +1,35 @@ +namespace PDFiumSharp.Types +{ // ReSharper disable InconsistentNaming + public enum FPDF_ANNOTATION_SUBTYPE : uint + { + UNKNOWN = 0, + TEXT = 1, + LINK = 2, + FREETEXT = 3, + LINE = 4, + SQUARE = 5, + CIRCLE = 6, + POLYGON = 7, + POLYLINE = 8, + HIGHLIGHT = 9, + UNDERLINE = 10, + SQUIGGLY = 11, + STRIKEOUT = 12, + STAMP = 13, + CARET = 14, + INK = 15, + POPUP = 16, + FILEATTACHMENT = 17, + SOUND = 18, + MOVIE = 19, + WIDGET = 20, + SCREEN = 21, + PRINTERMARK = 22, + TRAPNET = 23, + WATERMARK = 24, + THREED = 25, + RICHMEDIA = 26, + XFAWIDGET = 27, + REDACT = 28 + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FPDF_ANNOT_APPEARANCEMODE.cs b/PDFiumSharp/Types/FPDF_ANNOT_APPEARANCEMODE.cs new file mode 100644 index 0000000..72c73c9 --- /dev/null +++ b/PDFiumSharp/Types/FPDF_ANNOT_APPEARANCEMODE.cs @@ -0,0 +1,10 @@ +namespace PDFiumSharp.Types +{ // ReSharper disable InconsistentNaming + public enum FPDF_ANNOT_APPEARANCEMODE : uint + { + NORMAL = 0, + ROLLOVER = 1, + DOWN = 2, + COUNT = 3 + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FPDF_COLOR.cs b/PDFiumSharp/Types/FPDF_COLOR.cs index 8144951..5866bff 100644 --- a/PDFiumSharp/Types/FPDF_COLOR.cs +++ b/PDFiumSharp/Types/FPDF_COLOR.cs @@ -5,7 +5,6 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; using System.Runtime.InteropServices; namespace PDFiumSharp.Types diff --git a/PDFiumSharp/Types/FPDF_ERR.cs b/PDFiumSharp/Types/FPDF_ERR.cs index 122ecd2..0439874 100644 --- a/PDFiumSharp/Types/FPDF_ERR.cs +++ b/PDFiumSharp/Types/FPDF_ERR.cs @@ -5,10 +5,6 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; -using System.Collections.Generic; -using System.Text; - namespace PDFiumSharp.Types { public enum FPDF_ERR : uint diff --git a/PDFiumSharp/Types/FPDF_FILEACCESS.cs b/PDFiumSharp/Types/FPDF_FILEACCESS.cs index 1dfcc47..c2c5526 100644 --- a/PDFiumSharp/Types/FPDF_FILEACCESS.cs +++ b/PDFiumSharp/Types/FPDF_FILEACCESS.cs @@ -67,4 +67,12 @@ public FPDF_FILEWRITE(FileWriteBlockHandler writeBlock) _writeBlock = writeBlock; } } + + [StructLayout(LayoutKind.Sequential)] + public struct FPDF_FILEACCESS + { + readonly ulong m_FileLen; + readonly IntPtr m_GetBlock; + readonly IntPtr m_Param; + } } diff --git a/PDFiumSharp/Types/FPDF_FORMFILLINFO.cs b/PDFiumSharp/Types/FPDF_FORMFILLINFO.cs new file mode 100644 index 0000000..7098193 --- /dev/null +++ b/PDFiumSharp/Types/FPDF_FORMFILLINFO.cs @@ -0,0 +1,77 @@ +using System; +using System.Runtime.InteropServices; + +namespace PDFiumSharp.Types +{ // ReSharper disable once InconsistentNaming + [StructLayout(LayoutKind.Sequential)] + public class FPDF_FORMFILLINFO + { + public FPDF_FORMFILLINFO(int version) => this.version = version; + + private readonly int version; + + public int Version => this.version; + + private readonly IntPtr Release; + + private readonly IntPtr FFI_Invalidate; + + private readonly IntPtr FFI_OutputSelectedRect; + + private readonly IntPtr FFI_SetCursor; + + private readonly IntPtr FFI_SetTimer; + + private readonly IntPtr FFI_KillTimer; + + private readonly IntPtr FFI_GetLocalTime; + + private readonly IntPtr FFI_OnChange; + + private readonly IntPtr FFI_GetPage; + + private readonly IntPtr FFI_GetCurrentPage; + + private readonly IntPtr FFI_GetRotation; + + private readonly IntPtr FFI_ExecuteNamedAction; + + private readonly IntPtr FFI_SetTextFieldFocus; + + private readonly IntPtr FFI_DoURIAction; + + private readonly IntPtr FFI_DoGoToAction; + + private readonly IntPtr m_pJsPlatform; + + private readonly IntPtr FFI_DisplayCaret; + + private readonly IntPtr FFI_GetCurrentPageIndex; + + private readonly IntPtr FFI_SetCurrentPage; + + private readonly IntPtr FFI_GotoURL; + + private readonly IntPtr FFI_GetPageViewRect; + + private readonly IntPtr FFI_PageEvent; + + private readonly IntPtr FFI_PopupMenu; + + private readonly IntPtr FFI_OpenFile; + + private readonly IntPtr FFI_EmailTo; + + private readonly IntPtr FFI_UploadTo; + + private readonly IntPtr FFI_GetPlatform; + + private readonly IntPtr FFI_GetLanguage; + + private readonly IntPtr FFI_DownloadFromURL; + + private readonly IntPtr FFI_PostRequestURL; + + private readonly IntPtr FFI_PutRequestURL; + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FPDF_IMAGEOBJ_METADATA.cs b/PDFiumSharp/Types/FPDF_IMAGEOBJ_METADATA.cs new file mode 100644 index 0000000..c1f0a02 --- /dev/null +++ b/PDFiumSharp/Types/FPDF_IMAGEOBJ_METADATA.cs @@ -0,0 +1,41 @@ +using System.Runtime.InteropServices; + +namespace PDFiumSharp.Types +{ + [StructLayout(LayoutKind.Sequential)] + public struct FPDF_IMAGEOBJ_METADATA + { + // The image width in pixels. + public uint Width { get; } + + // The image height in pixels. + public uint Height { get; } + + // The image's horizontal pixel-per-inch. + public float HorizontalDpi { get; } + + // The image's vertical pixel-per-inch. + public float VerticalDpi { get; } + + // The number of bits used to represent each pixel. + public uint BitsPerPixel { get; } + + // The image's colorspace. See above for the list of FPDF_COLORSPACE_*. + public int Colorspace { get; } + + // The image's marked content ID. Useful for pairing with associated alt-text. + // A value of -1 indicates no ID. + public int MarkedContentId { get; } + + public FPDF_IMAGEOBJ_METADATA(uint width, uint height, float horizontalDpi, float verticalDpi, uint bitsPerPixel, int colorspace, int markedContentId) + { + Width = width; + Height = height; + HorizontalDpi = horizontalDpi; + VerticalDpi = verticalDpi; + BitsPerPixel = bitsPerPixel; + Colorspace = colorspace; + MarkedContentId = markedContentId; + } + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FPDF_LIBRARY_CONFIG.cs b/PDFiumSharp/Types/FPDF_LIBRARY_CONFIG.cs index 7ca83d7..831be9f 100644 --- a/PDFiumSharp/Types/FPDF_LIBRARY_CONFIG.cs +++ b/PDFiumSharp/Types/FPDF_LIBRARY_CONFIG.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; namespace PDFiumSharp.Types -{ +{ // ReSharper disable InconsistentNaming [StructLayout(LayoutKind.Sequential)] public struct FPDF_LIBRARY_CONFIG { diff --git a/PDFiumSharp/Types/FPDF_RESULT.cs b/PDFiumSharp/Types/FPDF_RESULT.cs new file mode 100644 index 0000000..fd2b306 --- /dev/null +++ b/PDFiumSharp/Types/FPDF_RESULT.cs @@ -0,0 +1,38 @@ +#region Copyright and License + +/* +This file is part of PDFiumSharp, a wrapper around the PDFium library for the .NET framework. +Copyright (C) 2017 Tobias Meyer +License: Microsoft Reciprocal License (MS-RL) +*/ + +#endregion + +namespace PDFiumSharp.Types +{ // ReSharper disable InconsistentNaming + public enum FPDF_RESULT + { + /// + /// No error. + /// + SUCCESS = 0, + + /// + /// Error. + /// + ERROR = -1 + } + + public static class PDF_RESULT_Extension + { + public static string GetDescription(this FPDF_RESULT error) + { + switch (error) + { + case FPDF_RESULT.SUCCESS: return "No error."; + case FPDF_RESULT.ERROR: return "Error."; + default: return $"{error} (No description available)."; + } + } + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FPDF_TEXT_RENDERMODE.cs b/PDFiumSharp/Types/FPDF_TEXT_RENDERMODE.cs new file mode 100644 index 0000000..54bf1a9 --- /dev/null +++ b/PDFiumSharp/Types/FPDF_TEXT_RENDERMODE.cs @@ -0,0 +1,19 @@ +namespace PDFiumSharp.Types +{ // ReSharper disable InconsistentNaming + /// + /// PDF text rendering modes + /// + public enum FPDF_TEXT_RENDERMODE + { + UNKNOWN = -1, + FILL = 0, + STROKE = 1, + FILL_STROKE = 2, + INVISIBLE = 3, + FILL_CLIP = 4, + STROKE_CLIP = 5, + FILL_STROKE_CLIP = 6, + CLIP = 7, + LAST = CLIP, + } +} diff --git a/PDFiumSharp/Types/FPDF_Typedefs.tt b/PDFiumSharp/Types/FPDF_Typedefs.tt index 7846e24..3ee986d 100644 --- a/PDFiumSharp/Types/FPDF_Typedefs.tt +++ b/PDFiumSharp/Types/FPDF_Typedefs.tt @@ -10,26 +10,47 @@ License: Microsoft Reciprocal License (MS-RL) <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".g.cs" #> <# // ------------------------------------------------------ Code Start ------------------------------------------------------ -string[] Names = { - "FPDF_ACTION", - "FPDF_BITMAP", - "FPDF_BOOKMARK", - "FPDF_CLIPPATH", - "FPDF_DEST", - "FPDF_DOCUMENT", - "FPDF_FONT", - "FPDF_LINK", - "FPDF_PAGE", - "FPDF_PAGELINK", - "FPDF_PAGEOBJECT", // Page object(text, path, etc) - "FPDF_PAGERANGE", +//This types from here: https://pdfium.googlesource.com/pdfium/+/master/public/fpdfview.h from line: // PDF types - use incomplete types (never completed) just for API type safety. +string[] names = { + "FPDF_ACTION", + "FPDF_ANNOTATION", + "FPDF_ATTACHMENT", + "FPDF_AVAIL", + "FPDF_BITMAP", + "FPDF_BOOKMARK", + "FPDF_BSTR", + "FPDF_CLIPPATH", + "FPDF_COLORSCHEME", + "FPDF_DEST", + "FPDF_DOCUMENT", + "FPDF_FILEIDTYPE", + "FPDF_FONT", + "FPDF_FORMHANDLE", + "FPDF_GLYPHPATH", + "FPDF_JAVASCRIPT_ACTION", + "FPDF_LINK", + "FPDF_PAGE", + "FPDF_PAGELINK", + "FPDF_PAGEOBJECT", // Page object(text, path, etc) + "FPDF_PAGEOBJECTMARK", + "FPDF_PAGERANGE", + "FPDF_PATHSEGMENT", "FPDF_RECORDER", - "FPDF_SCHHANDLE", - "FPDF_STRUCTELEMENT", - "FPDF_STRUCTTREE", - "FPDF_TEXTPAGE", - "FPDF_STRINGHANDLE", - "FPDF_WIDGET" }; + "FPDF_OBJECT_TYPE", + "FPDF_SCHHANDLE", + "FPDF_SIGNATURE", + "FPDF_SKIA_CANVAS", + "FPDF_STRUCTELEMENT", + "FPDF_STRUCTELEMENT_ATTR", + "FPDF_STRUCTTREE", + "FPDF_SYSFONTINFO", + "FPDF_TEXTPAGE", + "FPDF_XOBJECT", + "FPDF_WCHAR", + "FPDF_WIDGET", + "UNSUPPORT_INFO", + "FX_FILEAVAIL" +}; // --------------------------------------------------------- Code End ----------------------------------------------------- #> #region Copyright and License /* @@ -48,7 +69,7 @@ using System.Threading; namespace PDFiumSharp.Types { <# // ------------------------------------------------------ Code Start ------------------------------------------------------ -foreach (string name in Names) +foreach (var name in names) { // --------------------------------------------------------- Code End ----------------------------------------------------- #> /// Handle to a <#=name#> diff --git a/PDFiumSharp/Types/FS_MATRIX.cs b/PDFiumSharp/Types/FS_MATRIX.cs index 7b00420..41acd47 100644 --- a/PDFiumSharp/Types/FS_MATRIX.cs +++ b/PDFiumSharp/Types/FS_MATRIX.cs @@ -5,7 +5,6 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; using System.Runtime.InteropServices; namespace PDFiumSharp.Types diff --git a/PDFiumSharp/Types/FS_POINTF.cs b/PDFiumSharp/Types/FS_POINTF.cs new file mode 100644 index 0000000..e42692a --- /dev/null +++ b/PDFiumSharp/Types/FS_POINTF.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace PDFiumSharp.Types +{ + [StructLayout(LayoutKind.Sequential)] + public struct FS_POINTF + { + public float X { get; } + public float Y { get; } + + public FS_POINTF(float x, float y) + { + this.X = x; + this.Y = y; + } + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/FS_QUADPOINTSF.cs b/PDFiumSharp/Types/FS_QUADPOINTSF.cs index b12d587..d4c26aa 100644 --- a/PDFiumSharp/Types/FS_QUADPOINTSF.cs +++ b/PDFiumSharp/Types/FS_QUADPOINTSF.cs @@ -1,5 +1,4 @@ -using System; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace PDFiumSharp.Types { diff --git a/PDFiumSharp/Types/FS_RECTF.cs b/PDFiumSharp/Types/FS_RECTF.cs index 533d37c..92a3c84 100644 --- a/PDFiumSharp/Types/FS_RECTF.cs +++ b/PDFiumSharp/Types/FS_RECTF.cs @@ -5,17 +5,34 @@ License: Microsoft Reciprocal License (MS-RL) */ #endregion -using System; using System.Runtime.InteropServices; namespace PDFiumSharp.Types { + /// + /// Rectangle area(float) in device or page coordinate system. + /// [StructLayout(LayoutKind.Sequential)] public struct FS_RECTF { + /// + /// The x-coordinate of the left-top corner. + /// public float Left { get; } + + /// + /// The y-coordinate of the left-top corner. + /// public float Top { get; } + + /// + /// The x-coordinate of the right-bottom corner. + /// public float Right { get; } + + /// + /// The y-coordinate of the right-bottom corner. + /// public float Bottom { get; } public FS_RECTF(float left, float top, float right, float bottom) diff --git a/PDFiumSharp/Types/FS_SIZEF.cs b/PDFiumSharp/Types/FS_SIZEF.cs new file mode 100644 index 0000000..6c2be32 --- /dev/null +++ b/PDFiumSharp/Types/FS_SIZEF.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace PDFiumSharp.Types +{ + /// + /// Rectangle size. Coordinate system agnostic. + /// + [StructLayout(LayoutKind.Sequential)] + public struct FS_SIZEF + { + public float Width { get; } + public float Height { get; } + + public FS_SIZEF(float width, float height) + { + Width = width; + Height = height; + } + } +} diff --git a/PDFiumSharp/Types/FX_DOWNLOADHINTS.cs b/PDFiumSharp/Types/FX_DOWNLOADHINTS.cs new file mode 100644 index 0000000..eed2502 --- /dev/null +++ b/PDFiumSharp/Types/FX_DOWNLOADHINTS.cs @@ -0,0 +1,12 @@ +using System; +using System.Runtime.InteropServices; + +namespace PDFiumSharp.Types +{ // ReSharper disable once InconsistentNaming + [StructLayout(LayoutKind.Sequential)] + public struct FX_DOWNLOADHINTS + { + public readonly int Version; + public readonly IntPtr AddSegment; + } +} \ No newline at end of file diff --git a/PDFiumSharp/Types/IHandle.cs b/PDFiumSharp/Types/IHandle.cs index 0b1b3f1..a0db923 100644 --- a/PDFiumSharp/Types/IHandle.cs +++ b/PDFiumSharp/Types/IHandle.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace PDFiumSharp.Types +namespace PDFiumSharp.Types { public interface IHandle { diff --git a/PDFiumSharp/Types/NativeWrapper.cs b/PDFiumSharp/Types/NativeWrapper.cs index d4b7b17..a346c57 100644 --- a/PDFiumSharp/Types/NativeWrapper.cs +++ b/PDFiumSharp/Types/NativeWrapper.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; namespace PDFiumSharp.Types { diff --git a/PDFiumSharp/Types/Utf8StringMarshaler.cs b/PDFiumSharp/Types/Utf8StringMarshaler.cs new file mode 100644 index 0000000..0b37ebc --- /dev/null +++ b/PDFiumSharp/Types/Utf8StringMarshaler.cs @@ -0,0 +1,110 @@ +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2016 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ + +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace PDFiumSharp.Types +{ + internal unsafe class Utf8StringMarshaler : ICustomMarshaler + { + public const string LeaveAllocated = "LeaveAllocated"; + + private static readonly ICustomMarshaler leaveAllocatedInstance = new Utf8StringMarshaler(true); + + private static readonly ICustomMarshaler defaultInstance = new Utf8StringMarshaler(false); + + public static ICustomMarshaler GetInstance(string cookie) + { + switch (cookie) + { + case "LeaveAllocated": + return leaveAllocatedInstance; + default: + return defaultInstance; + } + } + + private readonly bool leaveAllocated; + + public Utf8StringMarshaler(bool leaveAllocated) => this.leaveAllocated = leaveAllocated; + + public object MarshalNativeToManaged(IntPtr pNativeData) + { + if (pNativeData == IntPtr.Zero) + { + return null; + } + + var ptr = (byte*)pNativeData; + while (*ptr != 0) + { + ptr++; + } + + var bytes = new byte[ptr - (byte*)pNativeData]; + Marshal.Copy(pNativeData, bytes, 0, bytes.Length); + return Encoding.UTF8.GetString(bytes); + } + + public IntPtr MarshalManagedToNative(object managedObj) + { + if (managedObj == null) + { + return IntPtr.Zero; + } + + if (!(managedObj is string str)) + { + throw new ArgumentException("ManagedObj must be a string.", "managedObj"); + } + + var bytes = Encoding.UTF8.GetBytes(str); + var mem = Marshal.AllocHGlobal(bytes.Length + 1); + Marshal.Copy(bytes, 0, mem, bytes.Length); + var b = (byte*)mem; + if (b != null) + { + b[bytes.Length] = 0; + } + + return mem; + } + + public void CleanUpManagedData(object managedObj) { } + + public void CleanUpNativeData(IntPtr pNativeData) + { + if (!this.leaveAllocated) + { + Marshal.FreeHGlobal(pNativeData); + } + } + + public int GetNativeDataSize() => -1; + } +} \ No newline at end of file diff --git a/Samples/Test.Console/Program.cs b/Samples/Test.Console/Program.cs index f695f82..b204e3c 100644 --- a/Samples/Test.Console/Program.cs +++ b/Samples/Test.Console/Program.cs @@ -1,21 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using PDFiumSharp; -using System.IO; -namespace TestConsole +namespace Test.Console { - class Program - { - static void Main(string[] args) - { - using (var doc = new PdfDocument("TestDoc.pdf", "password")) - { - int i = 0; - foreach (var page in doc.Pages) + internal class Program + { + private static void Main(string[] args) + { + using (var doc = new PdfDocument("TestDoc.pdf", "password")) + { + var i = 0; + foreach (var page in doc.Pages) + { using (page) { using (var bitmap = new PDFiumBitmap((int)page.Width, (int)page.Height, true)) @@ -25,9 +21,10 @@ static void Main(string[] args) bitmap.Save(stream); } } - - } - Console.ReadKey(); - } - } -} + } + } + + System.Console.ReadKey(); + } + } +} \ No newline at end of file diff --git a/Samples/Test.Console/Properties/AssemblyInfo.cs b/Samples/Test.Console/Properties/AssemblyInfo.cs index db70c36..5846b98 100644 --- a/Samples/Test.Console/Properties/AssemblyInfo.cs +++ b/Samples/Test.Console/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Samples/Test.GdiPlus/Form1.cs b/Samples/Test.GdiPlus/Form1.cs index adff33a..40faeac 100644 --- a/Samples/Test.GdiPlus/Form1.cs +++ b/Samples/Test.GdiPlus/Form1.cs @@ -1,11 +1,5 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using PDFiumSharp; diff --git a/Samples/Test.GdiPlus/Program.cs b/Samples/Test.GdiPlus/Program.cs index cc1d686..57ebad0 100644 --- a/Samples/Test.GdiPlus/Program.cs +++ b/Samples/Test.GdiPlus/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; namespace Test.GdiPlus diff --git a/Samples/Test.GdiPlus/Properties/AssemblyInfo.cs b/Samples/Test.GdiPlus/Properties/AssemblyInfo.cs index b8e5297..14c1e23 100644 --- a/Samples/Test.GdiPlus/Properties/AssemblyInfo.cs +++ b/Samples/Test.GdiPlus/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Samples/Test.GdiPlus/Test.GdiPlus.csproj b/Samples/Test.GdiPlus/Test.GdiPlus.csproj index 71b836b..1b00e18 100644 --- a/Samples/Test.GdiPlus/Test.GdiPlus.csproj +++ b/Samples/Test.GdiPlus/Test.GdiPlus.csproj @@ -93,7 +93,7 @@ - 4.3.0 + 4.5.0 diff --git a/Samples/Test.Nuget/Program.cs b/Samples/Test.Nuget/Program.cs index e8c3dc1..4127670 100644 --- a/Samples/Test.Nuget/Program.cs +++ b/Samples/Test.Nuget/Program.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using PDFiumSharp; +using PDFiumSharp; namespace Test.Nuget { diff --git a/Samples/Test.Nuget/Properties/AssemblyInfo.cs b/Samples/Test.Nuget/Properties/AssemblyInfo.cs index 659afcf..a903008 100644 --- a/Samples/Test.Nuget/Properties/AssemblyInfo.cs +++ b/Samples/Test.Nuget/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Samples/Test.Nuget/Test.Nuget.csproj b/Samples/Test.Nuget/Test.Nuget.csproj index 6f7f344..a7facab 100644 --- a/Samples/Test.Nuget/Test.Nuget.csproj +++ b/Samples/Test.Nuget/Test.Nuget.csproj @@ -53,11 +53,11 @@ - - 1.0.0 + + 1.1.4 - - 0.1.1-beta + + 1.1.4 diff --git a/Samples/Test.Wpf/App.xaml.cs b/Samples/Test.Wpf/App.xaml.cs index 5122d0d..b936b0b 100644 --- a/Samples/Test.Wpf/App.xaml.cs +++ b/Samples/Test.Wpf/App.xaml.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; namespace Test.Wpf { diff --git a/Samples/Test.Wpf/MainWindow.xaml.cs b/Samples/Test.Wpf/MainWindow.xaml.cs index dcc5a3e..ea67617 100644 --- a/Samples/Test.Wpf/MainWindow.xaml.cs +++ b/Samples/Test.Wpf/MainWindow.xaml.cs @@ -1,17 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; +using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using PDFiumSharp; namespace Test.Wpf diff --git a/Samples/Test.Wpf/Properties/AssemblyInfo.cs b/Samples/Test.Wpf/Properties/AssemblyInfo.cs index 64c32c2..6c3e46a 100644 --- a/Samples/Test.Wpf/Properties/AssemblyInfo.cs +++ b/Samples/Test.Wpf/Properties/AssemblyInfo.cs @@ -1,6 +1,4 @@ using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; diff --git a/Samples/Test.Wpf/Test.Wpf.csproj b/Samples/Test.Wpf/Test.Wpf.csproj index df5afb6..688e6d4 100644 --- a/Samples/Test.Wpf/Test.Wpf.csproj +++ b/Samples/Test.Wpf/Test.Wpf.csproj @@ -119,7 +119,7 @@ - 4.3.0 + 4.5.0 diff --git a/Samples/Test.Xwt/Program.cs b/Samples/Test.Xwt/Program.cs index 2535f34..4e9a073 100644 --- a/Samples/Test.Xwt/Program.cs +++ b/Samples/Test.Xwt/Program.cs @@ -1,19 +1,15 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xwt; using Xwt.Drawing; using PDFiumSharp; -using System.IO; +using PDFiumSharp.Enums; namespace Test.Xwt { class Program { [STAThread] - static void Main(string[] args) + static void Main() { Application.Initialize(); Window window = new Window(); diff --git a/Samples/Test.Xwt/Properties/AssemblyInfo.cs b/Samples/Test.Xwt/Properties/AssemblyInfo.cs index 6102524..bb9e1fb 100644 --- a/Samples/Test.Xwt/Properties/AssemblyInfo.cs +++ b/Samples/Test.Xwt/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Samples/Test.Xwt/Test.Xwt.csproj b/Samples/Test.Xwt/Test.Xwt.csproj index b5c06c6..1cee744 100644 --- a/Samples/Test.Xwt/Test.Xwt.csproj +++ b/Samples/Test.Xwt/Test.Xwt.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -67,13 +68,13 @@ - 4.3.0 + 4.5.0 - 0.2.5 + 0.2.218 - 0.2.5 + 0.2.218