Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            // Create a MigraDoc document
            MigraDocSample_CreateInvoiceDocument invoiceSample = new MigraDocSample_CreateInvoiceDocument();
            Document document = invoiceSample.CreateDocument();

            document.UseCmykColor = true;

            // Create a renderer for the MigraDoc document.
            const bool             unicode     = false;
            const PdfFontEmbedding embedding   = PdfFontEmbedding.Always;
            PdfDocumentRenderer    pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = document;

            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...
            const string filename = "d:\\HelloWorld.pdf";

            pdfRenderer.PdfDocument.Save(filename);

            // ...and start a viewer.
            System.Diagnostics.Process.Start(filename);
        }
Example #2
0
        public byte[] GenerateBidDocument(int BidId)
        {
            Document document = CreateBidDocument(BidId);

            document.UseCmykColor = true;

            const bool unicode = false;

            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            DocumentRenderer renderer = new DocumentRenderer(document);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;

            pdfRenderer.RenderDocument();

            MemoryStream stream = new MemoryStream();

            pdfRenderer.PdfDocument.Save(stream, false);

            byte[] bytes = stream.ToArray();

            return(bytes);
        }
Example #3
0
        public void CreateDocument()
        {
            // Create a new MigraDoc document
            document            = new Document();
            document.Info.Title = "Raport";

            DefineStyles();
            CreatePage();
            Wszystkie_zamowienia();
            Rozliczone_zamowienia();


            document.UseCmykColor = true;
            const bool             unicode     = true;
            const PdfFontEmbedding embedding   = PdfFontEmbedding.Always;
            PdfDocumentRenderer    pdfRenderer = new PdfDocumentRenderer(unicode, embedding)
            {
                Document = document
            };

            pdfRenderer.RenderDocument();
            //ścieżka dostępu
            try
            {
                string filename = Sciezki.moje_dokumnety + @"\SPOZ\Raport.pdf";
                pdfRenderer.PdfDocument.Save(filename);
                Process.Start(filename);
            }
            catch (Exception)
            {
                MessageBox.Show("Należy zamknąć poprzedni raport.");
            }
        }
Example #4
0
        //FileName is optional if no value then create temp file
        public String Generate(string FileName = null)
        {
            // Generate only once, if already done then get the file
            if (m_ReportFileName == null)
            {
                mPDFReport.UseCmykColor = true;

                const bool             unicode   = false;
                const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

                PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

                pdfRenderer.Document = mPDFReport;

                // Layout and render document to PDF
                pdfRenderer.RenderDocument();

                // Save the document...
                //TODO: clean/check temp folder for the pdf created...
                if (FileName == null)
                {
                    FileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".pdf";
                }
                pdfRenderer.PdfDocument.Save(FileName);
                m_ReportFileName = FileName;
            }
            return(m_ReportFileName);
        }
Example #5
0
        public static void CreateFile(Result result, string filePath)
        {
            // Create a MigraDoc document
            Document document = CreateDocument(result);

            document.UseCmykColor = true;

            // A flag indicating whether to create a Unicode PDF or a WinAnsi PDF file.
            // This setting applies to all fonts used in the PDF document.
            // This setting has no effect on the RTF renderer.
            const bool unicode = false;

            // An enum indicating whether to embed fonts or not.
            // This setting applies to all font programs used in the document.
            // This setting has no effect on the RTF renderer.
            // (The term 'font program' is used by Adobe for a file containing a font. Technically a 'font file'
            // is a collection of small programs and each program renders the glyph of a character when executed.
            // Using a font in PDFsharp may lead to the embedding of one or more font programms, because each outline
            // (regular, bold, italic, bold+italic, ...) has its own fontprogram)
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            pdfRenderer.PdfDocument.Save(filePath);
        }
Example #6
0
        public void ExportToPDF(string _sCardImage)
        {
            //297×210 A4
            //88x63 Card
            //264x189 9Cards
            Document document = new Document();
            Section  section  = document.AddSection();

            section.PageSetup.BottomMargin = "1.0cm";
            section.PageSetup.TopMargin    = "1.0cm";
            section.PageSetup.LeftMargin   = "0.65cm";
            section.PageSetup.RightMargin  = "0.65cm";

            var table = section.AddTable();

            table.Borders.Color = new MigraDoc.DocumentObjectModel.Color(0, 0, 0);
            var ColumnLeft  = table.AddColumn("0.5cm");
            var Column0     = table.AddColumn("6.315cm");
            var Column1     = table.AddColumn("6.315cm");
            var Column2     = table.AddColumn("6.315cm");
            var ColumnRight = table.AddColumn("0.5cm");
            var topRow      = table.AddRow();

            topRow.Height = "0.5cm";
            //[TODO] Split proxies in 9x9 pages and then add a 9x9 back images
            for (int i = 0; i < 3; ++i)
            {
                var tableRow = table.AddRow();
                //tableRow.Height = "8.8cm";
                for (int j = 1; j < 4; ++j)
                {
                    var cell = tableRow.Cells[j];
                    var par  = cell.AddParagraph();
                    par.Format.SpaceAfter = "-0.07cm";
                    par.Format.LeftIndent = "-0.12cm";
                    cell.Shading.Color    = new MigraDoc.DocumentObjectModel.Color(0, 0, 0);
                    var card = par.AddImage(_sCardImage);
                    card.Width  = "6.3cm";
                    card.Height = "8.8cm";
                }
            }
            var bottomRow = table.AddRow();

            bottomRow.Height      = "0.5cm";
            document.UseCmykColor = true;
            const bool             unicode   = false;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;
            // ========================================================================================
            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = document;
            // Layout and render document to PDF
            pdfRenderer.RenderDocument();
            // Save the document...
            string filename = _sCardImage.Replace(".png", ".pdf");

            pdfRenderer.PdfDocument.Save(filename);
        }
