3

将文件从 MSword 转换为 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();
}

谁能告诉我如何解决这个问题。谢谢

// 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;
}
4

1 回答 1

2

您可以先在记事本中打开 PDF 文件并检查签名是否存在。

于 2013-06-18T17:05:26.193 回答