PHP code example of ahmaadkhader / pdf-to-html
1. Go to this page and download the library: Download ahmaadkhader/pdf-to-html library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ahmaadkhader / pdf-to-html example snippets
use Ahmaadkhader\PdfToHtml\PdfToHtml;
use Ahmaadkhader\PdfToHtml\StyleAnalyzer;
use Ahmaadkhader\PdfToHtml\TableDetector;
use Ahmaadkhader\PdfToHtml\LinkExtractor;
use Ahmaadkhader\PdfToHtml\HtmlRenderer;
$styleAnalyzer = new StyleAnalyzer();
$tableDetector = new TableDetector();
$linkExtractor = new LinkExtractor($styleAnalyzer);
$htmlRenderer = new HtmlRenderer($styleAnalyzer);
$converter = new PdfToHtml($styleAnalyzer, $tableDetector, $linkExtractor, $htmlRenderer);
// Extract plain text.
$text = $converter->extractText('/path/to/file.pdf');
// Extract semantic HTML with headings, lists, tables and links.
$html = $converter->extractHtml('/path/to/file.pdf');
// Use native heading tags (h1-h6) instead of class-based.
$html = $converter->extractHtml('/path/to/file.pdf', ['native_headings' => true]);