示例#1
0
        public static PDFArray PDFColorToPDFArray(DeviceColor value)
        {
            PDFArray color = new PDFArray();

            switch (value.Colorspace.N)
            {
            case 1:
                color.AddItem(new PDFNumber((value as ColorGray).G * 1.0f / 255));
                break;

            case 3:
                color.AddItem(new PDFNumber((value as ColorRGB).R * 1.0f / 255));
                color.AddItem(new PDFNumber((value as ColorRGB).G * 1.0f / 255));
                color.AddItem(new PDFNumber((value as ColorRGB).B * 1.0f / 255));
                break;

            case 4:
                color.AddItem(new PDFNumber((value as ColorCMYK).C * 1.0f / 255));
                color.AddItem(new PDFNumber((value as ColorCMYK).M * 1.0f / 255));
                color.AddItem(new PDFNumber((value as ColorCMYK).Y * 1.0f / 255));
                color.AddItem(new PDFNumber((value as ColorCMYK).K * 1.0f / 255));
                break;
            }
            return(color);
        }
示例#2
0
 public ArgumentDevice(DeviceColor deviceColor) :
     base()
 {
     this.deviceColor       = (int)deviceColor;
     this.SN                = "";
     this.labelFilePathName = "";
 }
 private void SetColor(
     PdfName key,
     DeviceColor value
     )
 {
     BaseDataObject[key] = PdfObjectWrapper.GetBaseObject(value);
 }
示例#4
0
        private void parseFontColor(List <IPDFPageOperation> operations)
        {
            for (int i = operations.Count - 1; i >= 0; --i)
            {
                if (operations[i] is RGBColorSpaceForNonStroking || operations[i] is GrayColorSpaceForNonStroking ||
                    operations[i] is CMYKColorSpaceForNonStroking)
                {
                    if (operations[i] is RGBColorSpaceForNonStroking)
                    {
                        RGBColorSpaceForNonStroking rgb = (RGBColorSpaceForNonStroking)operations[i];
                        _fontColor = new ColorRGB((byte)(rgb.R * 255), (byte)(rgb.G * 255), (byte)(rgb.B * 255));
                    }
                    else if (operations[i] is GrayColorSpaceForNonStroking)
                    {
                        GrayColorSpaceForNonStroking gray = (GrayColorSpaceForNonStroking)operations[i];
                        _fontColor = new ColorGray((byte)(gray.Gray * 255));
                    }
                    else                     // CMYKColorSpaceForNonStroking
                    {
                        CMYKColorSpaceForNonStroking cmyk = (CMYKColorSpaceForNonStroking)operations[i];
                        _fontColor = new ColorCMYK((byte)(cmyk.C * 255), (byte)(cmyk.M * 255), (byte)(cmyk.Y * 255), (byte)(cmyk.K * 255));
                    }

                    return;
                }
            }

            _fontColor = new ColorRGB(0, 0, 0);
        }
