예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            string outputFilename = "bin\\output.pdf";

            using (FileStream outputStream = new FileStream(outputFilename, FileMode.Create, FileAccess.Write))
            {
                //----------------
                PdfCreator pdfCreator = new PdfCreator(outputStream);

                PdfResources     pdfRes        = pdfCreator.GetResources();
                PdfContentStream contentStream = pdfCreator.MakeContentStream();
                //----------------
                Fonet.Layout.FontInfo fontInfo = new Fonet.Layout.FontInfo();
                var fontSetup = new Fonet.Render.Pdf.FontSetup(
                    fontInfo, Fonet.Render.Pdf.FontType.Link);

                Fonet.Layout.FontState fontState = new Fonet.Layout.FontState(
                    fontInfo, "sans-serif", "normal",
                    "normal", 18000,
                    52);
                //----------------
                pdfCreator.OutputHeader();
                //----------------

                //simple page
                contentStream.BeginTextObject();
                contentStream.SetFont("F1", 18 * 1000);
                contentStream.SetFontColor(new Fonet.PdfColor(0, 0, 0));
                //----------------
                Fonet.Layout.TextPrinter textPrinter = new Fonet.Layout.TextPrinter();
                textPrinter.Reset(fontState, false);
                textPrinter.SetTextPos(100 * 1000, 100 * 1000);
                textPrinter.WriteText("Hello World!");
                textPrinter.PrintContentTo(contentStream);
                contentStream.CloseText();
                //----------------

                contentStream.DrawLine(0 * 1000, 0 * 1000, 70 * 1000, 50 * 1000,
                                       1 * 1000,
                                       new Fonet.PdfColor(255, 0, 0));


                contentStream.EndTextObject();
                //----------------
                int     w    = 800;
                int     h    = 600;
                PdfPage page = pdfCreator.MakePage(pdfRes, contentStream,
                                                   w,
                                                   h,
                                                   new string[0]);


                fontSetup.AddToResources(new PdfFontCreator(pdfCreator), pdfRes);
                pdfCreator.OutputTrailer();
                //----------------
                outputStream.Flush();
                outputStream.Close();
            }
        }
예제 #2
0
        /**
         * add a line to the current stream
         *
         * @param x1 the start x location in millipoints
         * @param y1 the start y location in millipoints
         * @param x2 the end x location in millipoints
         * @param y2 the end y location in millipoints
         * @param th the thickness in millipoints
         * @param r the red component
         * @param g the green component
         * @param b the blue component
         */

        private void AddLine(int x1, int y1, int x2, int y2, int th,
                             PdfColor stroke)
        {
            CloseText();
            currentStream.DrawLine(x1, y1, x2, y2, th, stroke);
        }