71 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Threading.Tasks;
 | |
| using VEPROMS.CSLA.Library;
 | |
| using iTextSharp.text;
 | |
| 
 | |
| 
 | |
| namespace Volian.Print.Library
 | |
| {
 | |
| 	public class PDFPageSize
 | |
| 	{
 | |
| 		// C2020-002 paper size is now set in the format files - this class is use to select the page size that PROMS should be using
 | |
| 		private static Dictionary<string, Rectangle> dicPDFPageSize = new Dictionary<string, Rectangle>();
 | |
| 		private static Dictionary<string, int> dicPDFPageSizePnts = new Dictionary<string, int>();
 | |
| 		private static void BuildPDFPageSizeDic()
 | |
| 		{
 | |
| 			// the page size is set in the format files using a string description i.e.: <PDFPageSize PaperSize="LETTER" />
 | |
| 			if (dicPDFPageSize.Count > 0) return;
 | |
| 			dicPDFPageSize.Add("LETTER", PageSize.LETTER);
 | |
| 			dicPDFPageSize.Add("A4", PageSize.A4);
 | |
| 		}
 | |
| 		private static void BuildPDFPageSizeDicPnts()
 | |
| 		{
 | |
| 			if (dicPDFPageSizePnts.Count > 0) return;
 | |
| 			dicPDFPageSizePnts.Add("LETTER", 792);
 | |
| 			dicPDFPageSizePnts.Add("A4", 842);
 | |
| 			/* Paper Size in Points
 | |
| 			 -------------------------
 | |
| 				Letter		 612x792
 | |
| 				LetterSmall	 612x792
 | |
| 				Tabloid		 792x1224
 | |
| 				Ledger		 1224x792
 | |
| 				Legal		 612x1008
 | |
| 				Statement	 396x612
 | |
| 				Executive	 540x720
 | |
| 				A0           2384x3371
 | |
| 				A1           1685x2384
 | |
| 				A2		     1190x1684
 | |
| 				A3		     842x1190
 | |
| 				A4		     595x842
 | |
| 				A4Small		 595x842
 | |
| 				A5		     420x595
 | |
| 				B4		     729x1032
 | |
| 				B5		     516x729
 | |
| 				Envelope	 ???x???
 | |
| 				Folio		 612x936
 | |
| 				Quarto		 610x780
 | |
| 				10x14		 720x1008	
 | |
| 			 */
 | |
| 		}
 | |
| 		public static Rectangle UsePaperSize(string pgSize)
 | |
| 		{
 | |
| 			Rectangle recPageSize = PageSize.LETTER;
 | |
| 			BuildPDFPageSizeDic();
 | |
| 			if (pgSize != null && dicPDFPageSize.ContainsKey(pgSize.ToUpper()))
 | |
| 				recPageSize = dicPDFPageSize[pgSize.ToUpper()];
 | |
| 			return recPageSize;
 | |
| 		}
 | |
| 		public static int PaperSizePoints(string pgSize)
 | |
| 		{
 | |
| 			int paperPoints = 792; //LETTER paper size
 | |
| 			BuildPDFPageSizeDicPnts();
 | |
| 			if (pgSize != null && dicPDFPageSizePnts.ContainsKey(pgSize.ToUpper()))
 | |
| 				paperPoints = dicPDFPageSizePnts[pgSize.ToUpper()];
 | |
| 			return paperPoints;
 | |
| 		}
 | |
| 	}
 | |
| }
 |