Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 17, 2019 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/fc6e51a674492712ea41d0398e1c1cac to your computer and use it in GitHub Desktop.
Save parzibyte/fc6e51a674492712ea41d0398e1c1cac to your computer and use it in GitHub Desktop.
<?php
# Incluir autoload
include "vendor/autoload.php";
$parseador = new \Smalot\PdfParser\Parser();
$nombreDocumento = "6-imagenes.pdf";
$documento = $parseador->parseFile($nombreDocumento);
$paginas = $documento->getPages();
foreach ($paginas as $indice => $pagina) {
printf("<h1>Página #%02d</h1>", $indice + 1);
$texto = $pagina->getText();
echo "<pre>";
echo $texto;
echo "</pre>";
}
$imagenes = $documento->getObjectsByType('XObject', 'Image');
foreach ($imagenes as $imagen) {
printf("<h1>Una imagen</h1><img src=\"data:image/jpg;base64,%s\"/>", base64_encode($imagen->getContent()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment