Exemple #1
0
 static PdfLink()
 {
     DefaultColor = new PdfArray();
     DefaultColor.Add(new PdfNumeric(0));
     DefaultColor.Add(new PdfNumeric(0));
     DefaultColor.Add(new PdfNumeric(0));
     DefaultBorder = new PdfArray();
     DefaultBorder.Add(new PdfNumeric(0));
     DefaultBorder.Add(new PdfNumeric(0));
     DefaultBorder.Add(new PdfNumeric(0));
 }
Exemple #2
0
 public PdfLink(PdfObjectId objectId, Rectangle r)
     : base(objectId)
 {
     this[PdfName.Names.Type] = PdfName.Names.Annot;
     this[PdfName.Names.Subtype] = PdfName.Names.Link;
     PdfArray rect = new PdfArray();
     rect.Add(new PdfNumeric(r.X / 1000m));
     rect.Add(new PdfNumeric(r.Y / 1000m));
     rect.Add(new PdfNumeric((r.X + r.Width) / 1000m));
     rect.Add(new PdfNumeric((r.Y - r.Height) / 1000m));
     this[PdfName.Names.Rect] = rect;
     this[PdfName.Names.H] = PdfName.Names.I;
     this[PdfName.Names.C] = DefaultColor;
     this[PdfName.Names.Border] = DefaultBorder;
 }
Exemple #3
0
        public PdfXObject AddImage(FonetImage img)
        {
            // check if already created
            string url = img.Uri;
            PdfXObject xObject = (PdfXObject)this.xObjectsMap[url];
            if (xObject == null)
            {
                PdfICCStream iccStream = null;

                ColorSpace cs = img.ColorSpace;
                if (cs.HasICCProfile())
                {
                    iccStream = new PdfICCStream(doc.NextObjectId(), cs.GetICCProfile());
                    iccStream.NumComponents = new PdfNumeric(cs.GetNumComponents());
                    iccStream.AddFilter(new FlateFilter());
                    this.objects.Add(iccStream);
                }

                // else, create a new one
                PdfName name = new PdfName("XO" + xObjectsMap.Count);
                xObject = new PdfXObject(img.Bitmaps, name, doc.NextObjectId());
                xObject.SubType = PdfName.Names.Image;
                xObject.Dictionary[PdfName.Names.Width] = new PdfNumeric(img.Width);
                xObject.Dictionary[PdfName.Names.Height] = new PdfNumeric(img.Height);
                xObject.Dictionary[PdfName.Names.BitsPerComponent] = new PdfNumeric(img.BitsPerPixel);

                // Check for ICC color space
                if (iccStream != null)
                {
                    PdfArray ar = new PdfArray();
                    ar.Add(PdfName.Names.ICCBased);
                    ar.Add(iccStream.GetReference());

                    xObject.Dictionary[PdfName.Names.ColorSpace] = ar;
                }
                else
                {
                    xObject.Dictionary[PdfName.Names.ColorSpace] = new PdfName(img.ColorSpace.GetColorSpacePDFString());
                }

                xObject.AddFilter(img.Filter);

                this.objects.Add(xObject);
                this.xObjectsMap.Add(url, xObject);
            }
            return xObject;
        }
Exemple #4
0
        private PdfFontDescriptor MakeFontDescriptor(string fontName, IFontMetric metrics)
        {
            IFontDescriptor descriptor = metrics.Descriptor;

            PdfFontDescriptor pdfDescriptor = new PdfFontDescriptor(
                fontName, NextObjectId());
            pdfDescriptor.Ascent = new PdfNumeric(metrics.Ascender);
            pdfDescriptor.CapHeight = new PdfNumeric(metrics.CapHeight);
            pdfDescriptor.Descent = new PdfNumeric(metrics.Descender);
            pdfDescriptor.Flags = new PdfNumeric(descriptor.Flags);
            pdfDescriptor.ItalicAngle = new PdfNumeric(descriptor.ItalicAngle);
            pdfDescriptor.StemV = new PdfNumeric(descriptor.StemV);

            PdfArray array = new PdfArray();
            array.AddArray(descriptor.FontBBox);
            pdfDescriptor.FontBBox = array;

            return pdfDescriptor;
        }