Beispiel #1
0
        /// <summary>
        /// Writes an hyperlink area
        /// </summary>
        /// <param name="link">Hyperlink</param>
        /// <param name="x1">Rectangle left</param>
        /// <param name="y1">Rectangle top</param>
        /// <param name="x2">Rectangle right</param>
        /// <param name="y2">Rectangle bottom</param>
        public void WriteLink(string link, int x1, int y1, int x2, int y2)
        {
            int idLink = _xRefs.CreateAndRegisterObject();

            _pdfWriter.WriteLine(idLink + " 0 obj");
            _pdfWriter.WriteLine("<<");
            _pdfWriter.WriteLine("/Type /Annot");
            _pdfWriter.WriteLine("/Subtype /Link");
            _pdfWriter.WriteLine("/Rect [" + x1 + " " + y1 + " " + x2 + " " + y2 + "]");
            _pdfWriter.WriteLine("/Border [0 0 0]");
            _pdfWriter.WriteLine("/A <<");
            _pdfWriter.WriteLine(" /Type /Action");
            _pdfWriter.WriteLine(" /S /URI");
            _pdfWriter.WriteLine(" /URI (" + link + ")");
            _pdfWriter.WriteLine(">>");
            _pdfWriter.WriteLine(">>");
            _pdfWriter.WriteLine("endobj");

            _currentPage.AddAnnot(idLink);
        }
Beispiel #2
0
        public static void Write(StreamWriter writer, PdfXRefs xrefs)
        {
            PdfFont[] fonts = new[] {
                PdfFonts.FONT_REGULAR,
                PdfFonts.FONT_BOLD,
                PdfFonts.FONT_OBLIQUE,
                PdfFonts.FONT_BOLD_OBLIQUE
            };
            int[] fontIds = new int[fonts.Length];

            for (int i = 0; i < fonts.Length; i++)
            {
                fontIds[i] = xrefs.CreateAndRegisterObject();

                writer.WriteLine(fontIds[i] + " 0 obj");
                writer.WriteLine("<<");
                writer.WriteLine("/Type /Font");
                writer.WriteLine("/Subtype /Type1");
                writer.WriteLine("/BaseFont /" + fonts[i].Name);
                writer.WriteLine("/Encoding /WinAnsiEncoding");

                /*
                 * _pdfWriter.Write("/FirstChar 0");
                 * _pdfWriter.Write("/LastChar 255");
                 * _pdfWriter.Write("/Widths[");
                 * foreach (short w in font.WidthsTs) {
                 *  _pdfWriter.Write(w);
                 *  _pdfWriter.Write(' ');
                 * }
                 * _pdfWriter.Write(']');
                 */
                writer.WriteLine(">>");
                writer.WriteLine("endobj");
            }

            xrefs.RegisterObject(PdfXRefs.ID_FONTS);
            writer.WriteLine(PdfXRefs.ID_FONTS + " 0 obj");
            writer.Write("<< ");
            for (int i = 0; i < fonts.Length; i++)
            {
                writer.Write(fonts[i].CodeName + " " + fontIds[i] + " 0 R ");
            }
            writer.WriteLine(">>");
            writer.WriteLine("endobj");
        }
Beispiel #3
0
        public static void Write(StreamWriter writer, PdfXRefs xrefs) {
            PdfFont[] fonts = new[]{
                PdfFonts.FONT_REGULAR, 
                PdfFonts.FONT_BOLD,
                PdfFonts.FONT_OBLIQUE, 
                PdfFonts.FONT_BOLD_OBLIQUE
            };
            int[] fontIds = new int[fonts.Length];

            for (int i = 0; i < fonts.Length; i++) {
                fontIds[i] = xrefs.CreateAndRegisterObject();

                writer.WriteLine(fontIds[i] + " 0 obj");
                writer.WriteLine("<<");
                writer.WriteLine("/Type /Font");
                writer.WriteLine("/Subtype /Type1");
                writer.WriteLine("/BaseFont /" + fonts[i].Name);
                writer.WriteLine("/Encoding /WinAnsiEncoding");
                /*
                _pdfWriter.Write("/FirstChar 0");
                _pdfWriter.Write("/LastChar 255");
                _pdfWriter.Write("/Widths[");
                foreach (short w in font.WidthsTs) {
                    _pdfWriter.Write(w);
                    _pdfWriter.Write(' ');
                }
                _pdfWriter.Write(']');
                */
                writer.WriteLine(">>");
                writer.WriteLine("endobj");
            }

            xrefs.RegisterObject(PdfXRefs.ID_FONTS);
            writer.WriteLine(PdfXRefs.ID_FONTS + " 0 obj");
            writer.Write("<< ");
            for (int i = 0; i < fonts.Length; i++) {
                writer.Write(fonts[i].CodeName + " " + fontIds[i] + " 0 R ");
            }
            writer.WriteLine(">>");
            writer.WriteLine("endobj");
        }