Example #7
0
        public ActionResult TestMigraDoc1()
        {
            Document document = new Document();

            Style style = document.Styles["Normal"];

            style.Font.Name = "Cordia New";
            style.Font.Size = 16;

            document.Info.Author   = "PalangPanya";
            document.Info.Subject  = "Member Information";
            document.Info.Keywords = "PalangPanya";

            Section section = document.AddSection();

            Paragraph paragraph = section.AddParagraph();

            paragraph.Format.Font.Color = Color.FromCmyk(100, 30, 20, 50);

            paragraph.AddFormattedText("Hello,ไทย World!", TextFormat.Bold);
            paragraph.AddFormattedText("ทดสอบการใช้ภาษา", TextFormat.Italic);

            var logoPath = Path.Combine(_env.WebRootPath, "images");

            logoPath = Path.Combine(logoPath, "logo_t.png");
            Image imgLogo = section.AddImage(logoPath);

            imgLogo.Height          = "2cm";
            imgLogo.LockAspectRatio = true;

            var memberPicPath = Path.Combine(_env.WebRootPath, "images_member");

            memberPicPath = Path.Combine(memberPicPath, "_2_1365148227.jpg");
            //memberPicPath = Path.Combine(memberPicPath, "_677138-topic-ix-1.jpg");
            Image imgMember = section.AddImage(memberPicPath);

            imgMember.Height             = "5cm";
            imgMember.LockAspectRatio    = true;
            imgMember.RelativeVertical   = RelativeVertical.Line;
            imgMember.RelativeHorizontal = RelativeHorizontal.Margin;
            imgMember.Top              = ShapePosition.Top;
            imgMember.Left             = ShapePosition.Right;
            imgMember.WrapFormat.Style = WrapStyle.Through;


            document.UseCmykColor = true;
            const bool             unicode     = true;
            const PdfFontEmbedding embedding   = PdfFontEmbedding.Always;
            PdfDocumentRenderer    pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            //const string filename = "HelloWorld.pdf";
            //pdfRenderer.PdfDocument.Save(filename);
            MemoryStream m = new MemoryStream();

            pdfRenderer.PdfDocument.Save(m, false);
            return(new FileStreamResult(m, "application/pdf"));
        }
Example #8
0
        static string BuildSignature(Font font, bool unicode, PdfFontEmbedding fontEmbedding)
        {
            StringBuilder signature = new StringBuilder(128);

            signature.Append(font.Name.ToLower());
            signature.Append(font.Size.Point.ToString("##0.0"));
            return(signature.ToString());
        }
Example #9
0
        public void CreateInvoice(Order order)
        {
            if (order.OrderDetailDt == null)
            {
                return;
            }

            currentOrder = order;

            if (currentOrder == null)
            {
                return;
            }

            CreateDocument();
            document.UseCmykColor = true;

#if DEBUG
            // for debugging only...
            MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");
            //document = MigraDoc.DocumentObjectModel.IO.DdlReader.DocumentFromFile("MigraDoc.mdddl");
#endif

            const bool             unicode   = true;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            // Create a renderer for PDF that uses Unicode font encoding
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Set the MigraDoc document
            pdfRenderer.Document = document;

            // Create the PDF document
            pdfRenderer.RenderDocument();

            // Save the PDF document...
            //string filename = "Invoice.pdf";
            //string filename = string.Format("Invoice - {0}-{1} - {2}.pdf",
            //    currentOrder.OrderDate.ToString("yyyy.MM.dd"), DateTime.Now.ToString("HH.mm.ss"), currentOrder.OrderID.ToString().ToUpper());

            string filename = string.Format("{0}.pdf", currentOrder.GetReportName());

#if DEBUG
            // I don't want to close the document constantly...
            //filename = "Invoice-" + Guid.NewGuid().ToString("N").ToUpper() + ".pdf";
            //filename = string.Format("Invoice - {0}-{1} - {2}.pdf",
            //    currentOrder.OrderDate.ToString("yyyy.MM.dd"), DateTime.Now.ToString("HH.mm.ss"), currentOrder.OrderID.ToString().ToUpper());

            filename = string.Format("{0}.pdf", currentOrder.GetReportName());
#endif

            filename = string.Format("{0}\\{1}", ApplicationOperator.GetGeneralSetting().ReportPathSetting.ReportPath, filename);
            pdfRenderer.Save(filename);
            // ...and start a viewer.
            Process.Start(filename);
        }
Example #10
0
        public static void CreatePdf(string person1, string person2, DataHandler datahandler, Dictionary <string, string[]> groups)
        {
            Document document = new Document();

            document.UseCmykColor = true;

            MigraDoc.DocumentObjectModel.Section section = document.AddSection();
            section.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape;
            MigraDoc.DocumentObjectModel.Paragraph paragraph = section.AddParagraph();
            paragraph.Format.Font.Color = MigraDoc.DocumentObjectModel.Color.FromCmyk(100, 20, 30, 50);

            if (person1 == "<Ingen sælger valgt>")
            {
                person1 = null;
            }

            if (person2 == "<Ingen sælger valgt>")
            {
                person2 = null;
            }

            if (person1 != null)
            {
                paragraph.AddFormattedText(person1, TextFormat.Bold);
                paragraph.AddLineBreak();
                paragraph.AddLineBreak();

                DefineCharts(document, person1, groups, datahandler);
            }

            if (person2 != null)
            {
                MigraDoc.DocumentObjectModel.Section newSection = document.AddSection();
                newSection.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape;
                MigraDoc.DocumentObjectModel.Paragraph newParagraph = newSection.AddParagraph();

                newParagraph.AddFormattedText(person2, TextFormat.Bold);
                newParagraph.AddLineBreak();
                newParagraph.AddLineBreak();

                DefineCharts(document, person2, groups, datahandler);
            }

            const bool             unicode     = false;
            const PdfFontEmbedding embedding   = PdfFontEmbedding.Always;
            PdfDocumentRenderer    pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();

            string time   = DateTime.Today.ToShortDateString();
            string myfile = time + ".pdf";

            pdfRenderer.PdfDocument.Save(myfile);
            Process.Start(myfile);
        }
