2011-08-03 2 views
2

C# 프로그래밍을 통해 테이블 ​​내용 만 Excel로 내보내려면 어떻게합니까? 현재 PDFNET SDK를 사용하여 PDF에서 모든 내용을 추출하고 있지만 표를 표 형식의 구조로 읽을 수 없습니다.pdf에서 표를 내보내 Excel로 내보내기 하시겠습니까?

+0

PDF로 된 실제 테이블 구조가 없습니다. 기본적으로 어떤 종류의 "표 인식"에 의존해야합니다 ... 정의에 따라 일부 정확하고 잘못된 결과가 나타납니다. – Yahia

답변

2

나는 위의 솔루션을 시도했지만 그것을 밖으로 만들 수 없습니다. 너무 많은 무료 SDK 또는 DLL을 pdfnet, pdfclown, itextsharp, pdfbox, pdflib와 같이 사용할 수 있습니다. 마지막으로 pdfnet sdk로 다시 시도해 보았습니다. 내 입력 PDF가 pdf 형식의 태그 인 경우이를 수행 할 수 있습니다.

+0

word.bbox() 및 line.bbox()를 사용하여 ... –

0

우리가 아래로 전체 페이지를 추출 할 수 있습니다 bytescount PDF 추출기 SDK를 사용하여,

 CSVExtractor extractor = new CSVExtractor(); 
     extractor.RegistrationName = "demo"; 
     extractor.RegistrationKey = "demo"; 

     TableDetector tdetector = new TableDetector(); 
     tdetector.RegistrationKey = "demo"; 
     tdetector.RegistrationName = "demo"; 

      // Load the document 
     extractor.LoadDocumentFromFile("C:\\sample.pdf"); 
     tdetector.LoadDocumentFromFile("C:\\sample.pdf"); 

      int pageCount = tdetector.GetPageCount(); 

      for (int i = 1; i <= pageCount; i++) 
      { 
       int j = 1; 

        do 
        { 
          extractor.SetExtractionArea(tdetector.GetPageRect_Left(i), 
          tdetector.GetPageRect_Top(i), 
          tdetector.GetPageRect_Width(i), 
          tdetector.GetPageRect_Height(i) 
         ); 

         // and finally save the table into CSV file 
         extractor.SavePageCSVToFile(i, "C:\\page-" + i + "-table-" + j + ".csv"); 
         j++; 
        } while (tdetector.FindNextTable()); // search next table 
      } 

가 이전 게시물이기 때문에, 그것은 다른 사람을 도움이되기를 바랍니다.

0

위의 답변 (John)은 효과적입니다.

하지만 코드를 사용하는 대신 bytescount PDF Extrator SDK 도구를 사용합니다.

그런데이 도구는 하나의 Excel 파일에 많은 시트를 생성합니다.

아래 코드를 Excel에서 사용하면 하나의 시트로 생성 할 수 있습니다.

Sub ConvertAsOne() 
Application.ScreenUpdating = False 
For j = 1 To Sheets.Count 
If Sheets(j).Name <> ActiveSheet.Name Then 
    X = Range("A65536").End(xlUp).Row + 1 
    Sheets(j).UsedRange.Copy Cells(X, 1) 
End If 
Next 
Range("B1").Select 
Application.ScreenUpdating = True 
MsgBox "succeed!", vbInformation, "note" 
End Sub