print_job.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef PRINTING_PLUGIN_PRINT_JOB_H_
  17. #define PRINTING_PLUGIN_PRINT_JOB_H_
  18. #ifndef _GNU_SOURCE
  19. #define _GNU_SOURCE 1
  20. #endif
  21. #include <flutter_linux/flutter_linux.h>
  22. #include <gtk/gtk.h>
  23. #include <gtk/gtkunixprint.h>
  24. class print_job {
  25. private:
  26. const int index;
  27. GtkPrintJob* printJob = nullptr;
  28. public:
  29. GtkPrintUnixDialog* dialog = nullptr;
  30. explicit print_job(int index);
  31. ~print_job();
  32. int get_id() { return index; };
  33. static FlValue* list_printers();
  34. bool direct_print_pdf(const gchar* name,
  35. const uint8_t data[],
  36. size_t size,
  37. const gchar* printer);
  38. bool print_pdf(const gchar* name,
  39. const gchar* printer,
  40. double pageWidth,
  41. double pageHeight,
  42. double marginLeft,
  43. double marginTop,
  44. double marginRight,
  45. double marginBottom);
  46. void write_job(const uint8_t data[], size_t size);
  47. void cancel_job(const gchar* error);
  48. static bool share_pdf(const uint8_t data[], size_t size, const gchar* name);
  49. void raster_pdf(const uint8_t data[],
  50. size_t size,
  51. const int32_t pages[],
  52. size_t pages_count,
  53. double scale);
  54. static FlValue* printing_info();
  55. };
  56. void on_page_rasterized(print_job* job,
  57. const uint8_t* data,
  58. size_t size,
  59. int width,
  60. int height);
  61. void on_page_raster_end(print_job* job, const char* error);
  62. void on_layout(print_job* job,
  63. double pageWidth,
  64. double pageHeight,
  65. double marginLeft,
  66. double marginTop,
  67. double marginRight,
  68. double marginBottom);
  69. void on_completed(print_job* job, bool completed, const char* error);
  70. #endif // PRINTING_PLUGIN_PRINT_JOB_H_