Esempio n. 1
0
        internal override void Write(PdfStreamWriter writer)
        {
            writer.SetState(State);
            writer.WriteLine("BT");
            writer.WriteLine($"    /F{Font.FontId} {FontSize.AsPoints().AsFixed()} Tf");
            writer.WriteLine($"    {Location} Td");
            if (CharacterWidth.RawValue != 0.0)
            {
                writer.WriteLine($"    {CharacterWidth.AsPoints().AsFixed()} Tc");
            }

            writer.Write("    [(");
            foreach (var c in Value)
            {
                switch (c)
                {
                case '(':
                case ')':
                case '\\':
                    writer.Write((byte)'\\');
                    break;
                }

                writer.Write((byte)c);
            }

            writer.WriteLine(")] TJ");
            writer.WriteLine("ET");
        }
Esempio n. 2
0
 internal override void Write(PdfStreamWriter writer)
 {
     foreach (var command in Commands)
     {
         command.Write(writer);
     }
 }
Esempio n. 3
0
        internal override void Write(PdfStreamWriter writer)
        {
            writer.SetState(State);
            writer.WriteLine("q"); // save graphics state
            foreach (var transform in Transforms)
            {
                writer.WriteLine($"  {transform}");
            }

            writer.WriteLine($"  /{Image.ReferenceId} Do"); // paint
            writer.WriteLine("Q");                          // restore graphics state
        }
Esempio n. 4
0
        protected override byte[] GetContent()
        {
            var bytes  = new List <byte>();
            var writer = new PdfStreamWriter();

            foreach (var item in Items)
            {
                item.Write(writer);
            }

            writer.Stroke();

            var data = writer.GetBytes();

            foreach (var encoder in Encoders)
            {
                data = encoder.Encode(data);
            }

            var sb = new StringBuilder();

            sb.Append($"<</Length {data.Length}");
            if (Encoders.Count > 0)
            {
                sb.Append("\r\n");
                sb.Append($"  /Filter {Encoders.AsEncoderList()}\r\n");
            }

            sb.Append(">>\r\n");
            sb.Append("stream\r\n");
            bytes.AddRange(sb.ToString().GetBytes());

            bytes.AddRange(data);
            bytes.AddRange("endstream\r\n".GetBytes());

            return(bytes.ToArray());
        }