포함된 PDF에 텍스트를 링크로 만드는 방법

포함된 PDF에 텍스트를 링크로 만드는 방법

PDF 생성 작업에 PDF를 포함시켰습니다. 포함된 PDF 파일에서 텍스트를 클릭 가능한 텍스트로 바꾸는 것이 가능합니까? 텍스트에 대한 링크를 추가한다는 의미입니다. 내가 생성할 PDF에는 대체 가능한 클릭 가능한 텍스트가 포함되어야 합니다. 내가 포함시킨 PDF에서 추출된 링크 배열이 있습니다. 적절한 텍스트에 대한 링크를 추가해야 합니다.

 Array( 
[0] => Array(
    [text] => Text 1
    [href] => http://www.example.com
)
[1] => Array
(
    [text] => Text 2
    [href] => http://www.example.com
)
)

답변1

구현할 예정이라면pdf라텍스당신의PHP애플리케이션. 내겐 그랬어코드이그나이터.

1단계: pdflatex를 설치합니다.

2단계: $ pdfannotextractor --install터미널에 pdfannotextractor 설치

3단계: $ pdfannotextractor --version터미널에서 PDFAnnotExtractor 버전을 찾는 데 도움이 됩니다.

4단계: 그러나 Pdfannotextractor에는 libpdfbox-java 패키지도 필요합니다. 그렇지 않으면 이 오류가 발생합니다.!!! 오류: PDFBox 라이브러리를 찾을 수 없습니다!

5단계: 이 링크에서 pdfbox를 다운로드할 수 있습니다.https://sourceforge.net/projects/pdfbox/files/PDFBox/PDFBox-0.7.3/

6단계: zip 파일의 압축을 풀고 압축이 풀린 폴더를 애플리케이션에 복사하여 붙여넣습니다.

7단계: 이 코드를 따르세요.

$file                   =   '/home/rebin/Downloads/file.pdf'; 

$pdflatex               =   '/usr/local/texlive/2016/bin/x86_64-linux/pdflatex';

$pdf_box                =   BASEPATH.'PDFBox-0.7.3/lib/PDFBox-0.7.3.jar';

$template_file          =   'user/join_template.tex';

$new_pdf_filename       =   'new_pdf';

$temp_join_file_path    =   'user/';

shell_exec("CLASSPATH='".$pdf_box.":%CLASSPATH%' pdfannotextractor ".$file);

$doc    =   '\documentclass{article}
        \usepackage{hyperref}
        \usepackage[left=1cm, right=1cm, top=2cm, bottom=2cm]{geometry}
        \usepackage{pdfpages}
        \usepackage{pax}
        \begin{document}
            \includepdf[page=-]{' . $file. '}
        \end{document}';

file_put_contents($template_file, $doc);

shell_exec($pdflatex . ' -output-directory=' . $temp_join_file_path . ' -jobname=' . $new_pdf_filename . ' -interaction=nonstopmode -shell-escape join_template.tex');

누락된 링크 없이 PDF 파일이 생성됩니다.

관련 정보