Ejemplo n.º 1
0
        public unsafe string GetGlobalSetting(IntPtr settings, string name)
        {
            //default const char * size is 2048 bytes
            byte[] buffer = new byte[2048];

            fixed(byte *tempBuffer = buffer)
            {
                WkHtmlToXBindings.wkhtmltopdf_get_global_setting(settings, name, tempBuffer, buffer.Length);
            }

            return(GetString(buffer));
        }
Ejemplo n.º 2
0
        public int wkhtmltopdf_get_global_setting(IntPtr settings,
                                                  [MarshalAs((short)CustomUnmanagedType.LPUTF8Str)]
                                                  string name,
                                                  byte[] array)
        {
            int    size = Marshal.SizeOf(array[0]) * array.Length;
            IntPtr pnt  = Marshal.AllocHGlobal(size);

            try
            {
                // Copy the array to unmanaged memory.
                Marshal.Copy(array, 0, pnt, array.Length);

                return(WkHtmlToXBindings.wkhtmltopdf_get_global_setting(settings, name, pnt, size));
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pnt);
            }
        }