Question: How can I extract the attachments from a PDF file? The PDFs that I'm reading have a XML file attached and I can't find a way to get them.

Answer: 
I ended up by installing poppler-utils that has the command pdfdetach
By using core 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.

```