BVB Source Codes

PDF file browser Show PageSizeConverter.cs Source code

Return Download PDF file browser: download PageSizeConverter.cs Source code - Download PDF file browser Source code - Type:.cs
  1. //
  2. // PDFsharp - A library for processing PDF
  3. //
  4. // Authors:
  5. //   Stefan Lange (mailto:Stefan.Lange@pdfsharp.com)
  6. //
  7. // Copyright (c) 2005 empira Software GmbH, Cologne (Germany)
  8. //
  9. // http://www.pdfsharp.com
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29.  
  30. using System;
  31. #if Gdip
  32. using System.Drawing;
  33. #endif
  34. #if WinFX
  35. using System.Windows;
  36. #endif
  37.  
  38. namespace PdfSharp
  39. {
  40.   /// <summary>
  41.   ///
  42.   /// </summary>
  43.   public sealed class PageSizeConverter
  44.   {
  45.     PageSizeConverter()
  46.     {
  47.     }
  48.  
  49.     /// <summary>
  50.     /// Converts the specified page size enumeration to a pair of values in point.
  51.     /// </summary>
  52.     public static Size ToSize(PageSize value)
  53.     {
  54.       // The international definitions are:
  55.       //   1 inch == 25.4 mm
  56.       //   1 inch == 72 point
  57.       switch (value)
  58.       {
  59.         case PageSize.A0:
  60.           return new Size(2380, 3368);
  61.  
  62.         case PageSize.A1:
  63.           return new Size(1684, 2380);
  64.  
  65.         case PageSize.A2:
  66.           return new Size(1190, 1684);
  67.  
  68.         case PageSize.A3:
  69.           return new Size(842, 1190);
  70.  
  71.         case PageSize.A4:
  72.           return new Size(595, 842);
  73.  
  74.         case PageSize.A5:
  75.           return new Size(420, 595);
  76.  
  77.  
  78.         case PageSize.RA0:
  79.           return new Size(2438, 3458);
  80.  
  81.         case PageSize.RA1:
  82.           return new Size(1729, 2438);
  83.  
  84.         case PageSize.RA2:
  85.           return new Size(1219, 1729);
  86.  
  87.         case PageSize.RA3:
  88.           return new Size(865, 1219);
  89.  
  90.         case PageSize.RA4:
  91.           return new Size(609, 865);
  92.  
  93.         case PageSize.RA5:
  94.           return new Size(343, 609);
  95.  
  96.  
  97.         case PageSize.B0:
  98.           return new Size(2835, 4008);
  99.  
  100.         case PageSize.B1:
  101.           return new Size(2004, 2835);
  102.  
  103.         case PageSize.B2:
  104.           return new Size(4252, 1417);
  105.  
  106.         case PageSize.B3:
  107.           return new Size(1001, 1417);
  108.  
  109.         case PageSize.B4:
  110.           return new Size(729, 1032);
  111.  
  112.         case PageSize.B5:
  113.           return new Size(516, 729);
  114.  
  115.         // The strange sizes from overseas...
  116.  
  117.         case PageSize.Quarto:           // 8 x 10 inch
  118.           return new Size(576, 720);
  119.  
  120.         case PageSize.Foolscap:         // 8 x 13 inch
  121.           return new Size(576, 936);
  122.  
  123.         case PageSize.Executive:        // 7.5 x 10 inch
  124.           return new Size(540, 720);
  125.  
  126.         case PageSize.GovernmentLetter: // 10.5 x 8 inch
  127.           return new Size(756, 576);
  128.  
  129.         case PageSize.Letter:           // 8.5 x 11 inch
  130.           return new Size(612, 792);
  131.  
  132.         case PageSize.Legal:            // 8.5 x 14 inch
  133.           return new Size(612, 1008);
  134.  
  135.         case PageSize.Ledger:           // 17 x 11 inch
  136.           return new Size(1224, 792);
  137.  
  138.         case PageSize.Tabloid:          // 11 x 17 inch
  139.           return new Size(792, 1224);
  140.  
  141.         case PageSize.Post:             // 15.5 x 19.25 inch
  142.           return new Size(1126, 1386);
  143.  
  144.         case PageSize.Crown:            // 20 x 15 inch
  145.           return new Size(1440, 1080);
  146.  
  147.         case PageSize.LargePost:        // 16.5 x 21 inch
  148.           return new Size(1188, 1512);
  149.  
  150.         case PageSize.Demy:             // 17.5 x 22 inch
  151.           return new Size(1260, 1584);
  152.  
  153.         case PageSize.Medium:           // 18 x 23 inch
  154.           return new Size(1296, 1656);
  155.  
  156.         case PageSize.Royal:            // 20 x 25 inch
  157.           return new Size(1440, 1800);
  158.  
  159.         case PageSize.Elephant:         // 23 x 28 inch
  160.           return new Size(1565, 2016);
  161.  
  162.         case PageSize.DoubleDemy:       // 23.5 x 35 inch
  163.           return new Size(1692, 2520);
  164.  
  165.         case PageSize.QuadDemy:         // 35 x 45 inch
  166.           return new Size(2520, 3240);
  167.  
  168.         case PageSize.STMT:             // 5.5 x 8.5 inch
  169.           return new Size(396, 612);
  170.  
  171.         case PageSize.Folio:            // 8.5 x 13 inch
  172.           return new Size(612, 936);
  173.  
  174.         case PageSize.Statement:        // 5.5 x 8.5 inch
  175.           return new Size(396, 612);
  176.  
  177.         case PageSize.Size10x14:        // 8.5 x 13 inch
  178.           return new Size(720, 1008);
  179.       }
  180.       throw new ArgumentException("Invalid PageSize.", "value");
  181.     }
  182.   }
  183. }
  184.  
downloadPageSizeConverter.cs Source code - Download PDF file browser Source code
Related Source Codes/Software:
Campus id - This system includes a campus dormitory management... 2015-04-10
ShopXP online system source code - ShopXP ShoppingNet online system source code infor... 2015-04-10
TOM cat demo in learning to speak - 实现汤米猫学说话的演示,即实现变声功能鲜豔,,,,,,,开发者说:自己经常来看code4app,看看... 2015-04-10
Another OpenFolder - Implements can commence in the middle of the scree... 2015-04-10
Bus query system - A simple bus query system. Can be divided into rou... 2015-04-10
Customer service management system - To a store and development of customer service man... 2015-04-10
OA office automation system - OA office automation system is tomorrow technology... 2015-04-10
Chapters novel divider (ChapCuttor) - Chapter divider (ChapCuttor) by & have spent Black... 2015-04-10
Graduation design file (graphics algorithm design) - Reference image effect algorithm design the softwa... 2015-04-10
CheatEngine5.6 source code - Game cheat the 5.6 version of the source code, it ... 2015-04-10
Online ZhaXunWang science formula query V1.0 - Including junior middle school and high school sci... 2016-10-20
Observe science formula query v1.0 - Observe network science formulas 2016-10-20
Lele v1.1 QQ login system - "Le Le QQ Group landing system Ver1.1" * Fix QQ ... 2016-10-20
The new network domain name host distribution system V1.0 - Use Notepad to open \Global.asa idc1688 into your ... 2016-10-20
QQ group v2.1 release system - ha ha - "Copyright" This system is based on the Wu Meng de... 2016-10-20
Interesting content ASPCMS v1.0 - Update log: 2016-10-20
Residential feng shui fortune-telling v1.0 - The project according to the orientation of the ar... 2016-10-20
The self-help chain home beautiful - The self-help chain home beautiful 2016-10-20
EXW FLASH web site management system v2.0 - EXW FLASH introduction: EXW website management sys... 2016-10-20
WAP2.0 web site management system V1.0 - System installation steps 1, install the QuickWAP ... 2016-10-20

 Back to top