public static RotationAngle PDFNumberToRotationAngle(PDFNumber num) { if (num == null) { return(RotationAngle.Rotate0); } int angle = (int)num.GetValue(); angle = angle % 360; if (angle == 90 || angle == -270) { return(RotationAngle.Rotate90); } else if (angle == 180 || angle == -180) { return(RotationAngle.Rotate180); } else if (angle == 270 || angle == -90) { return(RotationAngle.Rotate270); } return(RotationAngle.Rotate0); }
private static int getColumns(PDFDictionary dict) { if (dict == null) { return(1); } PDFNumber columns = dict["Columns"] as PDFNumber; if (columns == null) { return(1); } return((int)columns.GetValue()); }
private static int getBitsPerComponent(PDFDictionary dict) { if (dict == null) { return(8); } PDFNumber bitsPerComponent = dict["BitsPerComponent"] as PDFNumber; if (bitsPerComponent == null) { return(8); } return((int)bitsPerComponent.GetValue()); }
private static int getPredictor(PDFDictionary dict) { if (dict == null) { return(1); } PDFNumber predictor = dict["Predictor"] as PDFNumber; if (predictor == null) { return(1); } return((int)predictor.GetValue()); }
private static int getK(PDFDictionary dict) { if (dict == null) { return(0); } PDFNumber k = dict["K"] as PDFNumber; if (k == null) { return(0); } return((int)k.GetValue()); }
private static int getDamagedRowsBeforeError(PDFDictionary dict) { if (dict == null) { return(0); } PDFNumber damagedRowsBeforeError = dict["DamagedRowsBeforeError"] as PDFNumber; if (damagedRowsBeforeError == null) { return(0); } return((int)damagedRowsBeforeError.GetValue()); }
private static int getRows(PDFDictionary dict) { if (dict == null) { return(0); } PDFNumber rows = dict["Rows"] as PDFNumber; if (rows == null) { return(0); } return((int)rows.GetValue()); }
public static TextAlign PDFNumberToPDFTextAlign(PDFNumber num) { if (num == null) { return(TextAlign.Left); } switch ((int)num.GetValue()) { case 1: return(TextAlign.Center); case 2: return(TextAlign.Right); } return(TextAlign.Left); }
private static int getColorTransform(PDFDictionary dict) { if (dict == null) { return(1); } PDFNumber colorTransform = dict["ColorTransform"] as PDFNumber; if (colorTransform == null) { return(1); } if (colorTransform.GetValue() == 0) { return(0); } return(1); }
private static int getEarlyChange(PDFDictionary dict) { if (dict == null) { return(1); } PDFNumber earlyChange = dict["EarlyChange"] as PDFNumber; if (earlyChange == null) { return(1); } if (earlyChange.GetValue() == 0) { return(0); } return(1); }
private PDFDictionary findRadioButtonGroup(string name) { PDFArray fields = _dictionary["Fields"] as PDFArray; for (int i = 0; i < fields.Count; ++i) { PDFDictionary dict = fields[i] as PDFDictionary; if (dict != null) { PDFName ft = dict["FT"] as PDFName; PDFNumber ff = dict["Ff"] as PDFNumber; PDFString t = dict["T"] as PDFString; if (ft != null && ff != null && t != null) { if (ft.GetValue() == "Btn" && t.GetValue() == name && ((uint)ff.GetValue() >> 15) % 2 != 0) { return(dict); } } } } return(null); }
public static DeviceColor PDFArrayToPDFColor(PDFArray color) { if (color == null || color.Count == 0) { return(new ColorRGB(0, 0, 0)); } switch (color.Count) { case 1: PDFNumber q = color[0] as PDFNumber; if (q == null || q.GetValue() > 1) { return(new ColorGray(0)); } return(new ColorGray((byte)(q.GetValue() * 255))); case 3: PDFNumber red = color[0] as PDFNumber; PDFNumber green = color[1] as PDFNumber; PDFNumber blue = color[2] as PDFNumber; byte r = 0, g = 0, b = 0; if (red != null) { r = (byte)(red.GetValue() * 255); } if (green != null) { g = (byte)(green.GetValue() * 255); } if (blue != null) { b = (byte)(blue.GetValue() * 255); } return(new ColorRGB(r, g, b)); default: PDFNumber cyan = color[0] as PDFNumber; PDFNumber magenta = color[1] as PDFNumber; PDFNumber yellow = color[2] as PDFNumber; PDFNumber black = color[3] as PDFNumber; byte c = 0, m = 0, y = 0, k = 0; if (cyan != null) { c = (byte)(cyan.GetValue() * 255); } if (magenta != null) { m = (byte)(magenta.GetValue() * 255); } if (yellow != null) { y = (byte)(yellow.GetValue() * 255); } if (black != null) { k = (byte)(black.GetValue() * 255); } return(new ColorCMYK(c, m, y, k)); } }