예제 #1
0
        /// <summary>
        /// Concatenate PDF
        /// </summary>
        /// <param name="outputDocument">
        /// Pdf Document
        /// </param>
        /// <param name="applicationData">
        /// Content Data
        /// </param>
        /// <returns></returns>
        public static PdfDocument ConcatenatePDFs(PdfDocument outputDocument, PDFContentData applicationData)
        {
            if (!string.IsNullOrEmpty(applicationData.Type))
            {
                // Create PDF file
                if (applicationData.Type.ToLower().Contains("pdf"))
                {
                    outputDocument = ConcatenatePDFDocumentByBytes(outputDocument, applicationData.Buffer, applicationData.FileName);
                }

                // Create PDF image
                if (applicationData.Type.ToLower().Contains("image"))
                {
                    var doc = CreatePDFWithImage(applicationData.Buffer, applicationData.FileName);
                    AddPagesToPdf(ref outputDocument, doc);
                }

                if (applicationData.Type.ToLower().Contains("html") && applicationData.HtmlString != null)
                {
                    foreach (var htmlString in applicationData.HtmlString)
                    {
                        if (!string.IsNullOrEmpty(htmlString))
                        {
                            var doc = GetPdfDocFromHtml(outputDocument, htmlString);
                            AddPagesToPdf(ref outputDocument, doc);
                        }
                    }
                }
            }

            if (applicationData.FilePaths != null)
            {
                outputDocument = ConcatenatePDFDocumentByPath(outputDocument, applicationData.FilePaths);
            }

            return(outputDocument);
        }