示例#5
0
 internal ChoiceField(float left, float top, float width, float height, string name, IDocumentEssential owner)
     : base(left, top, width, height, name, owner)
 {
     Dictionary.AddItem("FT", new PDFName("Ch"));
     _font = new Font(StandardFonts.Helvetica, 12);
     _font.ChangedFontSize += changedFontSize;
     _fontColor             = new ColorRGB(0, 0, 0);
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the Bytescout.PDF.FreeTextAnnotation class.
 /// </summary>
 /// <param name="left" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The x-coordinate of the upper-left corner of the annotation.</param>
 /// <param name="top" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The y-coordinate of the upper-left corner of the annotation.</param>
 /// <param name="width" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The width of the annotation.</param>
 /// <param name="height" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The height of the annotation.</param>
 public FreeTextAnnotation(float left, float top, float width, float height)
     : base(left, top, width, height, null)
 {
     Dictionary.AddItem("Subtype", new PDFName("FreeText"));
     _font = new Font(StandardFonts.Helvetica, 12);
     _font.ChangedFontSize += changedFontSize;
     _fontColor             = new ColorRGB(0, 0, 0);
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the Bytescout.PDF.ColorICC class.
 /// </summary>
 /// <param name="icc">The ICC color profile for color space.</param>
 /// <param name="color">The Bytescout.PDF.DeviceColor to create Bytescout.PDF.ColorICC from.</param>
 public ColorICC(ICCBasedColorspace icc, DeviceColor color)
 {
     if (icc.N != color.Colorspace.N)
     {
         throw new PDFNotEqualColorspacesException();
     }
     _colorspace = icc;
     _color      = color;
 }
示例#8
0
 internal PushButton(PDFDictionary dict, IDocumentEssential owner, bool createFont)
     : base(dict, owner)
 {
     if (createFont)
     {
         _font = new Font(StandardFonts.Helvetica, 12);
         _font.ChangedFontSize += changedFontSize;
         _fontColor             = new ColorRGB(0, 0, 0);
     }
 }
示例#9
0
 public Scribble(
     Page page,
     IList <IList <PointF> > paths,
     string text,
     DeviceColor color
     ) : base(page, PdfName.Ink, new RectangleF(), text)
 {
     Paths = paths;
     Color = color;
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the Bytescout.PDF.EditBox class.
 /// </summary>
 /// <param name="left" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The x-coordinate of the upper-left corner of the edit box.</param>
 /// <param name="top" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The y-coordinate of the upper-left corner of the edit box.</param>
 /// <param name="width" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The width of the edit box.</param>
 /// <param name="height" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The height of the edit box.</param>
 /// <param name="name" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">The unique name of the edit box control.</param>
 public EditBox(float left, float top, float width, float height, string name)
     : base(left, top, width, height, name, null)
 {
     Dictionary.AddItem("FT", new PDFName("Tx"));
     _font = new Font(StandardFonts.Helvetica, 12);
     _font.ChangedFontSize += changedFontSize;
     _fontColor             = new ColorRGB(0, 0, 0);
     BorderColor            = new ColorRGB(0, 0, 0);
     CreateApperance();
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the Bytescout.PDF.PushButton class.
 /// </summary>
 /// <param name="left" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The x-coordinate of the upper-left corner of the button.</param>
 /// <param name="top" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The y-coordinate of the upper-left corner of the button.</param>
 /// <param name="width" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The width of the button.</param>
 /// <param name="height" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The height of the button.</param>
 /// <param name="name" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">The unique name of the button control.</param>
 public PushButton(float left, float top, float width, float height, string name)
     : base(left, top, width, height, name, null)
 {
     Pushbutton = true;
     Apperance.BackgroundColor = new ColorGray(153);
     Apperance.BorderColor     = new ColorRGB(0, 0, 0);
     _font = new Font(StandardFonts.Helvetica, 12);
     _font.ChangedFontSize += changedFontSize;
     _fontColor             = new ColorRGB(0, 0, 0);
     CreateApperance();
 }
示例#12
0
        internal void SetTextProperties(Font font, DeviceColor color)
        {
            if (_font != null)
            {
                _font.ChangedFontSize -= changedFontSize;
            }

            _font      = font;
            _fontColor = color;
            setTextAttributes();
            _font.ChangedFontSize += changedFontSize;
        }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the Bytescout.PDF.Signature class.
        /// </summary>
        /// <param name="left" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The x-coordinate of the upper-left corner of the signature box.</param>
        /// <param name="top" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The y-coordinate of the upper-left corner of the signature box.</param>
        /// <param name="width" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The width of the signature box.</param>
        /// <param name="height" href="http://msdn.microsoft.com/en-us/library/system.single.aspx">The height of the signature box.</param>
        /// <param name="name" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">The unique name of the signature.</param>
        public Signature(float left, float top, float width, float height, string name, PDFDictionary sig)
            : base(left, top, width, height, name, null)
        {
            Dictionary.AddItem("FT", new PDFName("Sig"));
            Flag = 132; // ???

            _visible = true;
            _font    = new Font(StandardFonts.Helvetica, 12);
            //_font.ChangedFontSize += changedFontSize;
            _fontColor  = new ColorRGB(0, 0, 0);
            BorderColor = new ColorRGB(0, 0, 0);
            CreateApperance();
            Dictionary.AddItem("V", sig);
        }
 private void SetColor(
     PdfName key,
     DeviceColor value
     )
 {
     if (value == null)
     {
         BaseDataObject.Remove(key);
     }
     else
     {
         BaseDataObject[key] = value.BaseObject;
     }
 }
示例#15
0
        public UncoloredTilingPatternColorspace(float width, float height)
        {
            _stream     = new MemoryStream();
            _resources  = new Resources();
            _canvas     = new Canvas(_stream, _resources, width, height);
            _streamDict = new PDFDictionaryStream(new PDFDictionary(), _stream);
            _paintType  = PDFTilingPaintType.UncoloredTilingPattern;
            _tilingType = PDF.TilingType.ConstantSpacing;
            _height     = height;
            _width      = width;
            _matrix     = new float[6];
            _matrix[0]  = 1;
            _matrix[1]  = 0;
            _matrix[2]  = 0;
            _matrix[3]  = 1;
            _matrix[4]  = 0;
            _matrix[5]  = 0;
            _xstep      = width;
            _ystep      = height;
            _color      = new ColorRGB(0, 0, 0);

            PDFDictionary dict = _streamDict.Dictionary;

            dict.AddItem("Type", new PDFName(Name));
            dict.AddItem("PatternType", new PDFNumber((float)PDFPatternType.TilingPattern));
            dict.AddItem("PaintType", new PDFNumber((float)_paintType));
            dict.AddItem("TilingType", new PDFNumber((float)_tilingType));
            PDFArray rect = new PDFArray();

            rect.AddItem(new PDFNumber(0));
            rect.AddItem(new PDFNumber(0));
            rect.AddItem(new PDFNumber(_width));
            rect.AddItem(new PDFNumber(_height));
            dict.AddItem("BBox", rect);
            dict.AddItem("XStep", new PDFNumber(_xstep));
            dict.AddItem("YStep", new PDFNumber(_ystep));
            dict.AddItem("Resources", _resources.Dictionary);
            PDFArray array = new PDFArray();

            for (int i = 0; i < 6; ++i)
            {
                array.AddItem(new PDFNumber((_matrix[i])));
            }
            dict.AddItem("Matrix", array);
            _name = "";
        }
示例#16
0
        private void parseFontAndColor()
        {
            if (Owner != null)
            {
                byte[]    data = null;
                PDFString da   = Dictionary["DA"] as PDFString;
                if (da != null)
                {
                    data = da.GetBytes();
                }
                else
                {
                    PDFString ada = Owner.GetAcroFormDefaultAttribute();
                    if (ada != null)
                    {
                        data = ada.GetBytes();
                    }
                }

                if (data == null)
                {
                    _fontColor             = new ColorRGB(0, 0, 0);
                    _font                  = new Font(StandardFonts.Helvetica, 12);
                    _font.ChangedFontSize += changedFontSize;
                    return;
                }

                PageOperationParser      parser     = new PageOperationParser(new MemoryStream(data));
                List <IPDFPageOperation> operations = new List <IPDFPageOperation>();
                IPDFPageOperation        operation;
                while ((operation = parser.Next()) != null)
                {
                    operations.Add(operation);
                }

                parseFont(operations);
                parseFontColor(operations);
            }
        }
示例#17
0
        public Signature(float left, float top, float width, float height, string name, PDFDictionary sig, string reason, string contact, string location)
            : base(left, top, width, height, name, null)
        {
            Dictionary.AddItem("FT", new PDFName("Sig"));
            Flag = 132; // ???

            PDFString sname = (PDFString )sig["Name"];

            if (sname != null)
            {
                _name = sname.ToString();
            }
            _reason   = reason;
            _contact  = contact;
            _location = location;
            _visible  = true;
            _font     = new Font(StandardFonts.Helvetica, 12);
            //_font.ChangedFontSize += changedFontSize;
            _fontColor  = new ColorRGB(0, 0, 0);
            BorderColor = new ColorRGB(0, 0, 0);
            CreateApperance();
            Dictionary.AddItem("V", sig);
        }
 private DeviceColor GetColor(
     PdfName key
     )
 {
     return(DeviceColor.Get((PdfArray)BaseDataObject.Resolve(key)));
 }
示例#19
0
 public Scribble(Page page, IList <SKPath> paths, string text, DeviceColor color)
     : base(page, PdfName.Ink, new SKRect(), text)
 {
     Paths = paths;
     Color = color;
 }
示例#20
0
 /// <summary> </summary>
 public ColorICC CreateColorICC(ICCBasedColorspace icc, DeviceColor color)
 {
     return(new ColorICC(icc, color));
 }