예제 #1
0
 private void AddEmptyLine(RtfDocument doc)
 {
     doc.addParagraph();
 }
예제 #2
0
        public void Output(List<Sms> list, string outputFilename)
        {
            RtfDocument doc = new RtfDocument(PaperSize.A4, PaperOrientation.Portrait, Lcid.English);

            FontDescriptor fontBody = doc.createFont("Courier New");
            int fontSizeBody = 12;
            int fontSizeSmall = 10;

            RtfParagraph par;
            RtfCharFormat format;

            //
            // file header
            //
            par = doc.addParagraph();
            par.DefaultCharFormat.Font = fontBody;
            par.DefaultCharFormat.FontSize = fontSizeSmall;
            par.Text = String.Format("Generated\nOn {0}", DateTime.Now);

            this.AddEmptyLine(doc);

            string fromto = String.Empty;

            //
            // the smses
            //
            foreach (Sms sms in list)
            {
                //
                // from / to
                //
                fromto = "From";
                if (sms.Type.Equals(XmlConstants.TypeSent))
                {
                    fromto = "To";
                }
                par = doc.addParagraph();
                par.DefaultCharFormat.Font = fontBody;
                par.DefaultCharFormat.FontSize = fontSizeBody;
                par.Text = String.Format("{0}: {1}", fromto, sms.Address);
                format = par.addCharFormat(0, fromto.Length);
                format.FontStyle.addStyle(FontStyleFlag.Bold);

                if (!sms.ContactName.Equals(XmlConstants.UnknownContact))
                {
                    par.Text = String.Format("{0} ({1})", par.Text, sms.ContactName);
                }

                //
                // date
                //
                par = doc.addParagraph();
                par.DefaultCharFormat.Font = fontBody;
                par.DefaultCharFormat.FontSize = fontSizeBody;
                par.Text = sms.Date.ToString();

                this.AddEmptyLine(doc);

                //
                // body
                //
                par = doc.addParagraph();
                par.DefaultCharFormat.Font = fontBody;
                par.DefaultCharFormat.FontSize = fontSizeBody;
                par.Text = sms.Body;

                this.AddEmptyLine(doc);

                //
                // separator
                //
                par = doc.addParagraph();
                par.DefaultCharFormat.Font = fontBody;
                par.DefaultCharFormat.FontSize = fontSizeBody;
                par.Text = "---";

                this.AddEmptyLine(doc);
            }

            doc.save(outputFilename);
        }