Example #11
0
        static XFont XFontFromCache(Font font, bool unicode, PdfFontEmbedding fontEmbedding)
        {
            XFont xFont = null;

            XPdfFontOptions options = null;

            options = new XPdfFontOptions(fontEmbedding, unicode);
            XFontStyle style = GetXStyle(font);

            xFont = new XFont(font.Name, font.Size, style, options);

            return(xFont);
        }
        void model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            const bool             unicode   = false;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            if (e.PropertyName == "Document")
            {
                if (model.Document != null)
                {
                    docViewer.Ddl = DdlWriter.WriteToString(model.Document);
                }
            }
        }
        public virtual void WriteReport(Report report, string filename)
        {
            Document doc = CreateDocument(report);

            const bool             unicode     = false;
            const PdfFontEmbedding embedding   = PdfFontEmbedding.Always;
            PdfDocumentRenderer    pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = doc;

            pdfRenderer.RenderDocument();

            pdfRenderer.PdfDocument.Save(filename);
        }
Example #14
0
        private void renderPDF(string filename)
        {
            Bitmap bp = new Bitmap(900, 600);
            int    hh = chart2.Height;;

            chart2.Dock = DockStyle.None;
            chart2.Size = new Size(900, 600);
            chart2.DrawToBitmap(bp, new Rectangle(0, 0, 900, 600));
            chart2.Dock   = DockStyle.Bottom;
            chart2.Height = hh;
            bp.RotateFlip(RotateFlipType.Rotate90FlipNone);
            bp.Save(Application.StartupPath + "\\temp\\testa.png", ImageFormat.Png);

            Bitmap bp2 = new Bitmap(900, 600);

            hh          = chart1.Height;;
            chart1.Dock = DockStyle.None;
            chart1.Size = new Size(900, 600);
            chart1.DrawToBitmap(bp2, new Rectangle(0, 0, 900, 600));
            chart1.Dock   = DockStyle.Bottom;
            chart1.Height = hh;
            bp2.RotateFlip(RotateFlipType.Rotate90FlipNone);
            bp2.Save(Application.StartupPath + "\\temp\\testb.png", ImageFormat.Png);

            Document document = CreateDocument();
            string   ddl      = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);
            bool     unicode  = true;

            PdfFontEmbedding embedding = PdfFontEmbedding.Always;  // Set to PdfFontEmbedding.None or PdfFontEmbedding.Always only

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = document;

            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...

            pdfRenderer.PdfDocument.Save(filename);

            Process.Start(filename);
            //  Bitmap bp = new Bitmap(1024, 768);
            // chart2.DrawToBitmap(bp, new Rectangle(0, 0, 1024, 768));
            // bp.Save(Application.StartupPath + "\\testc.png", ImageFormat.Png);
        }
Example #15
0
        public void GeneratePdf(House details)
        {
            home = details;
            var    folder   = @"C:\Users\pec\Documents\My Received Files\Daft";
            string filename = CleanInput(home.Address) + ".pdf";
            var    target   = Path.Combine(folder, filename);

            //PdfPage page = document.AddPage();
            DefineStyles();

            BuildPages();
            const bool             unicode   = false;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer();

            pdfRenderer.Document = Migradoc;
            pdfRenderer.RenderDocument();
            // Create or Replace the file
            try
            {
                // Delete the file if it exists.
                if (File.Exists(target))
                {
                    // Note that no lock is put on the
                    // file and the possibility exists
                    // that another process could do
                    // something with it between
                    // the calls to Exists and Delete.
                    File.Delete(target);
                }

                // Create the file.

                using (FileStream fs = File.Create(target))
                {
                    File.SetAttributes(target, FileAttributes.Normal);
                    pdfRenderer.PdfDocument.Save(fs, true);
                    //Process.Start(target);
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Example #16
0
        static void Main()
        {
            // Create a MigraDoc document
            Document document = CreateDocument();

            document.UseCmykColor = true;

            // string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);

#if true_
            RtfDocumentRenderer renderer = new RtfDocumentRenderer();
            renderer.Render(document, "HelloWorld.rtf", null);
#endif

            // ----- Unicode encoding and font program embedding in MigraDoc is demonstrated here -----

            // A flag indicating whether to create a Unicode PDF or a WinAnsi PDF file.
            // This setting applies to all fonts used in the PDF document.
            // This setting has no effect on the RTF renderer.
            const bool unicode = false;

            // An enum indicating whether to embed fonts or not.
            // This setting applies to all font programs used in the document.
            // This setting has no effect on the RTF renderer.
            // (The term 'font program' is used by Adobe for a file containing a font. Technically a 'font file'
            // is a collection of small programs and each program renders the glyph of a character when executed.
            // Using a font in PDFsharp may lead to the embedding of one or more font programms, because each outline
            // (regular, bold, italic, bold+italic, ...) has its own fontprogram)
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            // ----------------------------------------------------------------------------------------

            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = document;

            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...
            const string filename = "HelloWorld.pdf";
            pdfRenderer.PdfDocument.Save(filename);
            // ...and start a viewer.
            Process.Start(filename);
        }
Example #17
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            const bool             unicode   = true;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;
            var pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = CreateSample1(TVItem);

            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...
            var dlg = new SaveFileDialog();

            dlg.FileName   = "ТЭСЦ-2 стан 73-219 " + Title;
            dlg.DefaultExt = ".pdf";
            dlg.ShowDialog();
            pdfRenderer.PdfDocument.Save(dlg.FileName);
        }
        void model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            const bool             unicode   = false;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            if (e.PropertyName == "Document")
            {
                if (model.Document != null)
                {
                    //PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);
                    //pdfRenderer.Document = model.Document;
                    //pdfRenderer.RenderDocument();
                    //const string filename = "HelloWorld.pdf";
                    //pdfRenderer.PdfDocument.Save(filename);
                    //Process.Start(filename);

                    string ddl = DdlWriter.WriteToString(model.Document);
                    docViewer.Ddl = ddl;
                }
            }
        }
Example #19
0
        private static PdfDocumentRenderer PrepareDocument(Trip trip)
        {
            Document document = new Document();

            document.Info.Title   = $"Roadbook for {trip.region} { trip.startDate}";
            document.Info.Subject = "Roadbook";
            document.Info.Author  = "Wine trip solutions (c)2017 Marcel Sennema";
            DefineStyles(document);
            CreatePages(document, trip);

            document.UseCmykColor = true;
            const bool             unicode   = false;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            return(pdfRenderer);
        }
Example #20
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Create a MigraDoc document
            Document document = MigraDocSample_HelloWorld.CreateDocument();

            document.UseCmykColor = true;

            // ===== Unicode encoding and font program embedding in MigraDoc is demonstrated here =====
            // A flag indicating whether to create a Unicode PDF or a WinAnsi PDF file.
            // This setting applies to all fonts used in the PDF document.
            // This setting has no effect on the RTF renderer.
            const bool unicode = false;

            // An enum indicating whether to embed fonts or not.
            // This setting applies to all font programs used in the document.
            // This setting has no effect on the RTF renderer.
            // (The term 'font program' is used by Adobe for a file containing a font. Technically a 'font file'
            // is a collection of small programs and each program renders the glyph of a character when executed.
            // Using a font in PDFsharp may lead to the embedding of one or more font programms, because each outline
            // (regular, bold, italic, bold+italic, ...) has its own fontprogram)
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            // ========================================================================================
            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = document;

            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...
            const string filename = "d:\\HelloWorld.pdf";

            pdfRenderer.PdfDocument.Save(filename);

            // ...and start a viewer.
            System.Diagnostics.Process.Start(filename);
        }
