dovhpmnm31216 2019-05-04 04:24
浏览 124

将值作为文本返回到textarea

I have been trying for few days, I think my brain doesn't get it well.

I am making a pdf parsing function from the ACF file upload field and I need the return value to be into a textarea field.

function extract_pdf_content( $value, $post_id, $field ) {
    // make sure the file exists and the Xpdf path was provided
    $xpdfPath = '/Users/michael/Sites/play/wp-content/pdftotext';

    // make sure it's a PDF
    $checkFileType = wp_check_filetype( $post_id );
    if ( 'pdf' !== strtolower( $checkFileType['ext'] ) ) {
        return $value;
    }

    // generate the full command to Xpdf's pdftotext binary
    $cmd = $xpdfPath . ' "' . $post_id . '" - -enc UTF-8';

    // @codingStandardsIgnoreStart
    // fire Xpdf
    @exec( $cmd, $output, $exitCode );
    // @codingStandardsIgnoreEnd

    // grab the content
    $value = isset( $exitCode ) && 0 === $exitCode ? implode( ' ', $output ) : '';

    // clean up a little bit
    $value = trim( str_replace( "
", ' ', $value ) );
    $value = sanitize_text_field( $value );


    function cv_update_value( $value ) {
    return $value;
    }
    add_filter('acf/update_value/name=cv', 'cv_update_value', 10, 3);

}
add_filter( 'acf/load_value/name=resume', 'extract_pdf_content', 10, 3 );

how to can this be possible?

simple explanation

Thanks in advance!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序