PDF To HTML

Free online PDF to HTML converter. Text extraction plus style wrapping, supports single or multi-page output, pure frontend.

Uso

Recursos

  • PDF 文本提取 → HTML 包装(4 种样式)
  • 支持单文件下载 / 预览 / 复制
  • 可设置 `` 完整文档或仅 `` 片段

Casos de Uso

  • PDF 内容嵌入网页 / 内容发布 / 简化版 PDF 阅读
  • 本工具简化版不还原字体/图片,只输出文本结构

Agent API Usage

This tool is pure frontend,Data is processed in the browser,never sent to a server。 manifest 中 api_url 为空,/api/pdf_to_html/ endpoint does not exist(返回 404)。 Agent 请读取 schema.json 理解字段,Please execute the tool logic in the browser first。
// Step 1: 读取工具 Schema
GET https://clawam.com/tools/pdf_to_html/schema.json

// Step 2: 在浏览器中执行工具逻辑
// PDF 转 HTML 在工具页 JS 中实现
'; } var lastHtml = ''; $('btn-convert').addEventListener('click', function() { var f = $('file').files[0]; if (!f) { showError('请先选 PDF'); return; } if (f.size > 20 * 1024 * 1024) { showError('超 20MB,简化版不支持'); return; } var r = new FileReader(); r.onload = function(e) { try { var bytes = new Uint8Array(e.target.result); var lines = extractText(bytes); if (lines.length === 0) { showError('未提取到文本,可能需 OCR 或 PDF 加密'); return; } var style = $('style').value; lastHtml = toHtml(lines, style); showResult('=== HTML 已生成 ===\n长度: ' + lastHtml.length + ' 字符\n文本行: ' + lines.length + '\n样式: ' + style + '\n\n点击"预览"查看 / "下载"保存', '已生成', false); } catch (e) { showError('转换失败: ' + (e.message || e)); } }; r.readAsArrayBuffer(f); }); $('btn-preview').addEventListener('click', function() { if (!lastHtml) { showError('请先生成'); return; } var win = window.open('', '_blank'); if (win) { win.document.write(lastHtml); win.document.close(); } else { var iframe = ''; showResult(iframe, '预览(新窗口被拦截,已嵌入 iframe)', true); } }); $('btn-copy').addEventListener('click', function() { if (!lastHtml) return; if (navigator.clipboard) navigator.clipboard.writeText(lastHtml); }); $('btn-download').addEventListener('click', function() { if (!lastHtml) return; var blob = new Blob([lastHtml], { type: 'text/html;charset=utf-8' }); var url = URL.createObjectURL(blob); var a = document.createElement('a'); a.href = url; a.download = 'pdf-to-html.html'; a.click(); URL.revokeObjectURL(url); }); $('btn-clear').addEventListener('click', function() { $('file').value = ''; lastHtml = ''; var ra = $('result-area'); ra.hidden = true; ra.style.display = 'none'; var em = $('error-msg'); em.hidden = true; em.style.display = 'none'; $('btn-copy').style.display = 'none'; $('btn-download').style.display = 'none'; }); })();