Example #21
0
        private PdfDocumentRenderer PrepareDocument(Trip trip, Event evnt)
        {
            this.trip             = trip;
            this.evnt             = evnt;
            document              = new Document();
            document.Info.Title   = $" Order for {evnt.name}";
            document.Info.Subject = "Ordering wine";
            document.Info.Author  = "Wine trip solutions (c)2017 Marcel Sennema";
            DefineStyles();
            CreatePage();

            document.UseCmykColor = true;
            const bool             unicode   = false;
            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            return(pdfRenderer);
        }
Example #22
0
        // FOR CONTRACTS
        public string GenerateContractDocument(ContractInsertRequest model)
        {
            Document document = CreateContractDocument(model);

            document.UseCmykColor = true;

            const bool unicode = false;

            const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

            DocumentRenderer renderer = new DocumentRenderer(document);

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;

            pdfRenderer.RenderDocument();

            MemoryStream stream = new MemoryStream();

            pdfRenderer.PdfDocument.Save(stream, false);

            S3Request s3Request = new S3Request();

            s3Request.NewFileName = Guid.NewGuid().ToString() + ".pdf";

            s3Request.FileStream = stream;

            S3Handler s3Handler = new S3Handler();

            string filename = s3Handler.UploadStream(s3Request);

            return(filename);

            //byte[] bytes = stream.ToArray();

            //return bytes;
        }
Example #23
0
        public void CreateDocument()
        {
            // Create a new MigraDoc document
            document            = new Document();
            document.Info.Title = "Zamówienie";
            // document.Info.Subject = "Demonstrates how to create an invoice.";
            // document.Info.Author = "Stefan Lange";
            document.DefaultPageSetup.RightMargin = 20;
            document.DefaultPageSetup.LeftMargin  = 40;
            document.DefaultPageSetup.TopMargin   = 40;

            DefineStyles();
            CreatePage();
            Create_Table();
            // FillContent_table();

            document.UseCmykColor = true;
            const bool             unicode     = true;
            const PdfFontEmbedding embedding   = PdfFontEmbedding.Always;
            PdfDocumentRenderer    pdfRenderer = new PdfDocumentRenderer(unicode, embedding)
            {
                Document = document
            };

            pdfRenderer.RenderDocument();
            //ścieżka dostępu
            try
            {
                string filename = Sciezki.faktury + @"\FV-" + numer_faktury.Replace('/', '-') + ".pdf";
                Sciezki.drukowane_zk = filename;
                pdfRenderer.PdfDocument.Save(filename);
                Process.Start(filename);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Należy zamknąć poprzednie zamówienie.");
            }
        }
Example #24
0
 public XPdfFontOptions(PdfFontEmbedding embedding)
 {
     _fontEncoding = PdfFontEncoding.WinAnsi;
 }