예제 #3
0
        private void CreateRTF()
        {
            // Create document by specifying paper size and orientation, 
            // and default language.
            var doc = new RtfDocument(PaperSize.A4, PaperOrientation.Portrait, Lcid.TraditionalChinese);
            var times = doc.createFont("Times New Roman");
            var courier = doc.createFont("Arial");

            var red = doc.createColor(new DW.RtfWriter.Color("ff0000"));
            var blue = doc.createColor(new DW.RtfWriter.Color(System.Drawing.Color.Navy));

            // Don't instantiate RtfTable, RtfParagraph, and RtfImage objects by using
            // ``new'' keyword. Instead, use add* method in objects derived from 
            // RtfBlockList class. (See Demos.)
            RtfTable table;
            RtfParagraph par;
            RtfImage img;
            // Don't instantiate RtfCharFormat by using ``new'' keyword, either. 
            // An addCharFormat method are provided by RtfParagraph objects.
            RtfCharFormat fmt;


            // ==========================================================================
            // Demo 1: Font Setting
            // ==========================================================================
            // If you want to use Latin characters only, it is as simple as assigning
            // ``Font'' property of RtfCharFormat objects. If you want to render Far East 
            // characters with some font, and Latin characters with another, you may 
            // assign the Far East font to ``Font'' property and the Latin font to 
            // ``AnsiFont'' property. This Demo contains Traditional Chinese characters.
            // (Note: non-Latin characters are unicoded so you don't have to be worried.)

            img = doc.addImage("images/hellas.gif", ImageFileType.Gif);
            img.Alignment = Align.Center;
            img.Width = 60;

            par = doc.addParagraph();
            par.DefaultCharFormat.Font = doc.createFont("Arial");
            par.DefaultCharFormat.FontSize = 11;
            par.DefaultCharFormat.FgColor = blue;
            par.DefaultCharFormat.AnsiFont = courier;
            par.DefaultCharFormat.FontStyle.addStyle(FontStyleFlag.Bold);
            par.Alignment = Align.Center;
            par.setText("ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ\n ΥΠΟΥΡΓΕΙΟ ΕΡΓΑΣΙΑΣ, ΚΟΙΝΩΝΙΚΗΣ ΑΣΦΑΛΙΣΗΣ ΚΑΙ ΠΡΟΝΟΙΑΣ\n ΓΕΝΙΚΗ ΓΡΑΜΜΑΤΕΙΑ ΔΙΑΧΕΙΡΙΣΗΣ ΚΟΙΝΟΤΙΚΩΝ ΚΑΙ ΑΛΛΩΝ ΠΟΡΩΝ\n ΕΙΔΙΚΗ ΥΠΗΡΕΣΙΑ ΕΦΑΡΜΟΓΗΣ\nΣΥΓΧΡΗΜΑΤΟΔΟΤΟΥΜΕΝΩΝ ΕΝΕΡΓΕΙΩΝ ΑΠΟ ΤΟ ΕΚΤ");

            par = doc.addParagraph();
            fmt = par.addCharFormat();
            fmt.FontStyle.addStyle(FontStyleFlag.Bold);
            par.Alignment = Align.Center;
            par.setText("\n\nΑΝΑΦΟΡΑ ΔΕΙΓΜΑΤΟΛΗΨΙΑΣ\n");

            par = doc.addParagraph();
            par.Alignment = Align.Center;
            par.setText(" ___________________________________________________________\n");

            par = doc.addParagraph();
            par.Alignment = Align.Center;
            par.setText("Ημερομηνία: " + this.CurrentProject.Date + "                   Ώρα: " + this.CurrentProject.Time);

            par = doc.addParagraph();
            par.Alignment = Align.Center;
            par.setText(" ___________________________________________________________\n");

            par = doc.addParagraph();
            par.Alignment = Align.FullyJustify;
            par.setText("Πραγματοποιήθηκε δειγματοληψία, όπως προβλέπεται από το άρθρο 3 της υπ’ αριθμ. 37156/18953/ 20.05.2008 ΚΥΑ, σε πληθυσμό " + CurrentProject.NumOfItems.ToString() + " προγραμμάτων του έργου «" + CurrentProject.title + "». Ως αποτέλεσμα της δειγματοληψίας, επιλέχθηκε δείγμα " + CurrentProject.NumOfSamples.ToString() + " προγραμμάτων στα οποία θα πραγματοποιηθεί από την αρμόδια Μονάδα Ελέγχου της ΕΥΕ επιτόπιος έλεγχος για τη διαπίστωση της ορθής υλοποίηση των συγχρηματοδοτούμενων ενεργειών και την τήρηση των υποχρεώσεων των Αναδόχων σύμφωνα με το ισχύον θεσμικό πλαίσιο.");


            par = doc.addParagraph();
            par.setText("\n\n");

            par = doc.addParagraph();
            par.DefaultCharFormat.FontStyle.addStyle(FontStyleFlag.Underline);
            par.Alignment = Align.Left;
            par.setText("Ρυθμίσεις δειγματοληψίας.\n\n");
           
            par = doc.addParagraph();
            par.Alignment = Align.FullyJustify;
            par.setText(CurrentProject.Settings + "\n\n");


            par = doc.addParagraph();
            par.DefaultCharFormat.FontStyle.addStyle(FontStyleFlag.Underline);
            par.Alignment = Align.Left;
            par.setText("Πίνακας επιλεγμένων δειγμάτων.\n");


            int tablerows = CurrentProject.ResultItems.Count;
            int x = 1;
            table = doc.addTable(tablerows+1, 7, 415.2f, 9);
            table.Margins[Direction.Bottom] = 20;
            table.setInnerBorder(BorderStyle.Dotted, 1.5f);
            table.setOuterBorder(BorderStyle.Dotted, 3f);
            table.Alignment = Align.Left;
            
            
            for (var j = 0; j < table.ColCount; j++)
            {
                table.cell(0, j).AlignmentVertical = AlignVertical.Middle;
                table.cell(0, j).DefaultCharFormat.FontStyle.addStyle(FontStyleFlag.Bold);
                table.cell(0, j).DefaultCharFormat.FontSize = 9;
            }
            table.cell(0, 0).Width = 20;
            table.cell(0, 0).addParagraph().setText("Α/Α");
            table.cell(0, 1).Width = 30;
            table.cell(0, 1).addParagraph().setText("Πράξη");
            table.cell(0, 2).Width = 120;
            table.cell(0, 2).addParagraph().setText("Επωνυμία Φορέα");
            table.cell(0, 3).Width = 35;
            table.cell(0, 3).addParagraph().setText("Υποέργο");
            table.cell(0, 4).Width = 40;
            table.cell(0, 4).addParagraph().setText("Κωδ.Πρ.");
            table.cell(0, 5).Width = 120;
            table.cell(0, 5).addParagraph().setText("Τίτλος Πρ.");
            table.cell(0, 6).Width = 70;
            table.cell(0, 6).addParagraph().setText("Περιφέρεια");
            for (var i = 1; i < table.RowCount; i++)
            {
                for (var j = 0; j < table.ColCount; j++)
                {
                    table.cell(i, j).AlignmentVertical = AlignVertical.Middle;
                    table.cell(i, j).DefaultCharFormat.FontSize = 8;
                }
                Item t = CurrentProject.ResultItems[i-1];
                table.cell(i, 0).Width = 20;
                table.cell(i, 1).Width = 30;
                table.cell(i, 2).Width = 120;
                table.cell(i, 3).Width = 35;
                table.cell(i, 4).Width = 40;
                table.cell(i, 5).Width = 120;
                table.cell(i, 6).Width = 70;
                table.cell(i, 0).addParagraph().setText(x++.ToString());
                table.cell(i, 1).addParagraph().setText(t.getProperty("praxi").value);
                table.cell(i, 2).addParagraph().setText(t.getProperty("eponimia").value);
                table.cell(i, 3).addParagraph().setText(t.getProperty("ypoergo").value);
                table.cell(i, 4).addParagraph().setText(t.getProperty("kod_programmatos").value);
                table.cell(i, 5).addParagraph().setText(t.getProperty("titlos_programmatos").value);
                table.cell(i, 6).addParagraph().setText(t.getProperty("periferia").value);
            }

            doc.save(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/RECENT_SAMPLINGS/" + CurrentProject.Report());
        }