Exemplo n.º 1
0
        private static void Merge(IReadOnlyList <PdfDocument> files, Stream output, IReadOnlyList <IReadOnlyList <int> > pagesBundle)
        {
            var maxVersion = files.Select(x => x.Version).Max();

            using (var document = new PdfDocumentBuilder(output, false, PdfWriterType.Default, maxVersion))
            {
                foreach (var fileIndex in Enumerable.Range(0, files.Count))
                {
                    var existing = files[fileIndex];
                    IReadOnlyList <int> pages = null;
                    if (pagesBundle != null && fileIndex < pagesBundle.Count)
                    {
                        pages = pagesBundle[fileIndex];
                    }

                    if (pages == null)
                    {
                        for (var i = 1; i <= existing.NumberOfPages; i++)
                        {
                            document.AddPage(existing, i);
                        }
                    }
                    else
                    {
                        foreach (var i in pages)
                        {
                            document.AddPage(existing, i);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 internal PdfPageBuilder(int number, PdfDocumentBuilder documentBuilder, IEnumerable <CopiedContentStream> copied,
                         Dictionary <NameToken, IToken> pageDict)
 {
     this.documentBuilder = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder));
     PageNumber           = number;
     pageDictionary       = pageDict;
     contentStreams       = new List <IPageContentStream>();
     contentStreams.AddRange(copied);
     currentStream = new DefaultContentStream();
     contentStreams.Add(currentStream);
 }
Exemplo n.º 3
0
        internal PdfPageBuilder(int number, PdfDocumentBuilder documentBuilder)
        {
            this.documentBuilder = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder));
            PageNumber           = number;

            currentStream  = new DefaultContentStream();
            contentStreams = new List <IPageContentStream>()
            {
                currentStream
            };
        }
Exemplo n.º 4
0
 internal PdfPageBuilder(int number, PdfDocumentBuilder documentBuilder)
 {
     this.documentBuilder = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder));
     PageNumber           = number;
     Advanced             = new AdvancedEditing(operations);
 }
Exemplo n.º 5
0
 public PdfPageBuilder(int number, PdfDocumentBuilder documentBuilder)
 {
     this.documentBuilder = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder));
     PageNumber           = number;
 }