Example #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdfDocumentRenderer"/> class.
 /// </summary>
 /// <param name="unicode">If true Unicode encoding is used for all text. If false, WinAnsi encoding is used.</param>
 /// <param name="fontEmbedding">Specifies which fonts will be imbedded in the PDF file.</param>
 public PdfDocumentRenderer(bool unicode, PdfFontEmbedding fontEmbedding)
 {
   this.unicode = unicode;
   this.fontEmbedding = fontEmbedding;
 }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XPdfFontOptions"/> class.
 /// </summary>
 public XPdfFontOptions(PdfFontEmbedding embedding)
 {
     fontEncoding  = PdfFontEncoding.WinAnsi;
     fontEmbedding = embedding;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XPdfFontOptions"/> class.
 /// </summary>
 public XPdfFontOptions(PdfFontEncoding encoding,  PdfFontEmbedding embedding)
 {
   this.fontEncoding = encoding;
   this.fontEmbedding = embedding;
 }
Example #28
0
    static XFont XFontFromCache(Font font, bool unicode, PdfFontEmbedding fontEmbedding)
    {
      XFont xFont = null;

      XPdfFontOptions options = null;
      options = new XPdfFontOptions(fontEmbedding, unicode);
      XFontStyle style = GetXStyle(font);
      xFont = new XFont(font.Name, font.Size, style, options);

      return xFont;
    }
Example #29
0
 public PdfDocumentRenderer(bool unicode, PdfFontEmbedding fontEmbedding)
 {
     _unicode = unicode;
 }
Example #30
0
 public PdfDocumentRenderer(bool unicode, PdfFontEmbedding fontEmbedding)
 {
     _unicode = unicode;
 }
Example #31
0
        public ActionResult TestMigraDocMixPdfSharp()
        {
            PdfDocument doc = new PdfDocument();

            doc.Info.Title    = "Member information";
            doc.Info.Author   = "PalangPanya";
            doc.Info.Subject  = "Member information";
            doc.Info.Keywords = "PalangPanya";

            PdfPage   page = doc.AddPage();
            XGraphics gfx  = XGraphics.FromPdfPage(page);

            gfx.MUH  = PdfFontEncoding.Unicode;
            gfx.MFEH = PdfFontEmbedding.Default;
            XFont font = new XFont("Cordia New", 16, XFontStyle.Bold);

            gfx.DrawString("The following paragraph was rendered using ภาษาภ", font, XBrushes.Black, new XRect(100, 100, page.Width - 200, 300), XStringFormats.Center);


            XPen pen = new XPen(XColors.Navy, Math.PI);

            gfx.DrawRectangle(pen, 10, 0, 100, 60);
            gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
            gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);



            Document document = new Document();
            Section  sec      = document.AddSection();

            //Paragraph para = sec.AddParagraph();
            //para.Format.Alignment = ParagraphAlignment.Justify;
            //para.Format.Font.Name = "Times New Roman";
            //para.Format.Font.Size = 12;
            //para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
            //para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
            //para.AddText("Duisism odigna acipsum delesenisl ");
            //para.AddFormattedText("ullum in velenit", TextFormat.Bold);
            //para.AddText(" ipit iurero dolum zzriliquisis nit wis dolore vel et nonsequipit, velendigna " +
            //  "auguercilit lor se dipisl duismod tatem zzrit at laore magna feummod oloborting ea con vel " +
            //  "essit augiati onsequat luptat nos diatum vel ullum illummy nonsent nit ipis et nonsequis " +
            //  "niation utpat. Odolobor augait et non etueril landre min ut ulla feugiam commodo lortie ex " +
            //  "essent augait el ing eumsan hendre feugait prat augiatem amconul laoreet. ≤≥≈≠");
            //para.Format.Borders.Distance = "5pt";
            //para.Format.Borders.Color = Colors.Gold;



            Paragraph paragraph = sec.AddParagraph();

            paragraph.Format.Font.Color = Color.FromCmyk(100, 30, 20, 50);

            paragraph.AddFormattedText("Hello,ไทย World!", TextFormat.Bold);
            paragraph.AddFormattedText("ทดสอบการใช้ภาษา", TextFormat.Italic);

            var logoPath = Path.Combine(_env.WebRootPath, "images");

            logoPath = Path.Combine(logoPath, "logo_t.png");
            Image imgLogo = sec.AddImage(logoPath);

            imgLogo.Height          = "2cm";
            imgLogo.LockAspectRatio = true;

            var memberPicPath = Path.Combine(_env.WebRootPath, "images_member");

            memberPicPath = Path.Combine(memberPicPath, "_2_1365148227.jpg");
            //memberPicPath = Path.Combine(memberPicPath, "_677138-topic-ix-1.jpg");
            Image imgMember = sec.AddImage(memberPicPath);

            imgMember.Height             = "5cm";
            imgMember.LockAspectRatio    = true;
            imgMember.RelativeVertical   = RelativeVertical.Line;
            imgMember.RelativeHorizontal = RelativeHorizontal.Margin;
            imgMember.Top              = ShapePosition.Top;
            imgMember.Left             = ShapePosition.Right;
            imgMember.WrapFormat.Style = WrapStyle.Through;



            //document.UseCmykColor = true;
            const bool             unicode     = true;
            const PdfFontEmbedding embedding   = PdfFontEmbedding.Always;
            PdfDocumentRenderer    pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();


            //MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(document);
            //MigraDoc.Rendering.DocumentRenderer docRenderer = pdfRenderer.DocumentRenderer;
            //docRenderer.PrepareDocument();

            //docRenderer.RenderObject(gfx, XUnit.FromCentimeter(5), XUnit.FromCentimeter(10), "12cm", paragraph);

            MemoryStream m = new MemoryStream();

            doc.Save(m, false);
            return(new FileStreamResult(m, "application/pdf"));
        }
 public XPdfFontOptions(PdfFontEmbedding fontEmbedding, bool unicode)
   : this(fontEmbedding == PdfFontEmbedding.Always || fontEmbedding == PdfFontEmbedding.Automatic,
   unicode, "", "")
 { }
        public bool GetPdfNow(int id, int radno, string thenum, string company, DateTime combined)
        {
            try
            {
                using (var db = new ImportPermitEntities())
                {
                    var log = new LogicObject();

                    var appItems = (from t in db.ApplicationItems.Include("Application")
                                    where t.ApplicationId == id
                                    orderby t.EstimatedValue descending

                                    select t).ToList();

                    if (!appItems.Any())
                    {
                        return(false);
                    }
                    var items = new List <DatabaseObject>();
                    appItems.ForEach(t =>
                    {
                        var im = new DatabaseObject()
                        {
                            Id = t.Id,
                            ApplicationItemId                = t.Id,
                            ApplicationItemProductName       = t.Product.Name,
                            ApplicationItemEstimatedQuantity = t.EstimatedQuantity,
                            ApplicationItemEstimatedValue    = t.EstimatedValue,
                        };
                        var appCountries = db.ApplicationCountries.Where(a => a.ApplicationItemId == im.Id).Include("Country").ToList();
                        var depotList    = db.ThroughPuts.Where(a => a.ApplicationItemId == im.Id).Include("Depot").ToList();
                        if (appCountries.Any() && depotList.Any())
                        {
                            im.ApplicationItemPortOfOrigin = "";
                            appCountries.ForEach(c =>
                            {
                                if (string.IsNullOrEmpty(im.ApplicationItemPortOfOrigin))
                                {
                                    im.ApplicationItemPortOfOrigin = c.Country.Name;
                                }
                                else
                                {
                                    im.ApplicationItemPortOfOrigin += ", " + c.Country.Name;
                                }
                            });

                            im.ApplicationItemPortOfDischarge = "";
                            depotList.ForEach(d =>
                            {
                                if (string.IsNullOrEmpty(im.ApplicationItemPortOfDischarge))
                                {
                                    im.ApplicationItemPortOfDischarge = d.Depot.Name;
                                }
                                else
                                {
                                    im.ApplicationItemPortOfDischarge += ", " + d.Depot.Name;
                                }
                            });

                            items.Add(im);
                        }
                    });


                    PdfDocument pdf = new PdfDocument();

                    //Next step is to create a an Empty page.

                    PdfPage pp = pdf.AddPage();



                    string path = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permitup.pdf");

                    //Then create an XGraphics Object

                    XGraphics gfx = XGraphics.FromPdfPage(pp);

                    XImage image = XImage.FromFile(path);
                    gfx.DrawImage(image, 0, 0);



                    XFont font  = new XFont("Calibri", 12, XFontStyle.Regular);
                    XFont font2 = new XFont("Calibri", 10, XFontStyle.Regular);


                    gfx.DrawString(thenum, font, XBrushes.Black, new XRect(392, 70, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);

                    gfx.DrawString(DateTime.Now.ToString("dd/MM/yy"), font, XBrushes.Black,
                                   new XRect(390, 95, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft);

                    gfx.DrawString("", font, XBrushes.Black, new XRect(70, 125, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);

                    gfx.DrawString("", font, XBrushes.Black, new XRect(70, 150, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);

                    gfx.DrawString("", font, XBrushes.Black, new XRect(60, 175, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);


                    gfx.DrawString(company, font, XBrushes.Black, new XRect(80, 218, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);

                    gfx.DrawString("", font, XBrushes.Black, new XRect(92, 240, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);



                    MigraDoc.DocumentObjectModel.Document doc = new MigraDoc.DocumentObjectModel.Document();

                    Section section = doc.AddSection();

                    var table = section.AddTable();



                    //table = section.AddTable();
                    table.Style = "Table";

                    table.Borders.Width       = 0.25;
                    table.Borders.Left.Width  = 0.5;
                    table.Borders.Right.Width = 0.5;
                    table.Rows.LeftIndent     = 0;

                    Column column = table.AddColumn("4cm");
                    column.Format.Alignment = ParagraphAlignment.Center;


                    column = table.AddColumn("4cm");
                    column.Format.Alignment = ParagraphAlignment.Center;

                    column = table.AddColumn("4cm");
                    column.Format.Alignment = ParagraphAlignment.Center;

                    column = table.AddColumn("4cm");
                    column.Format.Alignment = ParagraphAlignment.Center;



                    // Create the header of the table
                    Row row = table.AddRow();
                    //row = table.AddRow();
                    row.HeadingFormat    = true;
                    row.Format.Alignment = ParagraphAlignment.Center;
                    row.Format.Font.Bold = true;


                    row.Cells[0].AddParagraph("Type of Petroleum Product:");
                    row.Cells[0].Format.Alignment = ParagraphAlignment.Left;


                    row.Cells[1].AddParagraph("Country of origin:");
                    row.Cells[1].Format.Alignment = ParagraphAlignment.Left;

                    row.Cells[2].AddParagraph("Quantity/Weight (Metric Tones):");
                    row.Cells[2].Format.Alignment = ParagraphAlignment.Left;

                    row.Cells[3].AddParagraph("Estimated Value($):");
                    row.Cells[3].Format.Alignment = ParagraphAlignment.Left;

                    double total = 0;

                    if (items.Any() && items.Count() <= 7)
                    {
                        foreach (var item in items.ToList())
                        {
                            row = table.AddRow();
                            row.Cells[0].AddParagraph(item.ApplicationItemProductName);
                            row.Cells[0].Format.Alignment = ParagraphAlignment.Left;

                            total = total + item.ApplicationItemEstimatedValue;

                            row.Cells[1].AddParagraph(item.ApplicationItemPortOfOrigin);
                            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                            row.Cells[2].AddParagraph(item.ApplicationItemEstimatedQuantity.ToString());
                            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
                            row.Cells[3].AddParagraph(item.ApplicationItemEstimatedValue.ToString());
                            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
                        }
                    }
                    else if (items.Any() && items.Count() > 7)
                    {
                        foreach (var item in items.ToList())
                        {
                            row = table.AddRow();
                            row.Format.Font.Size = 8;
                            row.Cells[0].AddParagraph(item.ApplicationItemProductName);
                            row.Cells[0].Format.Alignment = ParagraphAlignment.Left;

                            total = total + item.ApplicationItemEstimatedValue;

                            row.Cells[1].AddParagraph(item.ApplicationItemPortOfOrigin);
                            row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
                            row.Cells[2].AddParagraph(item.ApplicationItemEstimatedQuantity.ToString());
                            row.Cells[2].Format.Alignment = ParagraphAlignment.Left;
                            row.Cells[3].AddParagraph(item.ApplicationItemEstimatedValue.ToString());
                            row.Cells[3].Format.Alignment = ParagraphAlignment.Left;
                        }
                    }

                    //convert total amount to words



                    var amtWords = log.ChangeToWords(total.ToString(), true);


                    const bool             unicode   = false;
                    const PdfFontEmbedding embedding = PdfFontEmbedding.Always;

                    PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

                    // Associate the MigraDoc document with a renderer

                    pdfRenderer.Document = doc;



                    // Layout and render document to PDF

                    pdfRenderer.RenderDocument();



                    var pathtable = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "table.pdf");

                    pdfRenderer.PdfDocument.Save(pathtable);

                    XImage imagetable = XImage.FromFile(pathtable);
                    gfx.DrawImage(imagetable, 0, 280);


                    //rigid style
                    XImage image2 = XImage.FromFile(System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permitdown.pdf"));
                    gfx.DrawImage(image2, 0, 550);


                    gfx.DrawString(amtWords, font2, XBrushes.Black, new XRect(135, 556, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);

                    gfx.DrawString("", font, XBrushes.Black, new XRect(238, 593, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);

                    gfx.DrawString("", font, XBrushes.Black, new XRect(220, 633, pp.Width.Point, pp.Height.Point),
                                   XStringFormats.TopLeft);

                    gfx.DrawString(DateTime.Now.ToString("dd/MM/yy"), font, XBrushes.Black,
                                   new XRect(100, 673, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft);

                    gfx.DrawString(combined.ToString("dd/MM/yy"), font, XBrushes.Black,
                                   new XRect(370, 673, pp.Width.Point, pp.Height.Point), XStringFormats.TopLeft);



                    string path2 = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permit" + radno + ".pdf");



                    //string path2 = System.IO.Path.Combine(Server.MapPath("~/PermDoc"), "permit.pdf");

                    pdf.Save(path2);


                    return(true);
                }
            }

            catch (Exception ex)
            {
                return(false);
            }
        }
Example #34
0
    /// <summary>
    /// Converts an DOM Font to an XFont.
    /// </summary>
    internal static XFont FontToXFont(Font font, XPrivateFontCollection pfc, 
      PdfFontEncoding encoding, PdfFontEmbedding fontEmbedding)
    {
      XFont xFont = null;
#if GDI____  // done in PDFsharp
#if CACHE_FONTS
      string signature = BuildSignature(font, unicode, fontEmbedding);
      xFont = fontCache[signature] as XFont;
      if (xFont == null)
      {
        XPdfFontOptions options = null;
        options = new XPdfFontOptions(fontEmbedding, unicode);
        XFontStyle style = GetXStyle(font);
        xFont = new XFont(font.Name, font.Size, style, options);
        fontCache[signature] = xFont;
      }
#else
      XPdfFontOptions options = null;
      options = new XPdfFontOptions(encoding, fontEmbedding);
      XFontStyle style = GetXStyle(font);
      if (pfc != null && pfc.PrivateFontCollection != null)
      {
        // Is it a private font?
        try
        {
          foreach (System.Drawing.FontFamily ff in pfc.PrivateFontCollection.Families)
          {
            if (String.Compare(ff.Name, font.Name, true) == 0)
            {
              xFont = new XFont(ff, font.Size, style, options, pfc);
              break;
            }
          }
        }
        catch
        {
#if DEBUG
          pfc.GetType();
#endif
        }
      }
#endif
#endif

#if WPF___
      XPdfFontOptions options = null;
      options = new XPdfFontOptions(encoding, fontEmbedding);
      XFontStyle style = GetXStyle(font);
      //if (pfc != null &&
      //  pfc.PrivateFontCollection != null)
      //{
      //  // Is it a private font?
      //  try
      //  {
      //    foreach (System.Drawing.FontFamily ff in pfc.PrivateFontCollection.Families)
      //    {
      //      if (String.Compare(ff.Name, font.Name, true) == 0)
      //      {
      //        xFont = new XFont(ff, font.Size, style, options, pfc);
      //        break;
      //      }
      //    }
      //  }
      //  catch
      //  {
      //  }
      //}
#endif

      // #PFC
      XPdfFontOptions options = null;
      options = new XPdfFontOptions(encoding, fontEmbedding);
      XFontStyle style = GetXStyle(font);

      if (xFont == null)
        xFont = new XFont(font.Name, font.Size, style, options);
#if DEBUG
      CreateFontCounter++;
#endif
      return xFont;
    }
Example #35
0
 public XPdfFontOptions(PdfFontEmbedding fontEmbedding, bool unicode)
     : this(fontEmbedding == PdfFontEmbedding.Always || fontEmbedding == PdfFontEmbedding.Automatic,
            unicode, "", "")
 {
 }
Example #36
0
 static string BuildSignature(Font font, bool unicode, PdfFontEmbedding fontEmbedding)
 {
   StringBuilder signature = new StringBuilder(128);
   signature.Append(font.Name.ToLower());
   signature.Append(font.Size.Point.ToString("##0.0"));
   return signature.ToString();
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XPdfFontOptions"/> class.
 /// </summary>
 public XPdfFontOptions(PdfFontEncoding encoding, PdfFontEmbedding embedding)
 {
     fontEncoding  = encoding;
     fontEmbedding = embedding;
 }
Example #38
0
        public static void ConsignmentContract(string filePath, string logoPath, string title, string author, string subject, Address lelandsAddress, string lelandsSignaturePath, Address sellerAddress, string sellerEmail, string sellerSignaturePath, DateTime date, List <ConsignmentDetail> items, string contract)
        {
            Document document = new Document();

            document.Info.Title   = title;
            document.Info.Author  = author;
            document.Info.Subject = subject;

            Section section = document.AddSection();
            Table   table   = section.AddTable();

            table.Style = "Table";
            Column column = table.AddColumn("5cm");

            column.Format.Alignment = ParagraphAlignment.Left;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Left;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            Row row = table.AddRow();

            row.HeadingFormat    = true;
            row.Format.Alignment = ParagraphAlignment.Center;
            row.Format.Font.Bold = true;
            Image image = row.Cells[0].AddImage(logoPath);

            image.LockAspectRatio    = true;
            image.RelativeVertical   = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top                      = ShapePosition.Top;
            image.Left                     = ShapePosition.Left;
            image.WrapFormat.Style         = WrapStyle.Through;
            row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Top;
            row.Cells[0].MergeDown         = 5;

            Paragraph paragraph = row.Cells[1].AddParagraph();

            paragraph.AddText("Consignment Agreement Between");
            row.Cells[1].Format.Alignment = ParagraphAlignment.Center;
            row.Cells[1].MergeRight       = 1;

            row = table.AddRow();
            row.Cells[1].AddParagraph(lelandsAddress.FirstName);
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[1].Format.Font.Bold = true;
            row.Cells[2].AddParagraph(string.Format("{0} {1}", sellerAddress.FirstName, sellerAddress.LastName));
            row.Cells[2].Format.Font.Size = 9;
            row.Cells[2].Format.Font.Bold = true;

            row = table.AddRow();
            row.Cells[1].AddParagraph(lelandsAddress.Address_1);
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("{0} {1}", sellerAddress.Address_1, sellerAddress.Address_2));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(string.Format("{0}, {1} {2}", lelandsAddress.City, lelandsAddress.State, lelandsAddress.Zip));
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("{0}, {1} {2}", sellerAddress.City, sellerAddress.State, sellerAddress.Zip));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(string.Format("Tel: {0}", lelandsAddress.HomePhone));
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("Tel (Home): {0}", sellerAddress.HomePhone));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(string.Format("Fax: {0}", lelandsAddress.WorkPhone));
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(string.Format("Tel (Work): {0}", !string.IsNullOrWhiteSpace(sellerAddress.WorkPhone) ? sellerAddress.WorkPhone : "---"));
            row.Cells[2].Format.Font.Size = 9;

            row = table.AddRow();
            row.Cells[1].AddParagraph(lelandsAddress.LastName);
            row.Cells[1].Format.Font.Size = 9;
            row.Cells[2].AddParagraph(sellerEmail);
            row.Cells[2].Format.Font.Size = 9;


            paragraph = section.Footers.Primary.AddParagraph();
            paragraph.AddText(string.Format("{0} - {1}", author, DateTime.Now.Year));
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            section.AddParagraph(" ");
            paragraph = section.AddParagraph();
            paragraph.Format.Font.Bold = true;
            paragraph.AddText("SCHEDULE A");
            paragraph.AddLineBreak();
            paragraph.AddText("PROPERTY");
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            table = section.AddTable();
            table.Borders.Color = new Color(0, 0, 0);
            table.Borders.Width = 0.5;
            table.Style         = "Table";
            column = table.AddColumn("13cm");
            column.Format.Font.Size = 8;
            column = table.AddColumn("4cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column.Format.Font.Size = 8;
            row = table.AddRow();
            row.Cells[0].AddParagraph("Description");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[1].AddParagraph("Seller's Reserve");
            row.Cells[1].Format.Font.Bold = true;
            foreach (var item in items)
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph(string.Format("{0}{1}", item.LinkParams.Lot > 0 ? string.Format("Lot {0}. ", item.LinkParams.Lot) : string.Empty, item.LinkParams.Title));
                row.Cells[0].Format.Font.Size = 7;
                row.Cells[1].AddParagraph(item.Reserve.GetCurrency(false));
                row.Cells[1].Format.Font.Size = 7;
            }
            var y = 38 - items.Count;

            for (int i = 0; i < y; i++)
            {
                table.AddRow();
            }

            section.AddParagraph(" ");
            paragraph = section.AddParagraph();
            paragraph.Format.Font.Bold = true;
            paragraph.AddText("Seller agrees with the foregoing, and agrees to keep confidential all of the terms and conditions of this agreement by signing in the space provided below:");
            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Format.Font.Size = 7;

            section.AddParagraph(" ");
            section.AddParagraph(" ");

            table  = section.AddTable();
            column = table.AddColumn("3cm");
            column.Format.Alignment = ParagraphAlignment.Right;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            column = table.AddColumn("6cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            row = table.AddRow();
            row.Cells[0].AddParagraph("Date:");
            row.Cells[0].Format.Font.Size = 6;
            paragraph = row.Cells[1].AddParagraph(date.ToShortDateString());
            paragraph.Format.Font.Size = 6;
            paragraph.AddLineBreak();
            FormattedText formattedText;

            if (string.IsNullOrWhiteSpace(sellerSignaturePath))
            {
                formattedText             = paragraph.AddFormattedText("___________________________");
                formattedText.Superscript = true;
                formattedText.Font.Size   = 10;
            }
            row = table.AddRow();
            row.Cells[0].AddParagraph("Agreed to by:");
            row.Cells[0].Format.Font.Size  = 6;
            row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
            row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
            if (string.IsNullOrWhiteSpace(sellerSignaturePath))
            {
                paragraph                 = row.Cells[1].AddParagraph();
                formattedText             = paragraph.AddFormattedText("___________________________");
                formattedText.Superscript = true;
            }
            else
            {
                row.Cells[1].AddImage(sellerSignaturePath);
            }
            paragraph                      = row.Cells[1].AddParagraph();
            formattedText                  = paragraph.AddFormattedText("Seller");
            formattedText.Superscript      = true;
            row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
            row.Cells[2].AddImage(lelandsSignaturePath);
            paragraph                 = row.Cells[2].AddParagraph();
            formattedText             = paragraph.AddFormattedText("Lelands.com");
            formattedText.Superscript = true;

            section = document.AddSection();

            paragraph = section.AddParagraph("TERMS & CONDITIONS");
            paragraph.Format.Alignment  = ParagraphAlignment.Center;
            paragraph.Format.Font.Bold  = true;
            paragraph.Format.Font.Size  = 10;
            paragraph.Format.SpaceAfter = 15;

            string[] lines = contract.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
            foreach (var line in lines)
            {
                paragraph = section.AddParagraph(line);
                paragraph.Format.Font.Size  = 8;
                paragraph.Format.SpaceAfter = 10;
                //section.AddParagraph(" ");
            }

            // A flag indicating whether to create a Unicode PDF or a WinAnsi PDF file.
            // This setting applies to all fonts used in the PDF document.
            // This setting has no effect on the RTF renderer.
            bool unicode = true;

            // An enum indicating whether to embed fonts or not.
            // This setting applies to all font programs used in the document.
            // This setting has no effect on the RTF renderer.
            // (The term 'font program' is used by Adobe for a file containing a font. Technically a 'font file'
            // is a collection of small programs and each program renders the glyph of a character when executed.
            // Using a font in PDFsharp may lead to the embedding of one or more font programms, because each outline
            // (regular, bold, italic, bold+italic, ...) has its own fontprogram)
            PdfFontEmbedding embedding = PdfFontEmbedding.Always; // Set to PdfFontEmbedding.None or PdfFontEmbedding.Always only

            // ----------------------------------------------------------------------------------------
            // Create a renderer for the MigraDoc document.
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

            // Associate the MigraDoc document with a renderer
            pdfRenderer.Document = document;
            // Layout and render document to PDF
            pdfRenderer.RenderDocument();

            // Save the document...
            pdfRenderer.PdfDocument.Save(filePath);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="XPdfFontOptions"/> class.
 /// </summary>
 public XPdfFontOptions(PdfFontEmbedding embedding)
 {
   this.fontEncoding = PdfFontEncoding.WinAnsi;
   this.fontEmbedding = embedding;
 }