public unsafe string GetObjectSetting(IntPtr settings, string name) { //default const char * size is 2048 bytes byte[] buffer = new byte[2048]; fixed(byte *tempBuffer = buffer) { WkHtmlToXBindings.wkhtmltopdf_get_object_setting(settings, name, tempBuffer, buffer.Length); } return(GetString(buffer)); }
public int wkhtmltopdf_get_object_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_object_setting(settings, name, pnt, size)); } finally { // Free the unmanaged memory. Marshal.FreeHGlobal(pnt); } }