Example #1
0
 private static void AddPdfDocument(string[] attributes)
 {
     Dictionary<string, string> attr = getDictAttr(attributes);
     string documentName = returnNameCmdValue(attr);
     if (documentName != null)
     {
         PDF newDoc = new PDF(documentName);
         documents.Add(newDoc);
         Console.WriteLine("Document added: " + documentName);
         foreach (var key in attr.Keys)
         {
             switch (key)
             {
                 case "pages":
                     newDoc.NumberOfPages = attr[key];
                     break;
                 case "size":
                     newDoc.SizeInBytes = attr[key];
                     break;
                 case "content":
                     newDoc.Content = attr[key];
                     break;
             }
         }
     }
 }
    public Example_19()
    {
        try {

            FileStream fos = new FileStream("Example_19.pdf", FileMode.Create);
            BufferedStream bos = new BufferedStream(fos);

            PDF pdf = new PDF( bos );

            FileStream fis = new FileStream( "Example_03.pdf", FileMode.Open );

            // FileInputStream fis = new FileInputStream( "PDF32000_2008.pdf" );

            BufferedStream bis = new BufferedStream( fis );
            List< PDFobj > objects = pdf.read(bis);
            for ( int j = 0; j < objects.Count; j++ ) {
                PDFobj obj = ( PDFobj ) objects[j];
                for ( int i = 0; i < obj.dict.Count; i++ ) {
                    Console.WriteLine(obj.dict[i]);
                }
                Console.WriteLine();
            }
            bis.Close();

            pdf.Flush();
            bos.Close();
        }
        catch ( Exception e ) {
            Console.WriteLine(e.StackTrace);
        }
    }
 public IHttpActionResult Post([FromBody] string html)
 {
     TuesPich tue = new TuesPich();
     byte[] pdfArray=tue.convertHTMLTOPDF(html);
     PDF pdf = new PDF();
     pdf.pdfArray = pdfArray;
     pdf.tempString = Convert.ToBase64String(pdfArray);
     return Ok(pdf);
 }
    public Example_04()
    {
        String fileName = "data/happy-new-year.txt";

        FileStream fos = new FileStream("Example_04.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Font f1 = new Font(
                pdf,
                "AdobeMingStd-Light",       // Chinese (Traditional) font
                CodePage.UNICODE);
        Font f2 = new Font(
                pdf,
                "AdobeSongStd-Light",       // Chinese (Simplified) font
                CodePage.UNICODE);
        Font f3 = new Font(
                pdf,
                "KozMinProVI-Regular",      // Japanese font
                CodePage.UNICODE);
        Font f4 = new Font(
                pdf,
                "AdobeMyungjoStd-Medium",   // Korean font
                CodePage.UNICODE);

        Page page = new Page(pdf, Letter.PORTRAIT);

        f1.SetSize(14);
        f2.SetSize(14);
        f3.SetSize(14);
        f4.SetSize(14);

        double x_pos = 100.0;
        double y_pos = 20.0;
        StreamReader reader = new StreamReader(
                new FileStream(fileName, FileMode.Open));
        TextLine text = new TextLine(f1);
        String line = null;
        while ((line = reader.ReadLine()) != null) {
            if (line.IndexOf("Simplified") != -1) {
                text.SetFont(f2);
            } else if (line.IndexOf("Japanese") != -1) {
                text.SetFont(f3);
            } else if (line.IndexOf("Korean") != -1) {
                text.SetFont(f4);
            }
            text.SetText(line);
            text.SetPosition(x_pos, y_pos += 24);
            text.DrawOn(page);
        }
        reader.Close();

        pdf.Flush();
        bos.Close();
    }
    public Example_01()
    {
        FileStream fos = new FileStream("Example_01.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Page page = new Page(pdf, Letter.PORTRAIT);

        Box flag = new Box();
        flag.SetPosition(100.0, 100.0);
        flag.SetSize(190.0, 100.0);
        flag.SetColor(RGB.WHITE);
        flag.DrawOn(page);

        double sw = 7.69;   // stripe width
        Line stripe = new Line(0.0, sw/2, 190.0, sw/2);
        stripe.SetWidth(sw);
        stripe.SetColor(RGB.OLD_GLORY_RED);
        for (int row = 0; row < 7; row++) {
            stripe.PlaceIn(flag, 0.0, row * 2 * sw);
            stripe.DrawOn(page);
        }

        Box union = new Box();
        union.SetSize(76.0, 53.85);
        union.SetColor(RGB.OLD_GLORY_BLUE);
        union.SetFillShape(true);
        union.PlaceIn(flag, 0.0, 0.0);
        union.DrawOn(page);

        double h_si = 12.6; // horizontal star interval
        double v_si = 10.8; // vertical star interval
        Point star = new Point(h_si/2, v_si/2);
        star.SetShape(Point.STAR);
        star.SetRadius(3.0);
        star.SetColor(RGB.WHITE);
        star.SetFillShape(true);

        for (int row = 0; row < 6; row++) {
            for (int col = 0; col < 5; col++) {
                star.PlaceIn(union, row * h_si, col * v_si);
                star.DrawOn(page);
            }
        }
        star.SetPosition(h_si, v_si);
        for (int row = 0; row < 5; row++) {
            for (int col = 0; col < 4; col++) {
                star.PlaceIn(union, row * h_si, col * v_si);
                star.DrawOn(page);
            }
        }

        pdf.Flush();
        bos.Close();
    }
    public Example_08()
    {
        FileStream fos = new FileStream("Example_08.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        // Before you enable this flag please read README.ZLIB.TXT
        // in the 'optional' directory.

        Font f1 = new Font(pdf, "Helvetica-Bold");
        f1.SetSize(7.0);
        Font f2 = new Font(pdf, "Helvetica");
        f2.SetSize(7.0);
        Font f3 = new Font(pdf, "Helvetica-BoldOblique");
        f3.SetSize(7.0);

        Page page = new Page(pdf, Letter.PORTRAIT);

        Table table = new Table(f1, f2);
        List<List<Cell>> tableData = GetData(
                "data/world-communications.txt", "|", Table.DATA_HAS_2_HEADER_ROWS, f1, f2);
        table.SetData(tableData, Table.DATA_HAS_2_HEADER_ROWS);

        table.SetLineWidth(0.2);
        table.SetPosition(70.0, 30.0);
        table.SetTextColorInRow(6, RGB.BLUE);
        table.SetTextColorInRow(39, RGB.RED);
        table.SetTextFontInRow(26, f3, 7);
        table.RemoveLineBetweenRows(0, 1);
        table.AutoAdjustColumnWidths();
        table.SetColumnWidth(0, 120);
        table.RightAlignNumbers();
        int numOfPages = table.GetNumberOfPages(page);
        while (true) {
            table.DrawOn(page);
            // TO DO: Draw "Page 1 of N" here
            if (!table.HasMoreData()) break;
            page = new Page(pdf, Letter.PORTRAIT);
        }

        pdf.Flush();
        bos.Close();
    }
        /// <summary>
        /// Initialize document.
        /// </summary>
        /// <param name="conf">Config object that defines which pages and images to use.</param>
        /// <param name="princePath">Path to the PrinceXML binary.</param>
        public PrinceDocument(PDF.Config conf, string princePath)
        {
            prince = new Prince(princePath);

            // We are dealing with Html
            prince.SetHTML(true);

            // Add default stylesheets
            prince.AddStyleSheet(AppDomain.CurrentDomain.BaseDirectory + "\\assets\\mediawiki.css");
            prince.AddStyleSheet(AppDomain.CurrentDomain.BaseDirectory + "\\assets\\book.css");
            prince.AddStyleSheet(AppDomain.CurrentDomain.BaseDirectory + "\\assets\\ruby.css");

            // Add additional stylesheets
            foreach (Uri path in conf.StyleSheets)
            {
                prince.AddStyleSheet(path.AbsolutePath);
            }

            this.conf = conf;
        }
    public Example_05()
    {
        FileStream fos = new FileStream("Example_05.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        // Before you enable this flag please read README.ZLIB.TXT
        // in the 'optional' directory.

        // If PDF/A is not required use Helvetica, TimesRoman or Courier
        Font f1 = new Font(pdf, "Helvetica");

        Page page = new Page(pdf, Letter.PORTRAIT);

        TextLine text = new TextLine(f1);
        text.SetPosition(300.0, 300.0);
        for (int i = 0; i < 360; i += 15) {
            text.SetTextDirection(i);
            text.SetUnderline(true);
            // text.SetStrikeLine(true);
            text.SetText("             Hello, World -- " + i + " degrees.");
            text.DrawOn(page);
        }

        text = new TextLine(f1, "WAVE AWAY");
        text.SetPosition(70.0, 50.0);
        text.DrawOn(page);

        f1.SetKernPairs(true);
        text.SetPosition(70.0, 70.0);
        text.DrawOn(page);

        f1.SetKernPairs(false);
        text.SetPosition(70.0, 90.0);
        text.DrawOn(page);

        f1.SetSize(8);
        text = new TextLine(f1, "-- font.SetKernPairs(false);");
        text.SetPosition(150.0, 50.0);
        text.DrawOn(page);
        text.SetPosition(150.0, 90.0);
        text.DrawOn(page);
        text = new TextLine(f1, "-- font.SetKernPairs(true);");
        text.SetPosition(150.0, 70.0);
        text.DrawOn(page);

        Point point = new Point(300.0, 300.0);
        point.SetShape(Point.CIRCLE);
        point.SetFillShape(true);
        point.SetColor(RGB.BLUE);
        point.SetRadius(37.0);
        point.DrawOn(page);
        point.SetRadius(25.0);
        point.SetColor(RGB.WHITE);
        point.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }
Example #9
0
        public bool Do(string configurationFilePath)
        {
            try
            {
                Console.WriteLine("--- Load configuration file ---");
                configurationFilePath = Environment.ExpandEnvironmentVariables(configurationFilePath);
                XDocument xDocument = XDocument.Parse(File.ReadAllText(configurationFilePath));

                //// Options
                var xmlOptions = xDocument.Root.Element("Options");
                // DataSource
                Console.WriteLine("Load spreadsheet");
                dataSource = new Spreadsheet();
                dataSource.Open(Environment.ExpandEnvironmentVariables(xmlOptions.Element("DataSource").Element("Parameter").Value));
                ((Spreadsheet)dataSource).SetSheet(xmlOptions.Element("Spreadsheet").Element("Table").Value);

                // PDF
                Console.WriteLine("Load PDF");
                pdf = new PDF();
                pdf.Open(Environment.ExpandEnvironmentVariables(xmlOptions.Element("PDF").Element("Filepath").Value));

                //// PDFFieldValues
                Console.WriteLine("Load field configuration");
                Dictionary <string, PDFField> pdfFields = new Dictionary <string, PDFField>();
                foreach (var node in xDocument.Root.Element("PDFFieldValues").Descendants("PDFFieldValue"))
                {
                    var pdfField = new PDFField();
                    pdfField.Name                   = node.Element("Name").Value;
                    pdfField.DataSourceValue        = node.Element("NewValue").Value;
                    pdfField.UseValueFromDataSource = Convert.ToBoolean(node.Element("UseValueFromDataSource").Value);
                    pdfField.MakeReadOnly           = Convert.ToBoolean(node.Element("MakeReadOnly").Value);

                    pdfFields.Add(pdfField.Name, pdfField);
                }

                //// Filename
                Console.WriteLine("Load filename options");
                var xmlFilename = xmlOptions.Element("Filename");
                prefix = xmlFilename.Element("Prefix").Value;
                useValueFromDataSource         = Convert.ToBoolean(xmlFilename.Element("ValueFromDataSource").Value);
                DataSourceColumnsFilenameIndex = ((Spreadsheet)dataSource).Columns.IndexOf(xmlFilename.Element("DataSource").Value);
                suffix       = xmlFilename.Element("Suffix").Value;
                useRowNumber = Convert.ToBoolean(xmlFilename.Element("RowNumber").Value);

                //// Other
                Console.WriteLine("Load general options");
                bool   finalize  = Convert.ToBoolean(xmlOptions.Element("Finalize").Value);
                string outputDir = Environment.ExpandEnvironmentVariables(xmlOptions.Element("OutputDir").Value);


                Console.WriteLine("--- Start processing ---");
                PDFFiller.CreateFiles(pdf, finalize, dataSource, pdfFields, outputDir + @"\", ConcatFilename, WriteLinePercent);
                Console.WriteLine("!!! Finished !!!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }

            return(true);
        }
    public Example_31()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_31.pdf", FileMode.Create)));

        Page page = new Page(pdf, Letter.PORTRAIT);

        Font f1 = new Font(pdf,
                           new FileStream("fonts/Noto/NotoSansDevanagari-Regular.ttf",
                                          FileMode.Open,
                                          FileAccess.Read));

        f1.SetSize(15f);

        Font f2 = new Font(pdf,
                           new FileStream("fonts/Droid/DroidSans.ttf",
                                          FileMode.Open,
                                          FileAccess.Read));

        f2.SetSize(15f);

        StringBuilder buf    = new StringBuilder();
        StreamReader  reader = new StreamReader(
            new FileStream("data/marathi.txt", FileMode.Open, FileAccess.Read));
        String line = null;

        while ((line = reader.ReadLine()) != null)
        {
            buf.Append(line + "\n");
        }
        reader.Close();

        TextBox textBox = new TextBox(f1, buf.ToString(), 500f, 300f);

        textBox.SetFallbackFont(f2);
        textBox.SetLocation(50f, 50f);
        textBox.SetNoBorders();
        textBox.DrawOn(page);

        String   str      = "असम के बाद UP में भी CM कैंडिडेट का ऐलान करेगी BJP?";
        TextLine textLine = new TextLine(f1, str);

        textLine.SetFallbackFont(f2);
        textLine.SetLocation(50f, 175f);
        textLine.DrawOn(page);


        page.SetPenColor(Color.blue);
        page.SetBrushColor(Color.blue);
        page.FillRect(50f, 200f, 200f, 200f);

        GraphicsState gs = new GraphicsState();

        gs.Set_CA(0.5f);    // The stroking alpha constant
        gs.Set_ca(0.5f);    // The nonstroking alpha constant
        page.SetGraphicsState(gs);

        page.SetPenColor(Color.green);
        page.SetBrushColor(Color.green);
        page.FillRect(100f, 250f, 200f, 200f);

        page.SetPenColor(Color.red);
        page.SetBrushColor(Color.red);
        page.FillRect(150, 300, 200f, 200f);

        // Reset the parameters to the default values
        page.SetGraphicsState(new GraphicsState());

        page.SetPenColor(Color.orange);
        page.SetBrushColor(Color.orange);
        page.FillRect(200, 350, 200f, 200f);

        page.SetBrushColor(0x00003865);
        page.FillRect(50, 550, 200f, 200f);

        pdf.Close();
    }
Example #11
0
 public DocPdfBuilder()
 {
     documentacion = new PDF();
 }
Example #12
0
    public Example_13()
    {
        FileStream     fos = new FileStream("Example_13.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);

        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Font f1 = new Font(pdf, "Helvetica-Bold");
        Font f2 = new Font(pdf, "Helvetica");

        f1.SetSize(7.0);
        f2.SetSize(7.0);

        List <List <Cell> > tableData = new List <List <Cell> >();
        StreamReader        reader    = new StreamReader(
            new FileStream("data/winter-2009.txt", FileMode.Open));
        String line;

        while ((line = reader.ReadLine()) != null)
        {
            List <Cell> row     = new List <Cell>();
            String[]    columns = line.Split(new Char[] { '|' });
            for (int i = 0; i < columns.Length; i++)
            {
                row.Add(new Cell(f2, columns[i]));
            }
            tableData.Add(row);
        }
        reader.Close();

        Table table = new Table(f1, f2);

        table.SetData(tableData, Table.DATA_HAS_2_HEADER_ROWS);
        table.SetPosition(100.0, 50.0);
        table.setCellMargin(2.0);

        table.RemoveLineBetweenRows(0, 1);

        Cell cell3 = table.GetCellAt(1, 1);

        cell3.border.top = true;

        cell3            = table.GetCellAt(1, 2);
        cell3.border.top = true;

        SetFontForRow(table, 0, f1);
        SetFontForRow(table, 1, f1);

        table.AutoAdjustColumnWidths();

        List <Cell> column = table.GetColumn(7);

        for (int i = 0; i < column.Count; i++)
        {
            Cell cell = column[i];
            cell.SetTextAlignment(Align.CENTER);
        }

        column = table.GetColumn(4);
        for (int i = 2; i < column.Count; i++)
        {
            Cell cell = column[i];
            try {
                cell.SetTextAlignment(Align.CENTER);
                if (Int32.Parse(cell.GetText()) > 40)
                {
                    cell.SetBgColor(new double[] { 0.0, 0.85, 0.0 });
                }
                else
                {
                    cell.SetBgColor(new double[] { 1.0, 1.0, 0.0 });
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
        }

        Cell cell2 = table.GetCellAt(0, 1);

        cell2.SetColSpan(2);
        cell2.SetTextAlignment(Align.CENTER);

        SetBgColorForRow(table, 0, new double[] { 0.85, 0.85, 0.85 });
        SetBgColorForRow(table, 1, new double[] { 0.85, 0.85, 0.85 });

        table.SetColumnWidth(3, 10);
        blankOutColumn(table, 3);

        table.SetColumnWidth(8, 10);
        blankOutColumn(table, 8);

        Page page       = new Page(pdf, Letter.PORTRAIT);
        int  numOfPages = table.GetNumberOfPages(page);
        int  pageNumber = 1;

        while (true)
        {
            table.DrawOn(page);

            TextLine text = new TextLine(f1);
            text.SetText("Page " + pageNumber++ + " of " + numOfPages);
            text.SetPosition(300.0, 780.0);
            text.DrawOn(page);

            if (!table.HasMoreData())
            {
                break;
            }
            page = new Page(pdf, Letter.PORTRAIT);
        }

        pdf.Flush();
        bos.Close();
    }
Example #13
0
    public Example_02()
    {
        FileStream     fos = new FileStream("Example_02.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);

        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Page page = new Page(pdf, Letter.PORTRAIT);

        Box flag = new Box(85, 85, 64, 32);

        PDFjet.NET.Path path = new PDFjet.NET.Path();
        path.Add(new Point(13.0, 0.0));
        path.Add(new Point(15.5, 4.5));
        path.Add(new Point(18.0, 3.5));

        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(20.5, 7.5, Point.IS_CURVE_POINT));

        path.Add(new Point(21.0, 9.5));
        path.Add(new Point(25.0, 9.0));
        path.Add(new Point(24.0, 13.0));
        path.Add(new Point(25.5, 14.0));
        path.Add(new Point(19.0, 19.0));
        path.Add(new Point(20.0, 21.5));
        path.Add(new Point(13.5, 20.5));
        path.Add(new Point(13.5, 27.0));
        path.Add(new Point(12.5, 27.0));
        path.Add(new Point(12.5, 20.5));
        path.Add(new Point(6.0, 21.5));
        path.Add(new Point(7.0, 19.0));
        path.Add(new Point(0.5, 14.0));
        path.Add(new Point(2.0, 13.0));
        path.Add(new Point(1.0, 9.0));
        path.Add(new Point(5.0, 9.5));
        path.Add(new Point(5.5, 7.5));

        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(8.0, 3.5, Point.IS_CURVE_POINT));

        path.Add(new Point(10.5, 4.5));
        path.setClosePath(true);
        path.SetColor(RGB.RED);
        path.SetFillShape(true);
        path.PlaceIn(flag, 19.0, 3.0);
        path.DrawOn(page);

        Box box = new Box();

        box.SetSize(16, 32);
        box.SetColor(RGB.RED);
        box.SetFillShape(true);
        box.PlaceIn(flag, 0.0, 0.0);
        box.DrawOn(page);
        box.PlaceIn(flag, 48.0, 0.0);
        box.DrawOn(page);

        path.ScaleBy(15.0);
        path.SetFillShape(false);
        path.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }
    public static double log_normal_truncated_ab_cdf_inv(double cdf, double mu, double sigma,
                                                         double a, double b)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LOG_NORMAL_TRUNCATED_AB_CDF_INV inverts the Log Normal truncated AB CDF.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    27 March 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, double CDF, the value of the CDF.
    //    0.0 <= CDF <= 1.0.
    //
    //    Input, double MU, SIGMA, the parameters of the PDF.
    //    0.0 < SIGMA.
    //
    //    Input, double A, B, the lower and upper truncation limits.
    //    A < B.
    //
    //    Input, double LOG_NORMAL_TRUNCATED_AB_CDF_INV, the corresponding argument.
    //
    {
        bool check = PDF.log_normal_truncated_ab_check(mu, sigma, a, b);

        switch (check)
        {
        case false:
            Console.WriteLine("");
            Console.WriteLine("LOG_NORMAL_TRUNCATED_AB_CDF_INV - Fatal error!");
            Console.WriteLine("  Parameters are not legal.");
            return(1);

        default:
            double x;
            switch (cdf)
            {
            case <= 0.0:
                x = a;
                break;

            case >= 1.0:
                x = b;
                break;

            default:
                double lncdf_a = log_normal_cdf(a, mu, sigma);
                double lncdf_b = log_normal_cdf(b, mu, sigma);

                double lncdf_x = lncdf_a + cdf * (lncdf_b - lncdf_a);
                x = log_normal_cdf_inv(lncdf_x, mu, sigma);
                break;
            }

            return(x);
        }
    }
Example #15
0
    public Example_06()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_06.pdf", FileMode.Create)));

        // Use .ttf.stream fonts
        Font f1 = new Font(pdf, new FileStream(
                               "fonts/OpenSans/OpenSans-Regular.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read),
                           Font.STREAM);

        f1.SetSize(12f);

        Font f2 = new Font(pdf, new FileStream(
                               "fonts/Droid/DroidSansFallback.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read),
                           Font.STREAM);

        f2.SetSize(12f);

        Page page = new Page(pdf, Letter.PORTRAIT);

        List <Paragraph> paragraphs = new List <Paragraph>();
        Paragraph        paragraph  = null;

        StreamReader reader = new StreamReader(
            new FileStream("data/LCG.txt", FileMode.Open));
        String line = null;

        while ((line = reader.ReadLine()) != null)
        {
            if (line.Equals(""))
            {
                continue;
            }
            paragraph = new Paragraph();
            TextLine textLine = new TextLine(f1, line);
            textLine.SetFallbackFont(f2);
            paragraph.Add(textLine);
            paragraphs.Add(paragraph);
        }
        Text text = new Text(paragraphs);

        text.SetLocation(50f, 50f);
        text.SetWidth(500f);
        text.DrawOn(page);


        page = new Page(pdf, Letter.PORTRAIT);

        paragraphs = new List <Paragraph>();

        reader = new StreamReader(
            new FileStream("data/CJK.txt", FileMode.Open));

        while ((line = reader.ReadLine()) != null)
        {
            if (line.Equals(""))
            {
                continue;
            }
            paragraph = new Paragraph();
            TextLine textLine = new TextLine(f2, line);
            textLine.SetFallbackFont(f1);
            paragraph.Add(textLine);
            paragraphs.Add(paragraph);
        }
        text = new Text(paragraphs);
        text.SetLocation(50f, 50f);
        text.SetWidth(500f);
        text.DrawOn(page);

/*
 *      Page page = new Page(pdf, Letter.PORTRAIT);
 *
 *      List<Paragraph> paragraphs = new List<Paragraph>();
 *      Paragraph paragraph = new Paragraph();
 *
 *      TextLine textLine = new TextLine(f1, "Happy New Year!");
 *      textLine.SetFallbackFont(f2);
 *      textLine.SetLocation(70f, 70f);
 *      textLine.DrawOn(page);
 *
 *      paragraph.Add(textLine);
 *
 *      textLine = new TextLine(f1, "С Новым Годом!");
 *      textLine.SetFallbackFont(f2);
 *      textLine.SetLocation(70f, 100f);
 *      textLine.DrawOn(page);
 *
 *      paragraph.Add(textLine);
 *
 *      textLine = new TextLine(f1, "Ευτυχισμένο το Νέο Έτος!");
 *      textLine.SetFallbackFont(f2);
 *      textLine.SetLocation(70f, 130f);
 *      textLine.DrawOn(page);
 *
 *      paragraph.Add(textLine);
 *
 *      textLine = new TextLine(f1, "新年快樂!");
 *      textLine.SetFallbackFont(f2);
 *      textLine.SetLocation(300f, 70f);
 *      textLine.DrawOn(page);
 *
 *      paragraph.Add(textLine);
 *
 *      textLine = new TextLine(f1, "新年快乐!");
 *      textLine.SetFallbackFont(f2);
 *      textLine.SetLocation(300f, 100f);
 *      textLine.DrawOn(page);
 *
 *      paragraph.Add(textLine);
 *
 *      textLine = new TextLine(f1, "明けましておめでとうございます!");
 *      textLine.SetFallbackFont(f2);
 *      textLine.SetLocation(300f, 130f);
 *      textLine.DrawOn(page);
 *
 *      paragraph.Add(textLine);
 *
 *      textLine = new TextLine(f1, "새해 복 많이 받으세요!");
 *      textLine.SetFallbackFont(f2);
 *      textLine.SetLocation(300f, 160f);
 *      textLine.DrawOn(page);
 *
 *      paragraph.Add(textLine);
 *
 *      paragraphs.Add(paragraph);
 *
 *      Text text = new Text(paragraphs);
 *      text.SetLocation(70f, 200f);
 *      text.SetWidth(500f);
 *      text.DrawOn(page);
 */

        pdf.Close();
    }
Example #16
0
    public Example_14()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_14.pdf", FileMode.Create)));

        Font f1 = new Font(pdf, CoreFont.HELVETICA_BOLD);
        Font f2 = new Font(pdf, CoreFont.HELVETICA);

        f1.SetSize(7f);
        f2.SetSize(7f);

        Page page = new Page(pdf, A4.PORTRAIT);

        Table table = new Table();
        // table.SetCellMargin(10f);

        List <List <Cell> > tableData = new List <List <Cell> >();

        List <Cell> row;
        Cell        cell;

        for (int i = 0; i < 5; i++)
        {
            row = new List <Cell>();
            for (int j = 0; j < 5; j++)
            {
                if (i == 0)
                {
                    cell = new Cell(f1);
                }
                else
                {
                    cell = new Cell(f2);
                }

                // WITH:
                cell.SetTopPadding(10f);
                cell.SetBottomPadding(10f);
                cell.SetLeftPadding(10f);
                cell.SetRightPadding(10f);

                cell.SetNoBorders();
                cell.SetText("Hello " + i + " " + j);
                if (i == 0)
                {
                    cell.SetBorder(Border.TOP, true);
                    cell.SetUnderline(true);
                    cell.SetUnderline(false);
                }
                if (i == 4)
                {
                    cell.SetBorder(Border.BOTTOM, true);
                }
                if (j == 0)
                {
                    cell.SetBorder(Border.LEFT, true);
                }
                if (j == 4)
                {
                    cell.SetBorder(Border.RIGHT, true);
                }

                if (i == 2 && j == 2)
                {
                    cell.SetBorder(Border.TOP, true);
                    cell.SetBorder(Border.BOTTOM, true);
                    cell.SetBorder(Border.LEFT, true);
                    cell.SetBorder(Border.RIGHT, true);

                    cell.SetColSpan(3);
                    cell.SetBgColor(Color.darkseagreen);
                    cell.SetLineWidth(1f);
                    cell.SetTextAlignment(Align.RIGHT);
                }

                row.Add(cell);
            }
            tableData.Add(row);
        }

        table.SetData(tableData);
        table.SetCellBordersWidth(0.2f);
        table.SetLocation(70f, 30f);
        table.DrawOn(page);

        // Must call this method before drawing the table again.
        table.ResetRenderedPagesCount();
        table.SetLocation(70f, 200f);
        table.DrawOn(page);

        pdf.Close();
    }
Example #17
0
    private static void r8po_fa_test()

//****************************************************************************80
//
//  Purpose:
//
//    R8PO_FA_TEST tests R8PO_FA.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    10 June 2013
//
//  Author:
//
//    John Burkardt
//
    {
        int       j;
        const int n = 5;

        Console.WriteLine("");
        Console.WriteLine("R8PO_FA_TEST");
        Console.WriteLine("  R8PO_FA computes the Cholesky factor R of a");
        Console.WriteLine("  positive definite matrix A, so that A = R' * R.");
        Console.WriteLine("");
        Console.WriteLine("  Start with random R1;");
        Console.WriteLine("  Compute A = R1' * R1.");
        Console.WriteLine("  Call R8MAT_POFAC and see if you recover R2 = R1.");
//
//  Generate a random upper triangular matrix with positive diagonal.
//
        double[] r1 = new double[n * n];

        for (j = 0; j < n; j++)
        {
            int i;
            for (i = 0; i <= j; i++)
            {
                r1[i + j * n] = PDF.r8_uniform_01_sample();
            }

            for (i = j + 1; i < n; i++)
            {
                r1[i + j * n] = 0.0;
            }
        }

        typeMethods.r8ge_print(n, n, r1, "  R1:");
//
//  Compute a positive definite symmetric matrix A.
//
        double[] a = typeMethods.r8ge_mtm(n, r1, r1);

        typeMethods.r8ge_print(n, n, a, "  A:");

        double[] r2 = typeMethods.r8po_fa(n, a);

        double diff = typeMethods.r8mat_norm_fro_affine(n, n, r1, r2);

        Console.WriteLine("");
        Console.WriteLine("  Frobenius difference between R1 and R2 = " + diff + "");
    }
Example #18
0
    public static void r8vec_multinormal_pdf_test()

//****************************************************************************80
//
//  Purpose:
//
//    R8VEC_MULTINORMAL_PDF_TEST tests R8VEC_MULTINORMAL_PDF.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    04 August 2015
//
//  Author:
//
//    John Burkardt
//
    {
        int       i;
        int       j;
        const int n = 5;

        Console.WriteLine("");
        Console.WriteLine("R8VEC_MULTINORMAL_PDF_TEST");
        Console.WriteLine("  R8VEC_MULTINORMAL_PDF evaluates the PDF for the");
        Console.WriteLine("  multinormal distribution.");
        Console.WriteLine("");
        Console.WriteLine("  The covariance matrix is C.");
        Console.WriteLine("  The definition uses the inverse of C;");
        Console.WriteLine("  R8VEC_MULTINORMAL_PDF uses the Cholesky factor.");
        Console.WriteLine("  Verify that the algorithms are equivalent.");
//
//  Generate a random upper triangular matrix with positive diagonal.
//
        double[] r1 = new double[n * n];

        for (j = 0; j < n; j++)
        {
            for (i = 0; i <= j; i++)
            {
                if (i == j)
                {
                    r1[i + j * n] = Math.Abs(PDF.r8_uniform_01_sample());
                }
                else
                {
                    r1[i + j * n] = PDF.r8_uniform_01_sample();
                }
            }

            for (i = j + 1; i < n; i++)
            {
                r1[i + j * n] = 0.0;
            }
        }

        typeMethods.r8ge_print(n, n, r1, "  R1:");
//
//  Compute a positive definite symmetric matrix C.
//
        double[] c = typeMethods.r8ge_mtm(n, r1, r1);
        typeMethods.r8ge_print(n, n, c, "  C:");
//
//  Compute the Cholesky factor.
//
        double[] r2 = typeMethods.r8mat_pofac(n, c);
        typeMethods.r8ge_print(n, n, r2, "  R2:");
//
//  Compute the determinant of C.
//
        double c_det = typeMethods.r8mat_podet(n, r2);

        Console.WriteLine("");
        Console.WriteLine("  Determinant of C = " + c_det + "");
//
//  Compute the inverse of C.
//
        double[] c_inv = typeMethods.r8mat_poinv(n, r2);
//
//  Compute a random set of means.
//
        double[] mu = new double[n];
        for (i = 0; i < n; i++)
        {
            mu[i] = PDF.r8_normal_01_sample();
        }

//
//  Compute X as small variations from MU.
//
        double[] x = new double[n];
        for (i = 0; i < n; i++)
        {
            double eps = 0.01 * PDF.r8_normal_01_sample();
            x[i] = (1.0 + eps) * mu[i];
        }

//
//  Compute PDF1 from the function.
//
        double pdf1 = PDF.r8vec_multinormal_pdf(n, mu, r2, c_det, x);

//
//  Compute PDF2 from the definition.
//
        double[] y = new double[n];
        for (i = 0; i < n; i++)
        {
            y[i] = x[i] - mu[i];
        }

        double xcx = 0.0;

        for (j = 0; j < n; j++)
        {
            for (i = 0; i < n; i++)
            {
                if (i <= j)
                {
                    xcx += y[i] * c_inv[i + j * n] * y[j];
                }
                else
                {
                    xcx += y[i] * c_inv[j + i * n] * y[j];
                }
            }
        }

        double pdf2 = 1.0 / Math.Sqrt(Math.Pow(2.0 * Math.PI, n))
                      * 1.0 / Math.Sqrt(c_det)
                      * Math.Exp(-0.5 * xcx);

        Console.WriteLine("");
        Console.WriteLine("  PDF1 = " + pdf1 + "");
        Console.WriteLine("  PDF2 = " + pdf2 + "");
    }
Example #19
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     ConfigManager.LogEvents += (sender, text, e) => Console.WriteLine((text != null ? text + ": " : "") + e?.StackTrace);
     string[] args = Environment.GetCommandLineArgs();
     Errorlog = new ErrorLog();
     Config.LoadConfig(Application.StartupPath);
     HTMLExtensions.LoadTransform += (t, o) => { if (o is DisplayPossession)
                                                 {
                                                     t.Load(HTMLExtensions.Transform_Possession.FullName);
                                                 }
     };
     ConfigManager.LicenseProvider = new LicenseProvider();
     if (SourceManager.Init(Context, Application.StartupPath, true))
     {
         if (args.Count() > 1)
         {
             string file = args[1];
             if (File.Exists(file) && ".pdf".Equals(Path.GetExtension(file), StringComparison.InvariantCultureIgnoreCase))
             {
                 PDF.markFields(file);
                 Application.Exit();
                 return;
             }
         }
         LoadData();
     }
     else
     {
         Exit();
         return;
     }
     Context.SourcesChangedEvent += Player_SourcesChangedEvent;
     MainWindow = new Form1();
     if (args.Count() > 1)
     {
         string file = args[1];
         if (File.Exists(file))
         {
             MainWindow.lastfile = file;
             using (FileStream fs = new FileStream(file, FileMode.Open))
             {
                 try
                 {
                     Context.Player = PlayerExtensions.Load(Context, fs);
                     MainWindow.UpdateLayout();
                 }
                 catch (Exception e)
                 {
                     System.Windows.Forms.MessageBox.Show(e.Message + "\n" + e.InnerException + "\n" + e.StackTrace, "Error while loading " + file);
                     Program.Exit();
                 }
             }
         }
     }
     if (args.Count() > 2 && args[2] == "register")
     {
         Register();
     }
     Application.Run(MainWindow);
 }
Example #20
0
 public void PDFSave(PDF pdf)
 {
     PDFDAL.Save(null, null, pdf);
 }
        public ActionResult Save(ORDER_TASK_INFORMATION entity)
        {
            Common.ClientResult.OrderTaskGong result = new Common.ClientResult.OrderTaskGong();
            try
            {
                string currentPerson = GetCurrentPerson();
                if (string.IsNullOrWhiteSpace(entity.ID))
                {
                    List <COMPANY> companylist  = m_BLL2.GetByParam(null, "asc", "ID", "COMPANYNAME&" + entity.INSPECTION_ENTERPRISE + "");
                    List <COMPANY> companylist2 = m_BLL2.GetByParam(null, "asc", "ID", "COMPANYNAME&" + entity.CERTIFICATE_ENTERPRISE + "");


                    foreach (var item in companylist)
                    {
                        if (item.COMPANY2 != null)
                        {
                            entity.INSPECTION_ENTERPRISEHELLD = item.COMPANY2.COMPANYNAME;
                            break;
                        }
                    }
                    foreach (var item in companylist2)
                    {
                        if (item.COMPANY2 != null)
                        {
                            entity.CERTIFICATE_ENTERPRISEHELLD = item.COMPANY2.COMPANYNAME;
                            break;
                        }
                    }
                    string ORDER_NUMBER = m_BLL.GetORDER_NUMBER(ref validationErrors);
                    var    order        = ORDER_NUMBER.Split('*');// DC2016001 * 1 * 2016
                    entity.ORDER_STATUS = Common.ORDER_STATUS_INFORMATION.保存.ToString();
                    var ms = new System.IO.MemoryStream();
                    entity.CREATETIME   = DateTime.Now;
                    entity.CREATEPERSON = currentPerson;
                    entity.ID           = Result.GetNewId();

                    entity.ORDER_NUMBER   = order[0].ToString();
                    entity.ORSERIALNUMBER = Convert.ToDecimal(order[1]);
                    entity.ORYEARS        = order[2].ToString();

                    entity.ORDER_STATUS = Common.ORDER_STATUS_INFORMATION.保存.ToString();

                    string path = Server.MapPath("~/up/ErWeiMa/");
                    foreach (var item in entity.APPLIANCE_DETAIL_INFORMATION)
                    {
                        item.ID           = Result.GetNewId();
                        item.CREATETIME   = DateTime.Now;
                        item.CREATEPERSON = currentPerson;
                        item.BAR_CODE_NUM = item.ID;
                        //二维码生成
                        ErrorCorrectionLevel Ecl    = ErrorCorrectionLevel.M; //误差校正水平
                        string           Content    = item.ID;                //待编码内容
                        QuietZoneModules QuietZones = QuietZoneModules.Two;   //空白区域
                        int    ModuleSize           = 3;                      //大小
                        var    encoder = new QrEncoder(Ecl);
                        QrCode qr;
                        if (encoder.TryEncode(Content, out qr))//对内容进行编码,并保存生成的矩阵
                        {
                            Renderer r = new Renderer(ModuleSize);
                            r.QuietZoneModules = QuietZones;
                            r.WriteToStream(qr.Matrix, ms, ImageFormat.Png);
                        }
                        //QRCodeHelper.GetQRCode(item.ID, ms);
                        var pathErWeiMa = path + item.ID + ".png";

                        //System.IO.FileStream fs = new System.IO.FileStream(pathErWeiMa, System.IO.FileMode.OpenOrCreate);


                        //System.IO.BinaryWriter w = new System.IO.BinaryWriter(fs);
                        #region 二维码加字
                        System.IO.FileStream fss = new System.IO.FileStream(Server.MapPath("~/up/moban.png"), System.IO.FileMode.OpenOrCreate);
                        int filelength           = 0;
                        filelength = (int)fss.Length;        //获得文件长度
                        Byte[] image = new Byte[filelength]; //建立一个字节数组
                        fss.Read(image, 0, filelength);      //按字节流读取
                        System.Drawing.Image imag = System.Drawing.Image.FromStream(fss);
                        //System.Drawing.Image Image = System.Drawing.Image.FromStream(ms);
                        Graphics g = null;
                        g = Graphics.FromImage(imag);
                        string xinghao = item.FACTORY_NUM;//需要写入的字
                        //string xinghao = "123456789abcd";//需要写入的字
                        int w = imag.Width;
                        int h = imag.Height;
                        int y = 0;
                        int x = 380;
                        for (int i = 0; i < xinghao.Length; i++)
                        {
                            if (x > w)
                            {
                                result.Code    = Common.ClientCode.Fail;
                                result.Message = "内容太多二维码生成失败!";
                                return(Json(result));
                            }
                            else
                            {
                                if (i % 6 == 0)
                                {
                                    x = x + 50;
                                    y = 0;
                                    y = y + 45;
                                    g.DrawString(xinghao[i].ToString(), new Font("宋体", 14), Brushes.Red, new PointF(x, y));//x:值越大越靠右;y:值越小越靠上
                                }
                                else
                                {
                                    y = y + 45;
                                    g.DrawString(xinghao[i].ToString(), new Font("宋体", 14), Brushes.Red, new PointF(x, y));//x:值越大越靠右;y:值越小越靠上
                                }
                            }
                        }
                        System.Drawing.Image ig = CombinImage(imag, ms);
                        fss.Close();
                        TuPanBaoCun(ig, pathErWeiMa);
                        //生成pdf
                        //图片
                        //Image image = Image.GetInstance(imagePath);
                        //cell = new PdfPCell(image, true);
                        //table.AddCell(cell);
                        PDF.Create(path + item.ID);
                        #endregion

                        //w.Write(ms.ToArray());
                        //fs.Close();
                        //器具明细信息_承接实验室表添加数据
                        foreach (var it in item.UNDERTAKE_LABORATORYID.TrimEnd(',').Split(','))
                        {
                            item.APPLIANCE_LABORATORY.Add(new APPLIANCE_LABORATORY()
                            {
                                ID = Result.GetNewId(),
                                UNDERTAKE_LABORATORYID   = it,
                                ORDER_STATUS             = Common.ORDER_STATUS.保存.ToString(),
                                EQUIPMENT_STATUS_VALUUMN = Common.ORDER_STATUS.保存.GetHashCode().ToString(),
                                DISTRIBUTIONPERSON       = currentPerson,
                                DISTRIBUTIONTIME         = DateTime.Now,
                                CREATEPERSON             = currentPerson,
                                CREATETIME = DateTime.Now,
                                ISRECEIVE  = Common.ISRECEIVE.是.ToString(),
                                RECYCLING  = entity.RECYCLING
                            });
                        }
                    }
                    ms.Close();

                    string returnValue = string.Empty;
                    if (m_BLL.Create(ref validationErrors, entity))
                    {
                        LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",委托单信息的信息的Id为" + entity.ID, "委托单信息"
                                                       );//写入日志
                        result.Code    = Common.ClientCode.Succeed;
                        result.Message = Suggestion.InsertSucceed;
                        result.Id      = entity.ID;
                        return(Json(result)); //提示创建成功
                    }
                    else
                    {
                        if (validationErrors != null && validationErrors.Count > 0)
                        {
                            validationErrors.All(a =>
                            {
                                returnValue += a.ErrorMessage;
                                return(true);
                            });
                        }
                        LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",委托单信息的信息," + returnValue, "委托单信息"
                                                       );//写入日志
                        result.Code    = Common.ClientCode.Fail;
                        result.Message = Suggestion.InsertFail + returnValue;
                        return(Json(result)); //提示插入失败
                    }
                }
                else
                {
                }


                result.Code    = Common.ClientCode.FindNull;
                result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            }
            catch (Exception lastError)
            {
                ExceptionsHander.WriteExceptions(lastError);//将异常写入数据库
            }
            return(Json(result));
        }
Example #22
0
        private void exportPDF(string path, string name)
        {
            commUtil.ShowInfo_DEBUG(" Save --pdf (" + name + ")----- Start == " + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
            PDF pDF = new PDF(new System.IO.BufferedStream(new System.IO.FileStream(path + "\\" + name + ".pdf", System.IO.FileMode.Create)));

            PDFjet.NET.Font font = new PDFjet.NET.Font(pDF, CoreFont.TIMES_BOLD);
            font.SetSize(7f);
            PDFjet.NET.Font font2 = new PDFjet.NET.Font(pDF, CoreFont.TIMES_ROMAN);
            font2.SetSize(7f);
            int  num  = 1;
            Page page = new Page(pDF, Letter.PORTRAIT);

            pdfUtil.DrawTitle(pDF, page, this.lbTitle.Text, 0f, 12f, 1048576);
            string msg = EcoLanguage.getMsg(LangRes.Rpt_BillTitle, new string[]
            {
                this.m_pParaClass.Txtwriter,
                this.m_pParaClass.Dtptime
            });

            pdfUtil.DrawTitle(pDF, page, msg, 30f, 10f, 2097152);
            System.Collections.Generic.List <System.Collections.Generic.List <Cell> > list = new System.Collections.Generic.List <System.Collections.Generic.List <Cell> >();
            System.Collections.Generic.List <Cell> list2 = new System.Collections.Generic.List <Cell>();
            for (int i = 0; i < this.dgvBilling.ColumnCount; i++)
            {
                Cell cell = new Cell(font, this.dgvBilling.Columns[i].HeaderText);
                cell.SetTextAlignment(1048576);
                list2.Add(cell);
            }
            list.Add(list2);
            for (int j = 0; j < this.dgvBilling.Rows.Count; j++)
            {
                list2 = new System.Collections.Generic.List <Cell>();
                for (int k = 0; k < this.dgvBilling.ColumnCount; k++)
                {
                    Cell cell = new Cell(font2, this.dgvBilling.Rows[j].Cells[k].Value.ToString());
                    if (this.dgvBilling.Rows[j].Cells[k].Style.Alignment == DataGridViewContentAlignment.MiddleRight || this.dgvBilling.Columns[k].DefaultCellStyle.Alignment == DataGridViewContentAlignment.MiddleRight)
                    {
                        cell.SetTextAlignment(2097152);
                    }
                    list2.Add(cell);
                }
                list.Add(list2);
            }
            System.Collections.Generic.List <float> list3 = new System.Collections.Generic.List <float>();
            int tableType_index = this.m_pParaClass.tableType_index;

            for (int l = 0; l < this.dgvBilling.Columns.Count; l++)
            {
                float item = pdfUtil.PDFpageeffwidth / (float)this.dgvBilling.Size.Width * (float)BillingRptShow.TableWidth[tableType_index][l];
                list3.Add(item);
            }
            Page page2 = pdfUtil.DrawTable(pDF, page, ref num, list, Table.DATA_HAS_1_HEADER_ROWS, 55f, list3);

            pdfUtil.DrawPageNumber(pDF, page2, num++);
            pDF.Close();
            commUtil.ShowInfo_DEBUG(string.Concat(new string[]
            {
                " Save --pdf (",
                name,
                ")----- End   == ",
                System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"),
                "\n"
            }));
        }
Example #23
0
    public Example_13()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_13.pdf", FileMode.Create)));

        Font f1 = new Font(pdf, CoreFont.HELVETICA_BOLD);
        Font f2 = new Font(pdf, CoreFont.HELVETICA);

        f1.SetSize(7f);
        f2.SetSize(7f);

        List <List <Cell> > tableData = new List <List <Cell> >();
        StreamReader        reader    = new StreamReader(
            new FileStream("data/winter-2009.txt", FileMode.Open));
        String line;

        while ((line = reader.ReadLine()) != null)
        {
            List <Cell> row     = new List <Cell>();
            String[]    columns = line.Split(new Char[] { '|' });
            for (int i = 0; i < columns.Length; i++)
            {
                Cell cell = new Cell(f2, columns[i]);

                // WITH:
                cell.SetTopPadding(2f);
                cell.SetBottomPadding(2f);
                cell.SetLeftPadding(2f);
                cell.SetRightPadding(2f);

                row.Add(cell);
            }
            tableData.Add(row);
        }
        reader.Close();

        Table table = new Table();

        table.SetData(tableData, Table.DATA_HAS_2_HEADER_ROWS);
        table.SetLocation(100f, 50f);

        // REPLACED:
        // table.SetCellMargin(2f);

        table.RemoveLineBetweenRows(0, 1);

        Cell cell3 = table.GetCellAt(1, 1);

        cell3.SetBorder(Border.TOP, true);

        cell3 = table.GetCellAt(1, 2);
        cell3.SetBorder(Border.TOP, true);

        SetFontForRow(table, 0, f1);
        SetFontForRow(table, 1, f1);

        table.AutoAdjustColumnWidths();

        List <Cell> column = table.GetColumn(7);

        for (int i = 0; i < column.Count; i++)
        {
            Cell cell = column[i];
            cell.SetTextAlignment(Align.CENTER);
        }

        column = table.GetColumn(4);
        for (int i = 2; i < column.Count; i++)
        {
            Cell cell = column[i];
            try {
                cell.SetTextAlignment(Align.CENTER);
                if (Int32.Parse(cell.GetText()) > 40)
                {
                    cell.SetBgColor(Color.darkseagreen);
                }
                else
                {
                    cell.SetBgColor(Color.yellow);
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
        }

        Cell cell2 = table.GetCellAt(0, 1);

        cell2.SetColSpan(2);
        cell2.SetTextAlignment(Align.CENTER);

        SetBgColorForRow(table, 0, Color.lightgray);
        SetBgColorForRow(table, 1, Color.lightgray);

        table.SetColumnWidth(3, 10);
        blankOutColumn(table, 3);

        table.SetColumnWidth(8, 10f);
        blankOutColumn(table, 8);

        Page page       = new Page(pdf, Letter.PORTRAIT);
        int  numOfPages = table.GetNumberOfPages(page);
        int  pageNumber = 1;

        while (true)
        {
            table.DrawOn(page);

            TextLine text = new TextLine(f1);
            text.SetText("Page " + pageNumber++ + " of " + numOfPages);
            text.SetLocation(300f, 780f);
            text.DrawOn(page);

            if (!table.HasMoreData())
            {
                table.ResetRenderedPagesCount();
                break;
            }

            page = new Page(pdf, Letter.PORTRAIT);
        }

        pdf.Close();
    }
Example #24
0
    public Example_45()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_45.pdf", FileMode.Create)),
                          Compliance.PDF_UA);

        Font f1 = new Font(pdf,
                           new FileStream(
                               "fonts/Droid/DroidSerif-Regular.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read),
                           Font.STREAM);

        Font f2 = new Font(pdf,
                           new FileStream(
                               // "fonts/Droid/DroidSerif-Regular.ttf.stream",
                               "fonts/Droid/DroidSerif-Italic.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read),
                           Font.STREAM);

        f1.SetSize(14f);
        f2.SetSize(14f);
        // f2.SetItalic(true);

        Page page = new Page(pdf, Letter.PORTRAIT);

        TextLine text = new TextLine(f1);

        text.SetLocation(70f, 70f);
        text.SetText("Hasta la vista!");
        text.SetLanguage("es-MX");
        text.SetStrikeout(true);
        text.SetUnderline(true);
        text.SetURIAction("http://pdfjet.com");
        text.DrawOn(page);

        text = new TextLine(f1);
        text.SetLocation(70f, 90f);
        text.SetText("416-335-7718");
        text.SetURIAction("http://pdfjet.com");
        text.DrawOn(page);

        text = new TextLine(f1);
        text.SetLocation(70f, 120f);
        text.SetText("2014-11-25");
        text.DrawOn(page);

        List <Paragraph> paragraphs = new List <Paragraph>();

        Paragraph paragraph = new Paragraph()
                              .Add(new TextLine(f1,
                                                "The centres also offer free one-on-one consultations with business advisors who can review your business plan and make recommendations to improve it. The small business centres offer practical resources, from step-by-step info on setting up your business to sample business plans to a range of business-related articles and books in our resource libraries."))
                              .Add(new TextLine(f2,
                                                "This text is blue color and is written using italic font.")
                                   .SetColor(Color.blue));

        paragraphs.Add(paragraph);

        Text textArea = new Text(paragraphs);

        textArea.SetLocation(70f, 150f);
        textArea.SetWidth(500f);
        textArea.DrawOn(page);

        float[] xy = (new PlainText(f2, new String[] {
            "The Fibonacci sequence is named after Fibonacci.",
            "His 1202 book Liber Abaci introduced the sequence to Western European mathematics,",
            "although the sequence had been described earlier in Indian mathematics.",
            "By modern convention, the sequence begins either with F0 = 0 or with F1 = 1.",
            "The Liber Abaci began the sequence with F1 = 1, without an initial 0.",
            "",
            "Fibonacci numbers are closely related to Lucas numbers in that they are a complementary pair",
            "of Lucas sequences. They are intimately connected with the golden ratio;",
            "for example, the closest rational approximations to the ratio are 2/1, 3/2, 5/3, 8/5, ... .",
            "Applications include computer algorithms such as the Fibonacci search technique and the",
            "Fibonacci heap data structure, and graphs called Fibonacci cubes used for interconnecting",
            "parallel and distributed systems. They also appear in biological settings, such as branching",
            "in trees, phyllotaxis (the arrangement of leaves on a stem), the fruit sprouts of a pineapple,",
            "the flowering of an artichoke, an uncurling fern and the arrangement of a pine cone.",
        })
                      .SetLocation(70f, 370f)
                      .SetFontSize(10f)
                      .DrawOn(page));

        Box box = new Box();

        box.SetLocation(xy[0], xy[1]);
        box.SetSize(20f, 20f);
        box.DrawOn(page);

        page = new Page(pdf, Letter.PORTRAIT);

        text = new TextLine(f1);
        text.SetLocation(70f, 120f);
        text.SetText("416-877-1395");
        text.DrawOn(page);

        Line line = new Line(70f, 150f, 300f, 150f);

        line.SetWidth(1f);
        line.SetColor(Color.oldgloryred);
        line.SetAltDescription("This is a red line.");
        line.SetActualText("This is a red line.");
        line.DrawOn(page);

        box = new Box();
        box.SetLineWidth(1f);
        box.SetLocation(70f, 200f);
        box.SetSize(100f, 100f);
        box.SetColor(Color.oldgloryblue);
        box.SetAltDescription("This is a blue box.");
        box.SetActualText("This is a blue box.");
        box.DrawOn(page);

        page.AddBMC("Span", "This is a test", "This is a test");
        page.DrawString(f1, "This is a test", 75f, 230f);
        page.AddEMC();

        Image image = new Image(
            pdf,
            new BufferedStream(new FileStream(
                                   "images/fruit.jpg", FileMode.Open, FileAccess.Read)),
            ImageType.JPG);

        image.SetLocation(70f, 310f);
        image.ScaleBy(0.5f);
        image.SetAltDescription("This is an image of a strawberry.");
        image.SetActualText("This is an image of a strawberry.");
        image.DrawOn(page);

        float w = 530f;
        float h = 13f;

        List <Field> fields = new List <Field>();

        fields.Add(new Field(0f, new String[] { "Company", "Smart Widget Designs" }));
        fields.Add(new Field(0f, new String[] { "Street Number", "120" }));
        fields.Add(new Field(w / 8, new String[] { "Street Name", "Oak" }));
        fields.Add(new Field(5 * w / 8, new String[] { "Street Type", "Street" }));
        fields.Add(new Field(6 * w / 8, new String[] { "Direction", "West" }));
        fields.Add(new Field(7 * w / 8, new String[] { "Suite/Floor/Apt.", "8W" })
                   .SetAltDescription("Suite/Floor/Apartment")
                   .SetActualText("Suite/Floor/Apartment"));
        fields.Add(new Field(0f, new String[] { "City/Town", "Toronto" }));
        fields.Add(new Field(w / 2, new String[] { "Province", "Ontario" }));
        fields.Add(new Field(7 * w / 8, new String[] { "Postal Code", "M5M 2N2" }));
        fields.Add(new Field(0f, new String[] { "Telephone Number", "(416) 331-2245" }));
        fields.Add(new Field(w / 4, new String[] { "Fax (if applicable)", "(416) 124-9879" }));
        fields.Add(new Field(w / 2, new String[] { "Email", "*****@*****.**" }));
        fields.Add(new Field(0f, new String[] { "Other Information",
                                                "We don't work on weekends.", "Please send us an Email." }));

// TODO:
        new Form(fields)
        .SetLabelFont(f1)
        .SetLabelFontSize(7f)
        .SetValueFont(f2)
        .SetValueFontSize(9f)
        .SetLocation(70f, 490f)
        .SetRowLength(w)
        .SetRowHeight(h)
        .DrawOn(page);

        pdf.Complete();
    }
Example #25
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            bs.Clear();
            int  fromMonth  = dtFrom.Value.Month - 2;
            int  toMonth    = dtTo.Value.Month - 2;
            bool thisYear   = IsThisYear();
            int  periodYear = (thisYear ? 112 : 12);

            if (fromMonth == 1 && thisYear)
            {
                fromMonth = 13;
            }
            if (toMonth == 1 && thisYear)
            {
                toMonth = 13;
            }
            int           sPeriod      = (fromMonth <= 0 ? periodYear + fromMonth : 100 + fromMonth);
            int           ePeriod      = (toMonth <= 0 ? periodYear + toMonth : 100 + toMonth);
            List <Trns>   transactions = new List <Trns>();
            double        trnBal       = 0;
            double        remBal       = 0;
            List <string> btmsg        = new List <string>();

            if (selectedBuilding.ID == 0)
            {
                Dictionary <String, List <Trns> > buildingTrans = new Dictionary <string, List <Trns> >();
                foreach (Building b in BuildingManager.buildings)
                {
                    if (b.ID != 0 && b.Web_Building)
                    {
                        transactions = LoadBuildingTransactions(sPeriod, ePeriod, fromMonth, b.Trust);
                        btmsg.Add(b.Name + " = " + transactions.Count.ToString());
                        if (transactions.Count > 2)
                        {
                            buildingTrans.Add(b.Name, transactions);
                        }
                    }
                }
                if (Controller.user.id == 1)
                {
                    // MessageBox.Show(String.Join(";", btmsg));
                }

                String pdfFile = new PDF().TrustMovement(buildingTrans);
                if (!String.IsNullOrEmpty(pdfFile))
                {
                    try
                    {
                        System.Diagnostics.Process.Start(pdfFile);
                    }
                    catch
                    {
                        MessageBox.Show("File " + pdfFile + " is in use. Please close and try again.");
                    }
                }
                else
                {
                    MessageBox.Show("No file created. Please try again.");
                }
            }
            else
            {
                //List<Trns> bTrans = LoadTransactions(sPeriod, ePeriod, selectedBuilding.Trust, out remBal, out trnBal);
                //double openingBalance = GetBalance(selectedBuilding.Trust, fromMonth - 1) + remBal; //- selectedBuilding.Period
                //Trns openingTrns = new Trns
                //{
                //    Amount = openingBalance.ToString("#0.00"),
                //    Date = dtFrom.Value.AddDays(-1).ToString("yyyy/MM/dd"),
                //    Description = "Opening Balance",
                //    Reference = ""
                //};
                //transactions.Add(openingTrns);
                //transactions.AddRange(bTrans);
                //Trns closingTrns = new Trns
                //{
                //    Amount = (openingBalance + trnBal).ToString("#0.00"),
                //    Date = dtTo.Value.ToString("yyyy/MM/dd"),
                //    Description = "Closing Balance",
                //    Reference = ""
                //};
                //transactions.Add(closingTrns);
                transactions = LoadBuildingTransactions(sPeriod, ePeriod, fromMonth, selectedBuilding.Trust);
            }
            transactions = transactions.OrderBy(t => t.Date).ToList();
            foreach (Trns t in transactions)
            {
                bs.Add(t);
            }
        }
    public static double log_normal_truncated_ab_cdf(double x, double mu, double sigma,
                                                     double a, double b)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LOG_NORMAL_TRUNCATED_AB_CDF evaluates the Log Normal truncated AB CDF.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    27 March 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, double X, the argument of the PDF.
    //    0.0 < X.
    //
    //    Input, double MU, SIGMA, the parameters of the PDF.
    //    0.0 < SIGMA.
    //
    //    Input, double A, B, the lower and upper truncation limits.
    //    A < B.
    //
    //    Output, double LOG_NORMAL_TRUNCATED_AB_CDF, the value of the CDF.
    //
    {
        double cdf;

        bool check = PDF.log_normal_truncated_ab_check(mu, sigma, a, b);

        switch (check)
        {
        case false:
            Console.WriteLine("");
            Console.WriteLine("LOG_NORMAL_TRUNCATED_AB_CDF - Fatal error!");
            Console.WriteLine("  Parameters are not legal.");
            return(1);
        }

        if (x <= a)
        {
            cdf = 0.0;
        }
        else if (b <= x)
        {
            cdf = 1.0;
        }
        else
        {
            double lncdf_a = log_normal_cdf(a, mu, sigma);
            double lncdf_b = log_normal_cdf(b, mu, sigma);
            double lncdf_x = log_normal_cdf(x, mu, sigma);

            cdf = (lncdf_x - lncdf_a) / (lncdf_b - lncdf_a);
        }

        return(cdf);
    }
Example #27
0
    public Example_34()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_34.pdf", FileMode.Create)), Compliance.PDF_A_1B);

        Page page = new Page(pdf, Letter.PORTRAIT);

        Font f1 = new Font(pdf, CoreFont.HELVETICA_BOLD);

        f1.SetSize(7f);

        Font f2 = new Font(pdf, CoreFont.HELVETICA);

        f2.SetSize(7f);

        Font f3 = new Font(pdf, CoreFont.HELVETICA_BOLD_OBLIQUE);

        f3.SetSize(7f);


        Table table = new Table();
        List <List <Cell> > tableData = GetData(
            "data/world-communications.txt", "|", Table.DATA_HAS_2_HEADER_ROWS, f1, f2);

        Point p1 = new Point();

        p1.SetShape(Point.CIRCLE);
        p1.SetRadius(2f);
        p1.SetColor(Color.darkolivegreen);
        p1.SetFillShape(true);
        p1.SetAlignment(Align.RIGHT);
        p1.SetURIAction("https://en.wikipedia.org/wiki/India");
        tableData[4][3].SetPoint(p1);

        p1 = new Point();
        p1.SetShape(Point.DIAMOND);
        p1.SetRadius(2.5f);
        p1.SetColor(Color.blue);
        p1.SetFillShape(true);
        p1.SetAlignment(Align.RIGHT);
        p1.SetURIAction("https://en.wikipedia.org/wiki/European_Union");
        tableData[5][3].SetPoint(p1);

        p1 = new Point();
        p1.SetShape(Point.STAR);
        p1.SetRadius(3f);
        p1.SetColor(Color.red);
        p1.SetFillShape(true);
        p1.SetAlignment(Align.RIGHT);
        p1.SetURIAction("https://en.wikipedia.org/wiki/United_States");
        tableData[6][3].SetPoint(p1);

        table.SetData(tableData, Table.DATA_HAS_2_HEADER_ROWS);
        // table.SetCellBordersWidth(1.2f);
        table.SetCellBordersWidth(0.2f);
        table.SetLocation(70f, 30f);
        table.SetTextColorInRow(6, Color.blue);
        table.SetTextColorInRow(39, Color.red);
        table.SetFontInRow(26, f3);
        table.RemoveLineBetweenRows(0, 1);
        table.AutoAdjustColumnWidths();
        table.SetColumnWidth(0, 120f);
        table.RightAlignNumbers();
        int numOfPages = table.GetNumberOfPages(page);

        while (true)
        {
            table.DrawOn(page);
            // TO DO: Draw "Page 1 of N" here
            if (!table.HasMoreData())
            {
                // Allow the table to be drawn again later:
                table.ResetRenderedPagesCount();
                break;
            }
            page = new Page(pdf, Letter.PORTRAIT);
        }

        pdf.Close();
    }
Example #28
0
 private void btnKreirajPDF_Click(object sender, EventArgs e)
 {
     PDF.KreirajPDF(rptZaliheViewer);
 }
Example #29
0
    public static int cr_index_choose(int cr_num, double[] cr_prob)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CR_INDEX_CHOOSE chooses a CR index.
    //
    //  Discussion:
    //
    //    Index I is chosen with probability CR_PROB(I).
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    01 May 2013
    //
    //  Author:
    //
    //    Original FORTRAN90 version by Guannan Zhang.
    //    C++ version by John Burkardt.
    //
    //  Parameters:
    //
    //    Input, int CR_NUM, the total number of CR values.
    //    1 <= CR_NUM.
    //
    //    Input, double CR_PROB[CR_NUM], the probability of each CR.
    //
    //    Output, int CR_INDEX_CHOOSE, the index of the CR.
    //    0 <= CR_INDEX_CHOOSE < CR_NUM.
    //
    {
        int cr_index = 0;

        switch (cr_num)
        {
        case 1:
            cr_index = 0;
            break;

        default:
        {
            const int n         = 1;
            int[]     tmp_index = PDF.i4vec_multinomial_sample(n, cr_prob, cr_num);

            int i;
            for (i = 0; i < cr_num; i++)
            {
                if (tmp_index[i] != 1)
                {
                    continue;
                }

                cr_index = i;
                break;
            }

            break;
        }
        }

        return(cr_index);
    }
Example #30
0
        public string getHTML(PDF pdf)
        {
            string htmlMassnahmen = Rtf.ToHtml(pdf.beschreibungMassnahme.Rtf);

            htmlMassnahmen = reduceRtfFormatting(htmlMassnahmen);

            string html = "";

            html = $@"
            <div style='position: fixed; left: 150px; top: 810px; width:65% '>
            <p style='font-size: 8px; '>Eictronic GmbH -Sitz: 37339 Berlingerode - Amtsgericht Jena - HRB 513528 - Geschäftsführer: Jörg Boden Steuernummer: 157 / 208 / 08940  UST - ID - Nr.: DE 251137789 Finanzamt Mühlhausen</p>
            </div>         
            <p style='font-size: 12px; ' >
                Eictronic GmbH, Gasse 25, 37339 Berlingerode
            </p>
            <table>
                <tr>
                    <td valign: top>
                    {pdf.empfaenger.AnsprechpartnerVorname} {pdf.empfaenger.AnsprechpartnerName}
                  </td>
                </tr>
                  <tr>
                    <td valign: top>
                    {pdf.empfaenger.Firma}  
                  </td>
                </tr>
                  <tr>
                    <td valign: top>
                    {pdf.empfaenger.Bereich}
                  </td>
                </tr>
                  <tr>
                    <td valign: top>
                    {pdf.empfaenger.Straße}
                  </td>
                </tr>
                <tr>
                    <td valign: top>
                    {pdf.empfaenger.PLZ} {pdf.empfaenger.Ort}
                  </td>
                </tr>
            </table>
            <table style='margin-top: 30px; '>
                <tr>
                    <td valign: top>
                    Aufragsnummer:
                  </td>
                  <td>
                    {pdf.auftrag.SMNummer} (bei Rückfragen bitte immer angeben)
                  </td>
                </tr>
                  <tr>
                    <td valign: top>
                    Ansprechpartner:    
                  </td>
                  <td>
                    {pdf.ansprechpartner.BearbeiterVorname} {pdf.ansprechpartner.BearbeiterName}, {pdf.ansprechpartner.Telefon}, {pdf.ansprechpartner.Email}
                  </td>
                </tr>
                  <tr>
                    <td valign= top>
                    Datum:
                  </td>
                  <td>
                    {pdf.datum.ToString("dd.MM.yyyy")}
                  </td>
                </tr>
                  <tr>
                    <td valign=top >
                    Betreff:
                  </td>
                  <td>
                    Zustimmung des Trägers der Wegebaulast nach §68 Telekommunikationsgesetz (TKG)
                  </td>
                </tr>
                </table>
                ";
            //ort der Maßnahmen
            html += $@"
                <table style='width:100%; margin-top:15px'>
                <tr>
                    <td style='valign: top; width:20%'>
                    Bauvorhaben:
                  </td>
                  <td>
                    {pdf.ortDerMassnahme}
                  </td>
                </tr>
                </table>
                ";
            //anschreiben
            html += $@"
            <div id='anschreiben'>
                <p>
                    Sehr geehrte Damen und Herren,
                    </br>
                    </br>
                    die Telekom Deutschland GmbH beabsichtigt nach den beiliegenden Plänen ihre </br>
                    Telekommunikationslinien zu ändern/zu erweitern.</br>
                    Dazu hat sie uns, die Eictronic GmbH beauftragt und bevollmächtigt die Aufgaben der Planung</br>
                    und Wegesicherung wahrzunehmen.
                </p>
            </div>
            
            <table style='width: 100%; margin-top:30px'>
                 <tr>
                    <td  valign=top style=' width:20%'>
                      Baubeschreibung:
                  </td>
                </tr>
                <tr>
                  <td valign=top>
                    {htmlMassnahmen}
                  </td>
                </tr>
            </table>
            <table style='page-break-inside: avoid'>
                <tr>
                    <td>
                            Wir bitten Sie, die Zustimmung gemäß § 68 Abs. 3 Satz 1 TKG zugunsten der Telekom
                            Deutschland GmbH (Reg-Nr.: 93/007 nach § 6 TKG) als Nutzungsberechtigte nach § 68 Abs. 1 i. V. m. § 69 Abs. 1 TKG zu erteilen.  Bitte senden Sie die Zustimmung unter Angabe der im Betreff 
                            genannten SM-Nr. an:</br></br></br>
                  </td>
                </tr>
                <tr>
                    <td>
                    <b>{pdf.wesiTeam.Firma}</b>
                  </td>
                </tr>
                <tr>
                    <td>
                    <b>{pdf.wesiTeam.Niederlassung}</b>
                  </td>
                </tr>
                <tr>
                    <td>
                    <b>{pdf.wesiTeam.Bereich}</b>
                  </td>
                </tr>
                <tr>
                    <td>
                    <b>{pdf.wesiTeam.Strasse}</b>
                  </td>
                </tr>
                <tr>
                    <td>
                        <b>{pdf.wesiTeam.PLZ} {pdf.wesiTeam.Stadt}</b>
                  </td>
                </tr>
                </table>
                <table style='width:100%; page-break-inside: avoid'>
                <tr>
                <td>
            <p>
                Rechtzeitig vor Baubeginn wird Ihnen der genaue Ausführungszeitraum sowie die mit den Arbeiten beauftragte Firma schriftlich mitgeteilt (Baubeginnanzeige).
            </p>
            <p>
            Vorraussichtllicher Ausführungszeitraum: {pdf.ausfuehrungszeitraum.ToString("MMMM yyyy")}
            ";
            if (pdf.ausfuehrungszeitraum.Month != pdf.ausfuehrungszeitraumEnde.Month || pdf.ausfuehrungszeitraum.Year != pdf.ausfuehrungszeitraumEnde.Year)
            {
                html += $@" bis {pdf.ausfuehrungszeitraumEnde.ToString("MMMM yyyy")}";
            }
            html += $@"
            <p>
                Falls bei der Bauausführung Ihre Belange betroffen sind, bitten wir um deren Angabe und um Beifügung von Plänen der betroffenen Anlagen.</br>
            </p>

            <p style='margin-top:30px'>
                Für Rückfragen stehen wir Ihnen gern zur Verfügung
            </p>


                <p style='margin-top:60px'>
                    Mit freundlichen Grüßen:
                </p>
                <p>
                    i.A. {pdf.ansprechpartner.BearbeiterVorname} {pdf.ansprechpartner.BearbeiterName}
                </p>
                </td>
                </tr>
                </table>
                <p>
                    Anlagen:
                </p>
            ";

            foreach (string s in pdf.Zusatzanlagen)
            {
                html += "<p>" + s + "</p>";
            }



            return(html);
        }
    public Example_03()
    {
        FileStream fos = new FileStream("Example_03.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        // Before you enable this flag please read README.ZLIB.TXT
        // in the 'optional' directory.

        //        Font f1 = new Font(pdf, "Helvetica");
        /*
        Font f1 = new Font(pdf, new FileStream(
                "fonts/DroidFonts/DroidSans.otf", FileMode.Open),
                CodePage.UNICODE,
                Embed.YES);
        */
        String fileName = "images/eu-map.png";
        FileStream fis1 = new FileStream(fileName, FileMode.Open);
        Image image1 = new Image(pdf, fis1, ImageType.PNG);

        fileName = "images/fruit.jpg";
        FileStream fis2 = new FileStream(fileName, FileMode.Open);
        Image image2 = new Image(pdf, fis2, ImageType.JPEG);

        fileName = "images/mt-map.bmp";
        FileStream fis3 = new FileStream(fileName, FileMode.Open);
        Image image3 = new Image(pdf, fis3, ImageType.BMP);

        Page page = new Page(pdf, A4.PORTRAIT);
        /*
        TextLine text = new TextLine(f1,
                "The map below is an embedded PNG image");
        text.SetPosition(90, 30);
        text.DrawOn(page);
        */
        image1.SetPosition(90, 40);
        image1.DrawOn(page);
        /*
        text.SetText(
                "JPG image file embedded once and drawn 3 times");
        text.SetPosition(90, 550);
        text.DrawOn(page);
        */
        image2.SetPosition(90, 560);
        image2.ScaleBy(0.5);
        image2.DrawOn(page);

        image2.SetPosition(260, 560);
        image2.ScaleBy(0.5);
        image2.DrawOn(page);

        image2.SetPosition(350, 560);
        image2.ScaleBy(0.5);
        image2.DrawOn(page);
        /*
        text.SetText(
                "The map on the right is an embedded BMP image");
        text.SetUnderline(true);
        text.SetStrikeLine(true);
        text.SetTextDirection(15);
        text.SetPosition(90, 800);
        text.DrawOn(page);
        */
        image3.SetPosition(390, 630);
        image3.ScaleBy(0.5);
        image3.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }
        //---------------------------------

        //GET => MyInvoices/Download/5
        public IActionResult Download(int id)
        {
            PDF pdf = new PDF(_context, _env);

            return(pdf.CreatePDF(id));
        }
Example #33
0
            public static double Integrate1D(PDF pdf, double lower, double upper, int pieces, double[] partial_arg)
            {
                double[] tmparg = new double[partial_arg.Length + 1];
                double integral = 0;
                for (int i = 0; i < partial_arg.Length; i++) { tmparg[i + 1] = partial_arg[i]; }
                //this can be optimized a bit but meh.
                for (int i = 0; i < pieces; i++)
                {
                    double width = (upper - lower) / (pieces);
                    double h = width / 3.0;
                    double x0 = lower + width * i;
                    double x1 = x0 + h;
                    double x2 = x0 + 2.0 * h;
                    double x3 = x0 + 3.0 * h;

                    tmparg[0] = x0;
                    double y0 = pdf(tmparg);
                    tmparg[0] = x1;
                    double y1 = pdf(tmparg);
                    tmparg[0] = x2;
                    double y2 = pdf(tmparg);
                    tmparg[0] = x3;
                    double y3 = pdf(tmparg);

                    integral += 3.0 * h / 8.0 * (y0 + 3 * y1 + 3 * y2 + y3);
                }
                return integral;
            }
Example #34
0
    public static IDocument CreateDocument(string command)
    {
        string[] splittedCommand = command.Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);

        if (splittedCommand.Length > 1)
        {
            string[] splittedParamethers = splittedCommand[1].Split(new char[] { '=', ';' }, StringSplitOptions.RemoveEmptyEntries);

            switch (splittedCommand[0])
            {
            case "AddTextDocument":
            {
                for (int i = 0; i < splittedParamethers.Length; i += 2)
                {
                    if (splittedParamethers[i] == "name")
                    {
                        TextDocument myDoc = new TextDocument(splittedParamethers[i + 1]);

                        for (int j = 0; j < splittedParamethers.Length; j += 2)
                        {
                            if (splittedParamethers[j] != "name")
                            {
                                myDoc.LoadProperty(splittedParamethers[j], splittedParamethers[j + 1]);
                            }
                        }

                        return(myDoc);
                    }
                }
                return(null);
            }

            case "AddPDFDocument":
            {
                for (int i = 0; i < splittedParamethers.Length; i += 2)
                {
                    if (splittedParamethers[i] == "name")
                    {
                        PDF myDoc = new PDF(splittedParamethers[i + 1]);

                        for (int j = 0; j < splittedParamethers.Length; j += 2)
                        {
                            if (splittedParamethers[j] != "name")
                            {
                                myDoc.LoadProperty(splittedParamethers[j], splittedParamethers[j + 1]);
                            }
                        }

                        return(myDoc);
                    }
                }
                return(null);
            }

            case "AddWordDocument":
            {
                for (int i = 0; i < splittedParamethers.Length; i += 2)
                {
                    if (splittedParamethers[i] == "name")
                    {
                        Word myDoc = new Word(splittedParamethers[i + 1]);

                        for (int j = 0; j < splittedParamethers.Length; j += 2)
                        {
                            if (splittedParamethers[j] != "name")
                            {
                                myDoc.LoadProperty(splittedParamethers[j], splittedParamethers[j + 1]);
                            }
                        }

                        return(myDoc);
                    }
                }
                return(null);
            }

            case "AddExcelDocument":
            {
                for (int i = 0; i < splittedParamethers.Length; i += 2)
                {
                    if (splittedParamethers[i] == "name")
                    {
                        Excel myDoc = new Excel(splittedParamethers[i + 1]);

                        for (int j = 0; j < splittedParamethers.Length; j += 2)
                        {
                            if (splittedParamethers[j] != "name")
                            {
                                myDoc.LoadProperty(splittedParamethers[j], splittedParamethers[j + 1]);
                            }
                        }

                        return(myDoc);
                    }
                }
                return(null);
            }

            case "AddAudioDocument":
            {
                for (int i = 0; i < splittedParamethers.Length; i += 2)
                {
                    if (splittedParamethers[i] == "name")
                    {
                        Audio myDoc = new Audio(splittedParamethers[i + 1]);

                        for (int j = 0; j < splittedParamethers.Length; j += 2)
                        {
                            if (splittedParamethers[j] != "name")
                            {
                                myDoc.LoadProperty(splittedParamethers[j], splittedParamethers[j + 1]);
                            }
                        }

                        return(myDoc);
                    }
                }
                return(null);
            }

            case "AddVideoDocument":
            {
                for (int i = 0; i < splittedParamethers.Length; i += 2)
                {
                    if (splittedParamethers[i] == "name")
                    {
                        Video myDoc = new Video(splittedParamethers[i + 1]);

                        for (int j = 0; j < splittedParamethers.Length; j += 2)
                        {
                            if (splittedParamethers[j] != "name")
                            {
                                myDoc.LoadProperty(splittedParamethers[j], splittedParamethers[j + 1]);
                            }
                        }

                        return(myDoc);
                    }
                }
                return(null);
            }

            default:
            {
                return(null);
            }
            }
        }
        else
        {
            return(null);
        }
    }
Example #35
0
            public Chi2(PDF pdf, double[] x, double[] y, double[] sigma = null)
            {
                Debug.Assert(x.Length == y.Length);
                if (sigma == null)
                {
                    sigma = NP.Ones(x.Length);
                }
                Debug.Assert(x.Length == sigma.Length);

                this.x = x;
                this.y = y;
                this.sigma = sigma;
                this.pdf = pdf;
            }
 private static void AddPdfDocument(string[] attributes)
 {
     Document doc = new PDF();
     CreateDocument(attributes, doc);
 }
Example #37
0
 private void button1_Click(object sender, EventArgs e)
 {
     pdf = new PDF();
     pdf.DocPDF("Turno VS-6", "Ticket VS-6");
 }
Example #38
0
    public Example_28()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_28.pdf", FileMode.Create)));

        Font f1 = new Font(pdf, new BufferedStream(
                               new FileStream(
                                   "fonts/Droid/DroidSans.ttf", FileMode.Open, FileAccess.Read)));

        Font f2 = new Font(pdf,
                           new FileStream(
                               "fonts/Droid/DroidSansFallback.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read), Font.STREAM);

        Font f3 = new Font(pdf,
                           new FileStream(
                               "fonts/Noto/NotoSansSymbols-Regular-Subsetted.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read), Font.STREAM);

        f1.SetSize(11f);
        f2.SetSize(11f);
        f3.SetSize(11f);

        Page page = new Page(pdf, Letter.LANDSCAPE);

        StreamReader reader = new StreamReader(
            new FileStream("data/report.csv", FileMode.Open));

        float  y   = 40f;
        String str = null;

        while ((str = reader.ReadLine()) != null)
        {
            new TextLine(f1, str)
            .SetFallbackFont(f2)
            .SetLocation(50f, y += 20f)
            .DrawOn(page);
        }
        reader.Close();

        float x = 50f;

        y = 210f;
        float dy = 22f;

        TextLine      text  = new TextLine(f3);
        StringBuilder buf   = new StringBuilder();
        int           count = 0;

        for (int i = 0x2200; i <= 0x22FF; i++)
        {
            // Draw the Math Symbols
            if (count % 80 == 0)
            {
                text.SetText(buf.ToString());
                text.SetLocation(x, y += dy);
                text.DrawOn(page);
                buf.Length = 0;
            }
            buf.Append((char)i);
            count++;
        }
        text.SetText(buf.ToString());
        text.SetLocation(x, y += dy);
        text.DrawOn(page);
        buf.Length = 0;

        count = 0;
        for (int i = 0x25A0; i <= 0x25FF; i++)
        {
            // Draw the Geometric Shapes
            if (count % 80 == 0)
            {
                text.SetText(buf.ToString());
                text.SetLocation(x, y += dy);
                text.DrawOn(page);
                buf.Length = 0;
            }
            buf.Append((char)i);
            count++;
        }
        text.SetText(buf.ToString());
        text.SetLocation(x, y += dy);
        text.DrawOn(page);
        buf.Length = 0;

        count = 0;
        for (int i = 0x2701; i <= 0x27ff; i++)
        {
            // Draw the Dingbats
            if (count % 80 == 0)
            {
                text.SetText(buf.ToString());
                text.SetLocation(x, y += dy);
                text.DrawOn(page);
                buf.Length = 0;
            }
            buf.Append((char)i);
            count++;
        }
        text.SetText(buf.ToString());
        text.SetLocation(x, y += dy);
        text.DrawOn(page);
        buf.Length = 0;

        count = 0;
        for (int i = 0x2800; i <= 0x28FF; i++)
        {
            // Draw the Braille Patterns
            if (count % 80 == 0)
            {
                text.SetText(buf.ToString());
                text.SetLocation(x, y += dy);
                text.DrawOn(page);
                buf.Length = 0;
            }
            buf.Append((char)i);
            count++;
        }
        text.SetText(buf.ToString());
        text.SetLocation(x, y);
        text.DrawOn(page);

        pdf.Close();
    }
Example #39
0
        public bool Gera(DataGridView grid, string arquivo, bool idtI, DateTime dataI, bool idtF, DateTime dataF, string titulo)
        {
            /*
             * FbCommand cmd;
             * FbDataReader reader;
             *
             * cmd =  new FbCommand("select " +
             *                   "a.NRO_NF," +
             *                   "a.SEQ_TITULO," +
             *                   "a.COD_CLIENTE," +
             *                   "b.DES_NATUREZA," +
             *                   "a.DAT_EMISSAO," +
             *                   "a.DAT_VENCIMENTO," +
             *                   "a.VLR_PREVISTO," +
             *                   "a.VLR_RECEBIDO," +
             *                   "a.DAT_RECEBIMENTO," +
             *                   "c.DES_FORMA," +
             *                   "a.TXT_OBSERVACAO " +
             *                                       "from TITULOS_RECEBER a " +
             *                                       "left outer join NATUREZAS_RECEBIMENTO b " +
             *                                       "on b.COD_NATUREZA = a.COD_NATUREZA " +
             *                                       "left outer join FORMAS_RECEBIMENTO c " +
             *                                       "on c.COD_FORMA = a.COD_FORMA " +
             *                   where + " " +
             *                   "order by a.DAT_VENCIMENTO",
             *                   Globais.bd);
             * reader = cmd.ExecuteReader(CommandBehavior.Default);
             */

            PDF pdf = new PDF(arquivo);

            pdf.Abre();

            /*
             * pdf.CriaTabela(2, 0);
             * pdf.AdicionaCelula("imagens\\logo_rel.jpg", 1000, 1000);
             * pdf.AdicionaCelula(titulo, BaseFont.HELVETICA_BOLD, 16);
             * pdf.AdicionaTabela();
             */
            Parte1(pdf, titulo);

            pdf.CriaTabela(11, 0);

            pdf.AdicionaCelula("Responsável", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);
            pdf.AdicionaCelula("Previsão", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);
            pdf.AdicionaCelula("Realização", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 1);
            pdf.AdicionaCelula("Usuário", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 3);
            pdf.AdicionaCelula("Pri", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 1);
            pdf.AdicionaCelula("Natureza", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);

            pdf.AdicionaCelula("", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);
            pdf.AdicionaCelula("Parceiro", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 3);
            pdf.AdicionaCelula("Endereço", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 4);
            pdf.AdicionaCelula("Fone", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);

            pdf.AdicionaCelula("", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);
            pdf.AdicionaCelula("Contato", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 3);
            pdf.AdicionaCelula("Papel", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 4);
            pdf.AdicionaCelula("Fone", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);

            pdf.AdicionaCelula("", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);
            pdf.AdicionaCelula("Descrição", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 9);

            pdf.AdicionaCelulaLinha("", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 2);
            pdf.AdicionaCelulaLinha("Solução", BaseFont.HELVETICA_BOLD, 6, /*Color.LIGHT_GRAY,*/ Element.ALIGN_LEFT, 9);

            foreach (DataGridViewRow row in  grid.Rows)
            {
                DateTime data = DateTime.Parse(row.Cells["Data"].Value.ToString());
                if (idtI && (data.Date < dataI.Date))
                {
                    continue;
                }
                if (idtF && (data.Date > dataF.Date))
                {
                    continue;
                }

                data = DateTime.Parse(row.Cells["Data"].Value.ToString());
                pdf.AdicionaCelula(row.Cells["Responsável"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                pdf.AdicionaCelula(data.ToString("d/M/yyyy HH:mm"), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                if ((row.Cells["Data Solução"].Value != null) && (!row.Cells["Data Solução"].Value.ToString().Trim().Equals("")))
                {
                    data = DateTime.Parse(row.Cells["Data Solução"].Value.ToString());
                    pdf.AdicionaCelula(data.ToString("d/M/yyyy"), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 1);
                }
                else
                {
                    pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 1);
                }
                pdf.AdicionaCelula(row.Cells["Usuário"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 3);
                switch (row.Cells["Prioridade"].Value.ToString()[0])
                {
                case '0': pdf.AdicionaCelula("Urgente", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 1); break;

                case '1': pdf.AdicionaCelula("Importante", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 1); break;

                case '2': pdf.AdicionaCelula("Normal", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 1); break;
                }
                pdf.AdicionaCelula(row.Cells["Natureza"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);


                pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                if (row.Cells["Razão"].Value != null)
                {
                    pdf.AdicionaCelula(row.Cells["Razão"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 3);
                }
                else
                {
                    pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                }
                string endereco = "";
                if ((row.Cells["RuaEntrega"].Value != null) && (!row.Cells["RuaEntrega"].Value.ToString().Trim().Equals("")))
                {
                    endereco = row.Cells["RuaEntrega"].Value.ToString().Trim() + " - " +
                               row.Cells["NroEntrega"].Value.ToString().Trim() + " - " +
                               row.Cells["ComplEntrega"].Value.ToString().Trim() + " - " +
                               row.Cells["BairroEntrega"].Value.ToString().Trim();
                }
                else
                {
                    endereco = row.Cells["Rua"].Value.ToString().Trim() + " - " +
                               row.Cells["Nro"].Value.ToString().Trim() + " - " +
                               row.Cells["Compl"].Value.ToString().Trim() + " - " +
                               row.Cells["Bairro"].Value.ToString().Trim();
                }
                pdf.AdicionaCelula(endereco, BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 4);

                string fones = FONES.Concatena(row.Cells["Fone"].Value, row.Cells["Celular"].Value);
                pdf.AdicionaCelula(fones, BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);

                pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                if (row.Cells["NomeContato"].Value != null)
                {
                    pdf.AdicionaCelula(row.Cells["NomeContato"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 3);
                    pdf.AdicionaCelula(row.Cells["Papel"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 4);

                    fones = FONES.Concatena(row.Cells["FoneContato"].Value, row.Cells["CelularContato"].Value);
                    pdf.AdicionaCelula(fones, BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                }
                else
                {
                    pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 9);
                }

                pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                pdf.AdicionaCelula(row.Cells["Pendência"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 9);

                pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 2);
                if (row.Cells["Solução"].Value != null)
                {
                    pdf.AdicionaCelula(row.Cells["Solução"].Value.ToString().Trim(), BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 9);
                }
                else
                {
                    pdf.AdicionaCelula("", BaseFont.HELVETICA, 6, Element.ALIGN_LEFT, 9);
                }

                pdf.AdicionaTabela();

                pdf.CriaTabela(128, 0);
                for (int i = 0; i < 128; i++)
                {
                    Cell cell = new Cell(new Paragraph(""));
                    cell.BorderWidthBottom = i % 2;
                    pdf.tabela.AddCell(cell);
                }

                pdf.AdicionaTabela();
                pdf.CriaTabela(11, 0);
            }
            pdf.AdicionaTabela();
            pdf.Fecha();
            return(true);
        }
Example #40
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction, PDF pdf)
        {
            SqlConnection  connection  = sqlConnection;
            SqlTransaction transaction = sqlTransaction;

            if (connection == null)
            {
                connection =
                    CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"));
            }

            bool isTransactionCoordinator = CustomSqlHelper.IsTransactionCoordinator(transaction);

            try
            {
                transaction = CustomSqlHelper.BeginTransaction(connection, transaction, isTransactionCoordinator);

                new PDFDAL().PDFManageAuto(connection, transaction, pdf);

                CustomSqlHelper.CommitTransaction(transaction, isTransactionCoordinator);
            }
            catch (Exception ex)
            {
                CustomSqlHelper.RollbackTransaction(transaction, isTransactionCoordinator);

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Example #41
0
    public Example_35()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_35.pdf", FileMode.Create)));

        Page page = new Page(pdf, Letter.PORTRAIT);

        // Font f1 = new Font(pdf, CoreFont.HELVETICA_BOLD);
        Font f1 = new Font(pdf, new FileStream(
                               "fonts/OpenSans/OpenSans-Bold.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read),
                           Font.STREAM);

        f1.SetSize(8f);

        // Font f2 = new Font(pdf, CoreFont.HELVETICA);
        Font f2 = new Font(pdf, new FileStream(
                               "fonts/OpenSans/OpenSans-Regular.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read),
                           Font.STREAM);

        f2.SetSize(8f);

        List <List <Point> > chartData = new List <List <Point> >();

        List <Point> path1 = new List <Point>();

        path1.Add(new Point(50f, 50f).SetDrawPath().SetColor(Color.blue));
        path1.Add(new Point(55f, 55f));
        path1.Add(new Point(60f, 60f));
        path1.Add(new Point(65f, 58f));
        path1.Add(new Point(70f, 59f));
        path1.Add(new Point(75f, 63f));
        path1.Add(new Point(80f, 65f));
        chartData.Add(path1);

        List <Point> path2 = new List <Point>();

        path2.Add(new Point(50f, 30f).SetDrawPath().SetColor(Color.red));
        path2.Add(new Point(55f, 35f));
        path2.Add(new Point(60f, 40f));
        path2.Add(new Point(65f, 48f));
        path2.Add(new Point(70f, 49f));
        path2.Add(new Point(75f, 53f));
        path2.Add(new Point(80f, 55f));
        chartData.Add(path2);

        List <Point> path3 = new List <Point>();

        path3.Add(new Point(50f, 80f).SetDrawPath().SetColor(Color.green));
        path3.Add(new Point(55f, 70f));
        path3.Add(new Point(60f, 60f));
        path3.Add(new Point(65f, 55f));
        path3.Add(new Point(70f, 59f));
        path3.Add(new Point(75f, 63f));
        path3.Add(new Point(80f, 61f));
        chartData.Add(path3);

        Chart chart = new Chart(f1, f2);

        chart.SetData(chartData);
        chart.SetLocation(70f, 50f);
        chart.SetSize(500f, 300f);
        chart.SetTitle("Chart Title");
        chart.SetXAxisTitle("X Axis Title");
        chart.SetYAxisTitle("Y Axis Title");

        // You can adjust the X and Y min and max manually:
        // chart.SetXAxisMinMax(45f, 80f, 7);
        // chart.SetYAxisMinMax(20f, 80f, 6);
        chart.DrawOn(page);

        pdf.Complete();
    }
    public Example_02()
    {
        FileStream fos = new FileStream("Example_02.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Page page = new Page(pdf, Letter.PORTRAIT);

        Box flag = new Box(85, 85, 64, 32);

        PDFjet.NET.Path path = new PDFjet.NET.Path();
        path.Add(new Point(13.0,  0.0));
        path.Add(new Point(15.5,  4.5));
        path.Add(new Point(18.0,  3.5));

        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(20.5,  7.5, Point.IS_CURVE_POINT));

        path.Add(new Point(21.0,  9.5));
        path.Add(new Point(25.0,  9.0));
        path.Add(new Point(24.0, 13.0));
        path.Add(new Point(25.5, 14.0));
        path.Add(new Point(19.0, 19.0));
        path.Add(new Point(20.0, 21.5));
        path.Add(new Point(13.5, 20.5));
        path.Add(new Point(13.5, 27.0));
        path.Add(new Point(12.5, 27.0));
        path.Add(new Point(12.5, 20.5));
        path.Add(new Point( 6.0, 21.5));
        path.Add(new Point( 7.0, 19.0));
        path.Add(new Point( 0.5, 14.0));
        path.Add(new Point( 2.0, 13.0));
        path.Add(new Point( 1.0,  9.0));
        path.Add(new Point( 5.0,  9.5));
        path.Add(new Point( 5.5,  7.5));

        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point( 8.0,  3.5, Point.IS_CURVE_POINT));

        path.Add(new Point(10.5,  4.5));
        path.setClosePath(true);
        path.SetColor(RGB.RED);
        path.SetFillShape(true);
        path.PlaceIn(flag, 19.0, 3.0);
        path.DrawOn(page);

        Box box = new Box();
        box.SetSize(16, 32);
        box.SetColor(RGB.RED);
        box.SetFillShape(true);
        box.PlaceIn(flag, 0.0, 0.0);
        box.DrawOn(page);
        box.PlaceIn(flag, 48.0, 0.0);
        box.DrawOn(page);

        path.ScaleBy(15.0);
        path.SetFillShape(false);
        path.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }
    public Example_19(String fileNumber, String fileName)
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_19_" + fileNumber + ".pdf", FileMode.Create)));

        BufferedStream bis = new BufferedStream(
            new FileStream("data/testPDFs/" + fileName, FileMode.Open));
        SortedDictionary <Int32, PDFobj> objects = pdf.Read(bis);

        bis.Close();

        Image image = new Image(
            objects,
            new BufferedStream(new FileStream(
                                   "images/BARCODE.PNG", FileMode.Open, FileAccess.Read)),
            ImageType.PNG);

        image.SetLocation(480f, 57f);
        image.ScaleBy(0.40f);

        Font f1 = new Font(
            objects,
            new FileStream("fonts/Droid/DroidSans.ttf.stream",
                           FileMode.Open,
                           FileAccess.Read), Font.STREAM);

        f1.SetSize(12f);

        Font f2 = new Font(
            objects,
            new FileStream("fonts/Droid/DroidSans-Bold.ttf.stream",
                           FileMode.Open,
                           FileAccess.Read), Font.STREAM);

        f2.SetSize(12f);

        List <PDFobj> pages = pdf.GetPageObjects(objects);

        Page page = null;

        for (int i = 0; i < pages.Count; i++)
        {
            page = new Page(pdf, pages[i]);
            // page.InvertYAxis();

            page.AddResource(image, objects);
            page.AddResource(f1, objects);
            page.AddResource(f2, objects);
            Font f3 = page.AddResource(CoreFont.HELVETICA, objects).SetSize(12f);

            image.DrawOn(page);

            float x  = 23f;
            float y  = 185f;
            float dx = 15f;
            float dy = 24f;

            page.SetBrushColor(Color.blue);

            // First Name and Initial
            // page.DrawString(f1, "John", x, y);
            page.DrawString(f2, "Иван", x, y);

            // Last Name
            page.DrawString(f3, "Jones", x + 258f, y);

            // Social Insurance Number
            page.DrawString(f1, StripSpacesAndDashes("243-590-129"), x + 437f, y, dx);

            // Last Name at Birth
            page.DrawString(f1, "Culverton", x, y += dy);

            // Mailing Address
            page.DrawString(f1, "10 Elm Street", x, y += dy);

            // City
            page.DrawString(f1, "Toronto", x, y + dy);

            // Province or Territory
            page.DrawString(f1, "Ontario", x + 365f, y += dy);

            // Postal Code
            page.DrawString(f1, StripSpacesAndDashes("L7B 2E9"), x + 482f, y, dx);

            // Home Address
            page.DrawString(f1, "10 Oak Road", x, y += dy);

            // City
            y += dy;
            page.DrawString(f1, "Toronto", x, y);

            // Previous Province or Territory
            page.DrawString(f1, "Ontario", x + 365f, y);

            // Postal Code
            page.DrawString(f1, StripSpacesAndDashes("L7B 2E9"), x + 482f, y, dx);

            // Home telephone number
            page.DrawString(f1, "905-222-3333", x, y + dy);
            // Work telephone number
            page.DrawString(f1, "416-567-9903", x + 279f, y += dy);

            // Previous province or territory
            page.DrawString(f1, "British Columbia", x + 452f, y += dy);

            // Move date from previous province or territory
            y += dy;
            page.DrawString(f1, StripSpacesAndDashes("2016-04-12"), x + 452f, y, dx);

            // Date new maritial status began
            page.DrawString(f1, StripSpacesAndDashes("2014-11-02"), x + 452f, 467f, dx);

            // First name of spouse
            y = 521f;
            page.DrawString(f1, "Melanie", x, y);
            // Last name of spouse
            page.DrawString(f1, "Jones", x + 258f, y);

            // Social Insurance number of spouse
            page.DrawString(f1, StripSpacesAndDashes("192-760-427"), x + 437f, y, dx);

            // Spouse or common-law partner's address
            page.DrawString(f1, "12 Smithfield Drive", x, 554f);

            // Signature Date
            page.DrawString(f1, "2016-08-07", x + 475f, 615f);

            // Signature Date of spouse
            page.DrawString(f1, "2016-08-07", x + 475f, 651f);

            // Female Checkbox 1
            // xMarkCheckBox(page, 477.5f, 197.5f, 7f);

            // Male Checkbox 1
            XMarkCheckBox(page, 534.5f, 197.5f, 7f);

            // Married
            XMarkCheckBox(page, 34.5f, 424f, 7f);

            // Living common-law
            // XMarkCheckBox(page, 121.5f, 424f, 7f);

            // Widowed
            // XMarkCheckBox(page, 235.5f, 424f, 7f);

            // Divorced
            // XMarkCheckBox(page, 325.5f, 424f, 7f);

            // Separated
            // XMarkCheckBox(page, 415.5f, 424f, 7f);

            // Single
            // XMarkCheckBox(page, 505.5f, 424f, 7f);

            // Female Checkbox 2
            XMarkCheckBox(page, 478.5f, 536.5f, 7f);

            // Male Checkbox 2
            // XMarkCheckBox(page, 535.5f, 536.5f, 7f);

            page.Complete(objects);
        }

        if (fileName.EndsWith("rc65-16e.pdf"))
        {
            HashSet <Int32> set = new HashSet <Int32>();
            set.Add(2);
            pdf.RemovePages(set, objects);
        }

        pdf.AddObjects(objects);

        pdf.Close();
    }
Example #44
0
            PDF pdf; //pdf

            /// <summary>
            /// construct
            /// </summary>
            /// <param name="pdf">PDF. The first argument(v[0]) must be dependent variable.</param>
            /// <param name="lowerbound"></param>
            /// <param name="upperbound"></param>
            /// <param name="pieces"></param>
            public CachedNormalized(PDF pdf, double lowerbound, double upperbound, int pieces = 100)
            {
                this.pdf = pdf;
                this.lower = lowerbound;
                this.upper = upperbound;
                this.partial_argcache = new double[0];
                this.cache = -1;
                this.pieces = pieces;
            }
Example #45
0
        static void Main(string[] args)
        {
            Console.WriteLine("start");

            byte[] inbytes;

            var mPDF = new PDF();

            mPDF.LoadPdf(@"C:\Working\PDF_Test.pdf");

            // read first line
            inbytes      = mPDF.ReadPdfNextline();
            mPDF.Version = Encoding.UTF8.GetString(inbytes);
            mPDF.WritePdfline(inbytes);

            // read 2nd line
            inbytes       = mPDF.ReadPdfNextline();
            mPDF.FileType = Encoding.UTF8.GetString(inbytes);
            mPDF.WritePdfline(inbytes);


            // Read Objects
            bool bInObjects = true;

            while (bInObjects = true)
            {
                // read object
                inbytes = mPDF.ReadPdfNextline();
                Console.WriteLine("Line1: " + Encoding.UTF8.GetString(inbytes));
                // check if done
                if (mPDF.IndexOf(inbytes, mPDF.serXref) > -1)
                {
                    bInObjects = false;
                    break;
                }

                //-- Stream -------------------------------------------------------------------------
                if (mPDF.IndexOf(inbytes, mPDF.serStreamStart) > -1)
                {
                    // New Object
                    byte[] inStream  = new byte[0];
                    bool   bInStream = true;
                    while (bInStream == true)
                    {
                        inbytes = mPDF.ReadPdfNextline();
                        if (mPDF.IndexOf(inbytes, mPDF.serStreamEnd) > -1)
                        {
                            bInStream = false;
                            break;
                        }
                        Console.WriteLine("Line2: " + Encoding.UTF8.GetString(inbytes));

                        byte[] outputBytes = new byte[inStream.Length + inbytes.Length];

                        Buffer.BlockCopy(inStream, 0, outputBytes, 0, inStream.Length);
                        Buffer.BlockCopy(inbytes, 0, outputBytes, inStream.Length, inbytes.Length);

                        inStream = outputBytes;
                    }
                    // remove last byte -----------------------------------------------------------------
                    byte[] fixInStream = new byte[inStream.Length - 1];
                    Buffer.BlockCopy(inStream, 0, fixInStream, 0, inStream.Length - 1);
                    inStream = fixInStream;

                    Console.WriteLine("Line2: " + inStream.Length);

                    // de-Encrypt ------------------------------------------------------------------------
                    DeflateStream compressedStream = new DeflateStream(inStream, CompressionMode.Compress, true);
                }
            }

            Console.WriteLine("PDF-Version: " + mPDF.Version);


            Console.WriteLine("Done");
        }
Example #46
0
            public BinChi2(PDF pdf, double[] edges, double[] y, double[] sigma = null)
            {
                Debug.Assert(edges.Length == y.Length + 1);
                if (sigma == null)
                {
                    sigma = NP.Ones(y.Length);
                }
                Debug.Assert(y.Length == sigma.Length);

                this.edges = edges;
                this.y = y;
                this.sigma = sigma;
                this.pdf = pdf;
            }
    public Example_13()
    {
        FileStream fos = new FileStream("Example_13.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Font f1 = new Font(pdf, "Helvetica-Bold");
        Font f2 = new Font(pdf, "Helvetica");
        f1.SetSize(7.0);
        f2.SetSize(7.0);

        List<List<Cell>> tableData = new List<List<Cell>>();
        StreamReader reader = new StreamReader(
                new FileStream("data/winter-2009.txt", FileMode.Open));
        String line;
        while (( line = reader.ReadLine()) != null) {
            List<Cell> row = new List<Cell>();
            String[] columns = line.Split(new Char[] {'|'});
            for ( int i = 0; i < columns.Length; i++ ) {
                row.Add(new Cell(f2, columns[i]));
            }
            tableData.Add(row);
        }
        reader.Close();

        Table table = new Table(f1, f2);
        table.SetData(tableData, Table.DATA_HAS_2_HEADER_ROWS);
        table.SetPosition(100.0, 50.0);
        table.setCellMargin(2.0);

        table.RemoveLineBetweenRows(0, 1);

        Cell cell3 = table.GetCellAt(1, 1);
        cell3.border.top = true;

        cell3 = table.GetCellAt(1, 2);
        cell3.border.top = true;

        SetFontForRow(table, 0, f1);
        SetFontForRow(table, 1, f1);

        table.AutoAdjustColumnWidths();

        List<Cell> column = table.GetColumn(7);
        for ( int i = 0; i < column.Count; i++ ) {
            Cell cell = column[i];
            cell.SetTextAlignment(Align.CENTER);
        }

        column = table.GetColumn(4);
        for ( int i = 2; i < column.Count; i++ ) {
            Cell cell = column[i];
            try {
                cell.SetTextAlignment(Align.CENTER);
                if ( Int32.Parse( cell.GetText()) > 40 ) {
                    cell.SetBgColor( new double[] { 0.0, 0.85, 0.0 } );
                } else {
                    cell.SetBgColor( new double[] { 1.0, 1.0, 0.0 } );
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
        }

        Cell cell2 = table.GetCellAt(0, 1);
        cell2.SetColSpan( 2 );
        cell2.SetTextAlignment(Align.CENTER);

        SetBgColorForRow(table, 0, new double[] { 0.85, 0.85, 0.85 });
        SetBgColorForRow(table, 1, new double[] { 0.85, 0.85, 0.85 });

        table.SetColumnWidth(3, 10);
        blankOutColumn(table, 3);

        table.SetColumnWidth(8, 10);
        blankOutColumn(table, 8);

        Page page = new Page(pdf, Letter.PORTRAIT);
        int numOfPages = table.GetNumberOfPages(page);
        int pageNumber = 1;
        while (true) {
            table.DrawOn(page);

            TextLine text = new TextLine(f1);
            text.SetText("Page " + pageNumber++ + " of " + numOfPages);
            text.SetPosition(300.0, 780.0);
            text.DrawOn(page);

            if (!table.HasMoreData()) break;
            page = new Page(pdf, Letter.PORTRAIT);
        }

        pdf.Flush();
        bos.Close();
    }