1 // Copyright (c) 2011 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.
5 #ifndef PRINTING_UNITS_H_
6 #define PRINTING_UNITS_H_
8 #include "printing/printing_export.h"
12 // Length of an inch in 0.001mm unit.
13 constexpr int kMicronsPerInch = 25400;
15 // Mil is a thousandth of an inch.
16 constexpr float kMicronsPerMil = 25.4f;
17 constexpr int kMilsPerInch = 1000;
19 // Length of an inch in CSS's 1pt unit.
20 // http://dev.w3.org/csswg/css3-values/#absolute-length-units-cm-mm.-in-pt-pc
21 const int kPointsPerInch = 72;
23 // Length of an inch in CSS's 1px unit.
24 // http://dev.w3.org/csswg/css3-values/#the-px-unit
25 const int kPixelsPerInch = 96;
27 // Dpi used to save to PDF or Cloud Print.
28 const int kDefaultPdfDpi = 300;
30 // LETTER: 8.5 x 11 inches
31 const float kLetterWidthInch = 8.5f;
32 const float kLetterHeightInch = 11.0f;
34 // LEGAL: 8.5 x 14 inches
35 const float kLegalWidthInch = 8.5f;
36 const float kLegalHeightInch = 14.0f;
38 // A4: 8.27 x 11.69 inches
39 const float kA4WidthInch = 8.27f;
40 const float kA4HeightInch = 11.69f;
42 // A3: 11.69 x 16.54 inches
43 const float kA3WidthInch = 11.69f;
44 const float kA3HeightInch = 16.54f;
46 // Converts from one unit system to another using integer arithmetics.
47 PRINTING_EXPORT int ConvertUnit(double value, int old_unit, int new_unit);
49 // Converts from one unit system to another using doubles.
50 PRINTING_EXPORT double ConvertUnitDouble(double value, double old_unit,
53 // Converts from 1 pixel to 1 point using integers.
54 PRINTING_EXPORT int ConvertPixelsToPoint(int pixels);
56 // Converts from 1 pixel to 1 point using doubles.
57 PRINTING_EXPORT double ConvertPixelsToPointDouble(double pixels);
59 // Converts from 1 point to 1 pixel using doubles.
60 PRINTING_EXPORT double ConvertPointsToPixelDouble(double points);
62 } // namespace printing
64 #endif // PRINTING_UNITS_H_