2013-06-18 3 views
3

MSword에서 PDF 추출로 파일을 변환 한 후 오류가 발생했습니다. PDF 헤더 서명을 찾을 수 없습니다.오류 PDF 헤더 서명을 찾을 수 없음

public void Extract_inputpdf() 
{ 
    text_input_File = string.Empty; 

    StringBuilder sb_inputpdf = new StringBuilder(); 
    PdfReader reader_inputPdf = new PdfReader(path); //read PDF 
    for (int i = 0; i <=reader_inputPdf.NumberOfPages ; i++) 
    { 
     TextWithFont_inputPdf inputpdf = new TextWithFont_inputPdf(); 

     text_input_File = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader_inputPdf, i, inputpdf); 

     sb_inputpdf.Append(text_input_File); 

     input_pdf = sb_inputpdf.ToString(); 
    } 

    reader_inputPdf.Close(); 
    clear(); 
} 

는 사람이 어떻게 당신은 메모장에서 PDF 파일을 열고 첫번째 서명 존재를 확인할 수 있습니다 this.Thanku

// word to pdf 
if (Extentsion_path == ".doc" || Extentsion_path == ".docx") 
{ 
    uploadFInput.SaveAs(targetPathip); 
    string wordFileName = targetPathip; 
    _Word.Visible = false; 
    _Word.ScreenUpdating = false; 

    // Cast as Object for word Open method 
    filename = (object)wordFileName; 

    // Use the dummy value as a placeholder for optional arguments 

    Microsoft.Office.Interop.Word.Document doc = _Word.Documents.Open(ref filename, ref _MissingValue, 
     ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue, 
     ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue, 
     ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue); 
    doc.Activate(); 

    object outputFileName = pdfFileName = Path.ChangeExtension(wordFileName, "pdf"); 
    object fileFormat = WdSaveFormat.wdFormatPDF; 

    // Save document into PDF Format 
    doc.SaveAs(ref outputFileName, ref fileFormat, ref _MissingValue, ref _MissingValue, 
     ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue, 
     ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue, 
     ref _MissingValue, ref _MissingValue, ref _MissingValue, ref _MissingValue); 

    // Close the Word document, but leave the Word application open. 
    // doc has to be cast to type _Document so that it will find the 
    // correct Close method. 
    object saveChanges = WdSaveOptions.wdDoNotSaveChanges; 
    ((_Document)doc).Close(ref saveChanges, ref _MissingValue, ref _MissingValue); 
    doc = null; 

    // word has to be cast to type _Application so that it will find 
    // the correct Quit method. 
    ((_Application)_Word).Quit(ref _MissingValue, ref _MissingValue, ref _MissingValue); 

    _Word = null; 

    //uploadFInput.SaveAs(pdfFileName); 
    // = targetPathip; 
    uploadFInput.SaveAs(pdfFileName); 
    LblFleip.Text = pdfFileName; 
} 
else 
{ 
    uploadFInput.SaveAs(targetPathip); 
    LblFleip.Text = targetPathip; 
} 
+1

그래서 Microsoft Word에서 PDF로 저장/내보내기를하셨습니까? 이제 PDF를 읽으려고하십니까? 어느 선에서 오류가 발생합니까? 내가 알아챌 수있는 한가지는 iText의 페이지 번호가 '1'이 아니라 '0'이 아니기 때문에 'for' 루프를'1 '에서 시작하도록 변경하십시오. –

+0

PDf에 단어를 추가했습니다. PdfReader를 읽는 중 오류가 발생했습니다. reader_inputPdf = new PdfReader (path); // 테스트 용으로 – pdp

+0

을 읽습니다. 동일한 PDF를 여러 번 테스트했는데 여러 번 유형 불일치 오류가 발생했습니다. (HRESULT 예외 : 0x80020005 (DISP_E_TYPEMISMATCH)) – pdp

답변

2

를 해결하기 위해 말해 줄 수 있습니다.

관련 문제