Как я могу извлечь вложения из файла PDF? К PDF-файлам, которые я читаю, прикреплен файл XML, и я не могу найти способ их получить.
PHP: получить файл вложения из PDF
Ответы (2)
В итоге я установил poppler-utils с командой pdfdetach
person
ColdFox
schedule
28.10.2015
Используя основной PHP:
#$file_path = absolute file path
#$attachment_extension = attachment extension eg. xml
$content = @file_get_contents($file_path, FILE_BINARY);
preg_match_all('/Type\/Filespec\/UF\((.*?)\)>>/', $content, $match);
$file_names = $match[1];
preg_match_all("#$attachment_extension>>stream(.*)endstream#ismU", $content, $attachments);
$attachments = $attachments[1];
for($i=0; $i < count($attachments); $i++){
$final_attrs[$file_names[$i]] = @gzuncompress(trim($attachments[$i]));
}
#$final_attrs this is the array of files.
person
SWAPNIL KUWAR
schedule
10.12.2020