private static void ObjectSetting(IntPtr settings, string name, bool?value) { if (value.HasValue) { WkHtmlToXBinding.wkhtmltopdf_set_object_setting(settings, name, value.Value ? "true" : "false"); } }
private static void ObjectSetting(IntPtr settings, string name, int?value) { if (value.HasValue) { WkHtmlToXBinding.wkhtmltopdf_set_object_setting(settings, name, value.ToString()); } }
private static byte[] _HtmlToPdf(byte[] bytes, WkHtmlToPdfSettings settings) { var globalSettings = WkHtmlToXBinding.wkhtmltopdf_create_global_settings(); var objectSettings = WkHtmlToXBinding.wkhtmltopdf_create_object_settings(); // Set global and object settings FillSettings(globalSettings, objectSettings, settings); var converter = WkHtmlToXBinding.wkhtmltopdf_create_converter(globalSettings); WkHtmlToXBinding.wkhtmltopdf_set_error_callback(converter, (cc, str) => { Console.WriteLine("Error: " + str); }); WkHtmlToXBinding.wkhtmltopdf_add_object(converter, objectSettings, bytes); // WkHtmlToXBinding.wkhtmltopdf_add_object(converter, objectSettings, new byte[] { .. }); if (!WkHtmlToXBinding.wkhtmltopdf_convert(converter)) { return(null); } var ret = GetConversionResult(converter); // Destroy all WkHtmlToXBinding.wkhtmltopdf_destroy_global_settings(globalSettings); WkHtmlToXBinding.wkhtmltopdf_destroy_object_settings(objectSettings); WkHtmlToXBinding.wkhtmltopdf_destroy_converter(converter); return(ret); }
private static void ObjectSetting(IntPtr settings, string name, double?value) { if (value.HasValue) { WkHtmlToXBinding.wkhtmltopdf_set_object_setting(settings, name, value.Value.ToString("0.##", CultureInfo.InvariantCulture)); } }
private static byte[] GetConversionResult(IntPtr converter) { var length = WkHtmlToXBinding.wkhtmltopdf_get_output(converter, out var resultPointer); var result = new byte[length]; Marshal.Copy(resultPointer, result, 0, length); return(result); }
private static void ObjectSetting(IntPtr settings, string name, string value) { if (string.IsNullOrEmpty(value)) { return; } WkHtmlToXBinding.wkhtmltopdf_set_object_setting(settings, name, value); }
private static void Run() { if (WkHtmlToXBinding.wkhtmltopdf_init(0) != 1) { throw new Exception("Could not initialize WkHtmlToPDF library"); } while (!_kill) { //get next conversion taks from blocking collection Task task = Conversions.Take(); lock (task) { //run taks on thread that called RunSynchronously method task.RunSynchronously(); //notify caller thread that task is completed Monitor.Pulse(task); } } }
private static int SetObjectSetting(IntPtr settings, string name, string value) { return(WkHtmlToXBinding.wkhtmltopdf_set_object_setting(settings, name, value)); }
private static int SetGlobalSetting(IntPtr settings, string name, string value) { return(WkHtmlToXBinding.wkhtmltopdf_set_global_setting(settings, name, value)); }
public static bool ExtendedQt() { return(WkHtmlToXBinding.wkhtmltopdf_extended_qt() == 1); }
public static string GetVersion() { return(Marshal.PtrToStringAnsi(WkHtmlToXBinding.wkhtmltopdf_version())); }