nup_parameters.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PRINTING_NUP_PARAMETERS_H_
  5. #define PRINTING_NUP_PARAMETERS_H_
  6. #include "base/component_export.h"
  7. namespace printing {
  8. class COMPONENT_EXPORT(PRINTING) NupParameters {
  9. public:
  10. // Callers should check `pages_per_sheet` values with IsSupported() first,
  11. // and only pass in supported values.
  12. NupParameters(int pages_per_sheet, bool is_source_landscape);
  13. // Whether or not the input `pages_per_sheet` is a supported N-up value.
  14. // Supported values are: 1 2 4 6 9 16
  15. static bool IsSupported(int pages_per_sheet);
  16. // Orientation of the to-be-generated N-up PDF document.
  17. bool landscape() const { return landscape_; }
  18. int num_pages_on_x_axis() const { return num_pages_on_x_axis_; }
  19. int num_pages_on_y_axis() const { return num_pages_on_y_axis_; }
  20. private:
  21. // Calculates the `num_pages_on_x_axis_`, `num_pages_on_y_axis_` and
  22. // `landscape_` based on the input.
  23. void SetParameters(int pages_per_sheet, bool is_source_landscape);
  24. int num_pages_on_x_axis_ = 1;
  25. int num_pages_on_y_axis_ = 1;
  26. bool landscape_ = false;
  27. };
  28. } // namespace printing
  29. #endif // PRINTING_NUP_PARAMETERS_H_