示例#1
0
 private static void Unify(IEnumerable <DocumentRequest> requests, string resultPath)
 {
     using (Pdf pdfWriter = Pdf.CreateWriter(resultPath))
     {
         foreach (DocumentRequest request in requests)
         {
             Add(request, pdfWriter);
         }
     }
 }
示例#2
0
 private static void Add(DocumentRequest source, Pdf targetWriter)
 {
     using (Pdf pdfReader = Pdf.CreateReader(source.Path))
     {
         for (uint i = 0; i < source.Amount; ++i)
         {
             targetWriter.AddAllPages(pdfReader);
         }
     }
 }
        public static Pdf CreateReader(string inputPath)
        {
            var pdf = new Pdf();

            var reader = new PdfReader(inputPath);

            pdf._document = new PdfDocument(reader);

            pdf._document.SetCloseReader(true);

            return(pdf);
        }
        public static Pdf CreateWriter(string outputPath)
        {
            var pdf = new Pdf();

            var writer = new PdfWriter(outputPath);

            pdf._document = new PdfDocument(writer);

            pdf._document.SetCloseWriter(true);

            return(pdf);
        }
示例#5
0
        public async Task DownloadAsync(DocumentInfo info, string resultPath)
        {
            using (Pdf pdfWriter = Pdf.CreateWriter(resultPath))
            {
                using (var temp = new TempFile())
                {
                    using (var stream = new MemoryStream())
                    {
                        await SetupStreamAsync(stream, info);

                        using (var fileStream = new FileStream(temp.Path, FileMode.Open))
                        {
                            stream.WriteTo(fileStream);
                        }
                    }

                    using (Pdf pdfReader = Pdf.CreateReader(temp.Path))
                    {
                        pdfWriter.AddAllPages(pdfReader);
                    }
                }
            }
        }
 public void AddAllPages(Pdf pdf) => pdf._document.CopyPagesTo(1, pdf.GetPagesAmount(), _document);