2013-07-08 2 views
1

asp.net에서 두 개 이상의 PDF를 병합 할 수 있습니까? 나는 interop을 사용하여 파일을 능가한다는 말을 할 수 있습니다. 하지만 PDF를 병합 할 수 있습니까? 제안 사항이나 링크를 제안하십시오.asp.net의 PDF 병합 C#

감사합니다.

+0

는 http://www.dotnetspider.com/resources/36210-Merge-PDF-File-using-itextsharp-library.aspx는 수도가 당신에게 도움이 여기에 –

+0

@pratapk을 살펴 보자 : 멋진을 ..! ! 다 .. 고마워요. – Ankur

답변

3

iTextSharp을 시도해보십시오

iTextSharp는 iText를의 C#을 포트이며, PDF 생성 및 조작을위한 오픈 소스 자바 라이브러리. 분할, 기존의 PDF 문서에 새로운 내용 을 스탬프, 대화 형 PDF 양식을 작성, PDF로 XML (추가 XFA 작업자 DLL을 사용하여) 변환, PDF를 처음부터 문서를 작성하는 데 사용 병합 할 수있다 기존의 PDF 문서, 및 훨씬 더.

Here's an article.

+0

멋진 .. !! 다 .. 고마워. !! – Ankur

+0

제안한 코드를 사용하여 PDF 만 병합하거나 다른 형식도 병합 할 수 있습니까? 또는 doc에서 pdf 또는 .xls to pdf. 이러한 작업을 수행 할 수 있습니까? – Ankur

+0

죄송합니다, iTextSharp는 html, xml 또는 프로그래밍 방식으로 만 PDF를 만들 수 있습니다. 여기에 설명 된 방법을 사용하여 LibreOffice를 사용하여 문서를 PDF로 변환 할 수 있습니다. http://kgsspot.blogspot.ca/2011/09/convert-doc-to-pdf-in-command-line.html –

-3

넵, iTextSharp를 사용하면 PDF 파일을 병합하고 병합 할 수 있습니다. PDfWriter, Document, Paragraph 클래스를 사용하여 요구 사항을 충족 할 수 있습니다.

+0

감사합니다. 링크를 제공해 줄 수 있습니까? – Ankur

+0

PDF Aricles의 http://www.codeproject.com을 방문 할 수 있습니다. 다른 형식을 PDf로 변환하려는 경우 동일한 작업을 수행 할 수 있습니다. doc, xls 파일을 pdf로 변환하려면 먼저 doc, xls를 Microsoft interop을 통해 jpg 파일로 변환 한 다음 jpg 이미지를 iTextSharp를 사용하여 PDF로 쉽게 변환 할 수 있습니다. –

0
using System.Text.RegularExpressions; 
using iTextSharp.text.pdf; 
using iTextSharp.text.pdf.parser; 
using iTextSharp.text; 
//Call this method in main with parameter 
public static void MergePages(string outputPdfPath, string[] lstFiles) 
{ 
    PdfReader reader = null; 
    Document sourceDocument = null; 
    PdfCopy pdfCopyProvider = null; 
    PdfImportedPage importedPage; 
    sourceDocument = new Document(); 
    pdfCopyProvider = new PdfCopy(sourceDocument, 
    new System.IO.FileStream(outputPdfPath, System.IO.FileMode.Create)); 
    sourceDocument.Open(); 
    try 
    { 
     for (int f = 0; f < lstFiles.Length - 1; f++) 
     { 
      int pages = 1; 
      reader = new PdfReader(lstFiles[f]); 
      //Add pages of current file 
      for (int i = 1; i <= pages; i++) 
      { 
       importedPage = pdfCopyProvider.GetImportedPage(reader, i); 
       pdfCopyProvider.AddPage(importedPage); 
      } 
      reader.Close(); 
     } 
     sourceDocument.Close(); 
    } 
    catch (Exception ex) 
    { 
     throw ex; 
    } 
}