관리자 (또는 사용자)가 채워진 하나의 PDF 양식이 있습니다.
생성 된 PDF를 병합하고 싶습니다.
간단한 병합 작업을 수행했지만 먼저 여러 파일을 생성 한 다음 병합해야합니다.
사용자가 여러 양식을 채운 다음 최종 제출 또는 인쇄 할 때 채워진 PDF가 하나만 병합되는 방식이 있습니까?
병합하고 싶습니다 여러 번 채워진 PDF 양식
답변
PDF 파일을 병합이 병합 기능을 사용 해보세요 :
public static void Merge(string[] sourceFiles, string destinationFile)
{
try
{
int f = 0;
// we create a reader for a certain document
PdfReader reader = new PdfReader(sourceFiles[f]);
// we retrieve the total number of pages
int n = reader.NumberOfPages;
//Debug.WriteLine("There are " + n + " pages in the original file.");
// step 1: creation of a document-object
Document document = new Document(reader.GetPageSizeWithRotation(1));
// step 2: we create a writer that listens to the document
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(destinationFile, FileMode.Create));
// step 3: we open the document
document.Open();
PdfContentByte cb = writer.DirectContent;
PdfImportedPage page;
int rotation;
// step 4: we add content
while (f < sourceFiles.Length)
{
int i = 0;
while (i < n)
{
i++;
document.SetPageSize(reader.GetPageSizeWithRotation(i));
document.NewPage();
page = writer.GetImportedPage(reader, i);
rotation = reader.GetPageRotation(i);
if (rotation == 90 || rotation == 270)
{
cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(i).Height);
}
else
{
cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
}
//Debug.WriteLine("Processed page " + i);
}
f++;
if (f < sourceFiles.Length)
{
reader = new PdfReader(sourceFiles[f]);
// we retrieve the total number of pages
n = reader.NumberOfPages;
//Debug.WriteLine("There are " + n + " pages in the original file.");
}
}
// step 5: we close the document
document.Close();
}
catch (Exception ex)
{
throw ex;
}
}
나는 위의 내 의견에 링크 된 원래 포스터에서 코드의 뻔뻔스러운 추출을 위해 당신을 뽑았다. 소싱 및 링크를 추가하면 아래 표가 제거됩니다. – Hardrada
@Hardrada, 여기에서 내 프로젝트 중 하나에서이 코드 조각을 사용했습니다. http://www.khswsoft.be/Blog/tabid/81/EntryId/16/Merge-PDF-Files-using-iTextSharp.aspx and http : //khsw.blogspot.com/2006/04/merge-pdf-files-using-itextsharp.html –
아주 좋습니다. 제거 된 투표 – Hardrada
내가 쓸이를 사용하여 내가 위에서 내 의견에 공급 병합 코드 .. 를 기반으로 http 응답의 출력 스트림. 바이트 []를 반환하지만 원래 코드와이 코드를 사용하여 작업을 완료 할 수 있습니다. 여기
public static byte[] MergeFiles(List<byte[]> sourceFiles)
{
Document document = new Document();
MemoryStream output = new MemoryStream();
try
{
// Initialize pdf writer
PdfWriter writer = PdfWriter.GetInstance(document, output);
// Open document to write
document.Open();
PdfContentByte content = writer.DirectContent;
// Iterate through all pdf documents
for (int fileCounter = 0; fileCounter < sourceFiles.Count; fileCounter++)
{
// Create pdf reader
PdfReader reader = new PdfReader(sourceFiles[fileCounter]);
int numberOfPages = reader.NumberOfPages;
// Iterate through all pages
for (int currentPageIndex = 1; currentPageIndex <=
numberOfPages; currentPageIndex++)
{
// Determine page size for the current page
document.SetPageSize(
reader.GetPageSizeWithRotation(currentPageIndex));
// Create page
document.NewPage();
PdfImportedPage importedPage =
writer.GetImportedPage(reader, currentPageIndex);
// Determine page orientation
int pageOrientation = reader.GetPageRotation(currentPageIndex);
if ((pageOrientation == 90) || (pageOrientation == 270))
{
content.AddTemplate(importedPage, 0, -1f, 1f, 0, 0,
reader.GetPageSizeWithRotation(currentPageIndex).Height);
}
else
{
content.AddTemplate(importedPage, 1f, 0, 0, 1f, 0, 0);
}
}
}
}
catch (Exception exception)
{
throw new Exception("There has an unexpected exception" +
" occured during the pdf merging process.", exception);
}
finally
{
document.Close();
}
return output.GetBuffer();
}
- 1. 채워진 PDF 양식 데이터 캡처
- 2. PDF 원형으로 채워진 채워진 원을 어떻게 그리나요?
- 3. 여러 번 양식 게시 방지하기
- 4. kinect RGB보기를 사용하여 kinect 해골보기를 병합하고 싶습니다.
- 5. 대량 PDF 양식 채우기
- 6. 여러 NotesViewEntryCollection을 병합하고 날짜순 정렬
- 7. 필드가 채워진 양식 다시 표시
- 8. PDF 양식 제출
- 9. pdf 채워진 템플렛 모양은 엑셀 또는 CSV로 개조합니까?
- 10. 여러 번 제출하는 Ajax 양식. 가끔
- 11. 양식 필드를 여러 번 유효성 검사
- 12. 양식 제출시 동일한 조치를 여러 번 호출하십시오.
- 13. 여러 번 제출하는 jQuery ajax 양식
- 14. 이전 변수로 채워진 양식 값
- 15. 여러 번 .live 트리거링
- 16. C/C++에서 동일한 파이프에 여러 번 쓰고 싶습니다.
- 17. 어떻게 테스트할까요? 다양한 조건에서 여러 번 사양을 테스트하고 싶습니다.
- 18. 여러 번 문자열 표시
- 19. 두 개의 서로 다른 그리드의 데이터를 병합하고 싶습니다.
- 20. 코드를 통해 PDF 내부에서 PDF 양식 필드 데이터를 게시하려면 어떻게합니까?
- 21. 양식 필드가있는 여러 페이지에 권장되는 .NET PDF 렌더러
- 22. ColdFusion에서 CFPDF를 사용하여 PDF 양식 필드의 이름을 바꿀 수 있습니까?
- 23. php 문의 양식 - 데이터베이스에서 채워진 부분
- 24. iTextSharp로 PDF 양식 복사하기
- 25. iOS PDF 양식 필드
- 26. pdf 양식 필드 추가
- 27. PDF PHP로 작성된 양식
- 28. 안드로이드에서 PDF 양식 작성
- 29. PDF 양식 FPDF로 채우기
- 30. 실버 PDF 양식 편집기
당신은 갈 : http://stackoverflow.com/questions/6196124/merge-pdf-files – Hardrada
내가 모두를 추가하려는 결국 다음 여러 번 작성하고 하나 개의 소스 파일이 채워질 파일을 병합 할 수 있습니다. –
많은 사람들이 여러 번 사용하여 하나의 폴더에 'n'개의 파일을 생성 할 수있는 하나의 양식 서식 파일을 갖고 있다는 귀하의 질문을 이해합니다. 그들을 병합하고 싶습니다. 내가 게시 한 링크는 itextsharp 및 병합에만 해당됩니다. 나는 이것을 전에 사용했는데 훌륭하게 작동합니다. – Hardrada