Ejemplo n.º 1
0
        private static DocX CreateInvoiceFromTemplate(DocX templateDoc)
        {
            // Fill in the document custom properties.
            templateDoc.AddCustomProperty(new CustomProperty("InvoiceNumber", 1355));
            templateDoc.AddCustomProperty(new CustomProperty("InvoiceDate", new DateTime(2016, 10, 15).ToShortDateString()));
            templateDoc.AddCustomProperty(new CustomProperty("CompanyName", "Toms Telecoms"));
            templateDoc.AddCustomProperty(new CustomProperty("CompanySlogan", "Always with you"));
            templateDoc.AddCustomProperty(new CustomProperty("ClientName", "James Doh"));
            templateDoc.AddCustomProperty(new CustomProperty("ClientStreetName", "123 Main street"));
            templateDoc.AddCustomProperty(new CustomProperty("ClientCity", "Springfield, Ohio"));
            templateDoc.AddCustomProperty(new CustomProperty("ClientZipCode", "54789"));
            templateDoc.AddCustomProperty(new CustomProperty("ClientPhone", "438-585-9636"));
            templateDoc.AddCustomProperty(new CustomProperty("ClientMail", "*****@*****.**"));
            templateDoc.AddCustomProperty(new CustomProperty("CompanyStreetName", "1458 Thompson Road"));
            templateDoc.AddCustomProperty(new CustomProperty("CompanyCity", "Los Angeles, California"));
            templateDoc.AddCustomProperty(new CustomProperty("CompanyZipCode", "90210"));
            templateDoc.AddCustomProperty(new CustomProperty("CompanyPhone", "1-965-434-5786"));
            templateDoc.AddCustomProperty(new CustomProperty("CompanySupport", "*****@*****.**"));

            // Remove the default logo and add the new one.
            var paragraphWithDefaultLogo = MiscellaneousSample.GetParagraphContainingPicture(templateDoc);

            if (paragraphWithDefaultLogo != null)
            {
                paragraphWithDefaultLogo.Pictures.First().Remove();
                var newLogo = templateDoc.AddImage(MiscellaneousSample.MiscellaneousSampleResourcesDirectory + @"Phone.png");
                paragraphWithDefaultLogo.AppendPicture(newLogo.CreatePicture(60, 180));
            }

            // Fill the details table.
            MiscellaneousSample.FillDetailsTable(ref templateDoc);

            return(templateDoc);
        }