Beispiel #1
0
        public void Can_easily_construct_with_all_options_set()
        {
            var lines = new List <HeaderFooterLine>
            {
                new HeaderFooterLine {
                    Left = "Acme, Inc.", Center = "Page 1 of 10", Right = "28 Aug 2019"
                },
                new HeaderFooterLine {
                    Center = "CONFIDENTIAL"
                },
                new HeaderFooterLine {
                    Left = "Acme"
                },
                new HeaderFooterLine {
                    Left = "123 Anvil St"
                },
                new HeaderFooterLine {
                    Left = "Somewhere, AZ 98765"
                },
            };

            var options = new HeaderFooterOptions
            {
                Lines      = lines,
                FontFamily = "Lexicon",
                FontSize   = "12pt",
                Color      = "#FF0000",
            };

            Assert.AreEqual(lines, options.Lines);
            Assert.AreEqual("Lexicon", options.FontFamily);
            Assert.AreEqual("12pt", options.FontSize);
            Assert.AreEqual("#FF0000", options.Color);
        }
Beispiel #2
0
        public void Can_easily_construct_with_no_options_set()
        {
            var options = new HeaderFooterOptions();

            Assert.IsNull(options.Lines);
            Assert.IsNull(options.FontFamily);
            Assert.IsNull(options.FontSize);
            Assert.IsNull(options.Color);
        }
Beispiel #3
0
 /// <summary>
 /// Convert pages of a single source document to PDF.
 /// <para>
 /// Convenience wrapper for <see cref="ConvertAsync(IEnumerable{ConversionSourceDocument}, DestinationOptions)" />, returning a single <see cref="ConversionResult" />.
 /// </para>
 /// </summary>
 /// <param name="sourceDocument">Information about the source document to
 /// use as input.</param>
 /// <param name="header">Header to be appended to each page of the output
 /// document. The original page content will be left unaltered. The overall
 /// page dimensions will be expanded to accommodate the header
 /// content.</param>
 /// <param name="footer">Footer to be appended to each page of the output
 /// document. The original page content will be left unaltered. The overall
 /// page dimensions will be expanded to accommodate the footer
 /// content.</param>
 /// <returns>ConversionResult for the created PDF.</returns>
 /// <seealso cref="ConvertAsync(ConversionSourceDocument, DestinationOptions)" />
 public Task <ConversionResult> ConvertToPdfAsync(ConversionSourceDocument sourceDocument, HeaderFooterOptions header = null, HeaderFooterOptions footer = null) =>
 this.CombineToPdfAsync(new ConversionSourceDocument[] { sourceDocument }, header, footer);
Beispiel #4
0
 /// <summary>
 /// Convert a local file to PDF.
 /// <para>
 /// Convenience wrapper for <see cref="ConvertAsync(IEnumerable{ConversionSourceDocument}, DestinationOptions)" />, returning a single <see cref="ConversionResult" />.
 /// </para>
 /// </summary>
 /// <param name="localFilePath">Path to a local file to use as
 /// input.</param>
 /// <param name="header">Header to be appended to each page of the output
 /// document. The original page content will be left unaltered. The overall
 /// page dimensions will be expanded to accommodate the header
 /// content.</param>
 /// <param name="footer">Footer to be appended to each page of the output
 /// document. The original page content will be left unaltered. The overall
 /// page dimensions will be expanded to accommodate the footer
 /// content.</param>
 /// <returns>ConversionResult for the created PDF.</returns>
 /// <seealso cref="ConvertAsync(string, DestinationOptions)" />
 public Task <ConversionResult> ConvertToPdfAsync(string localFilePath, HeaderFooterOptions header = null, HeaderFooterOptions footer = null) =>
 this.ConvertToPdfAsync(new ConversionSourceDocument(localFilePath), header, footer);
Beispiel #5
0
 /// <summary>
 /// Combine pages from a collection of source documents into a PDF.
 /// <para>
 /// Convenience wrapper for <see cref="ConvertAsync(IEnumerable{ConversionSourceDocument}, DestinationOptions)" />, returning a single <see cref="ConversionResult" />.
 /// </para>
 /// </summary>
 /// <param name="sourceDocuments">Collection of source documents whose pages
 /// should be combined, in order, to form the output.</param>
 /// <param name="header">Header to be appended to each page of the output
 /// document. The original page content will be left unaltered. The overall
 /// page dimensions will be expanded to accommodate the header
 /// content.</param>
 /// <param name="footer">Footer to be appended to each page of the output
 /// document. The original page content will be left unaltered. The overall
 /// page dimensions will be expanded to accommodate the footer
 /// content.</param>
 /// <returns>ConversionResult for the created PDF.</returns>
 /// <seealso cref="ConvertAsync(string, DestinationOptions)" />
 public async Task <ConversionResult> CombineToPdfAsync(IEnumerable <ConversionSourceDocument> sourceDocuments, HeaderFooterOptions header = null, HeaderFooterOptions footer = null)
 {
     return((await this.ConvertAsync(sourceDocuments, new DestinationOptions(DestinationFileFormat.Pdf)
     {
         Header = header,
         Footer = footer,
     })).Where(x => x.IsSuccess).Single());
 }