分裂 PDF 条形码 API
此端点的功能: 这 PDF4me 分裂 PDF 条形码 REST API 扫描 PDF 定义一个文档,该文档会查找包含特定条形码值的页面,并在每个匹配的页面处拆分文档。 条形码字符串、过滤方法和条形码类型然后选择是否切割 之前、之后或通过移除 条形码页面。 API 使用可配置的 DPI 可针对各种打印质量实现可靠的条形码识别,并可选择将具有相同条形码的连续页面分组到单个输出部分。非常适合自动化发票处理、邮件分拣、文档批量路由以及任何使用条形码作为物理文档分隔符的工作流程。
验证您的身份 API 要求
每一个 PDF4me REST API 通话必须包含您的 API 关键在于 Authorization 标题。请从开发者控制面板获取密钥。
您不容错过的重要事实
DocName, DocContent, Barcode String, Barcode Filter, Barcode Type, Split Barcode Page, Combine Pages With Same Consecutive Barcodes, and Pdf Render Dpi are all required. Omitting any parameter causes the API to return an error or produce unexpected split results. Validate all eight fields before sending the request.
The API uses Barcode Type to select the correct recognition engine. Setting Code128 when the document contains QR Codes causes recognition to fail silently: the API returns the unsplit original document because no barcodes matched. Always verify the barcode format used in your documents before setting this parameter.
The API renders each page at the specified DPI before scanning for barcodes. At low DPI (e.g. 150), small or dense barcodes: such as DataMatrix or compact QR codes on A4 pages, may not resolve clearly enough for accurate decoding. Use 300 DPI as your default. Increase to 400-600 DPI only for very small barcodes; higher values increase processing time significantly.
REST API 端点
| 方法 | 端点 |
|---|---|
| POST | /api/v2/SplitPdfByBarcode_old |
基本网址: https://api.pdf4me.com
参数
⚠️ 所有八个参数都是必需的 用于正确检测和分割条形码。
| 范围 | 必需的 | 类型 | 它的作用 | 例子 |
|---|---|---|---|---|
| DocName | Required | String | Filename of the source PDF including the .pdf extension. Used for processing identification and output file naming. | batch-invoices.pdf |
| DocContent | Required | Base64 | The complete PDF file encoded as a Base64 string. The PDF must contain pages with machine-readable barcodes. | JVBERi0xLjQK... |
| Barcode String | Required | String | The barcode text or pattern to search for. Matched against decoded barcode values on each page using the Barcode Filter method. | INV- |
| Barcode Filter | Required | Enum | How the Barcode String is matched against decoded barcode text. Contains: text includes the string anywhere. Equals, exact match. StartsWith, text begins with the string. EndsWith, text ends with the string. | Contains |
| Barcode Type | Required | String | The barcode format printed in the PDF. Must match the actual barcode standard used. Common values: Code128 · Code39 · QRCode · EAN13 · EAN8 · DataMatrix · PDF417 | Code128 |
| Split Barcode Page | Required | Enum | Controls where the split occurs relative to the barcode page. Before: barcode page starts the next document. After, barcode page ends the current document. Remove, barcode page is excluded from all output. | After |
| Combine Pages With Same Consecutive Barcodes | Required | Boolean | When true, consecutive pages sharing the same barcode value are grouped into a single output document rather than split individually. Useful for multi-page forms where the same barcode appears on every page of a section. | true |
| Pdf Render Dpi | Required | String | DPI resolution for rendering PDF pages before barcode scanning. 300 is recommended for standard-size barcodes. Increase to 400-600 for small or dense barcodes. Higher DPI improves recognition accuracy but increases processing time. | 300 |
输出字段
| 场地 | 类型 | 描述 |
|---|---|---|
| 文件内容 | Base64 | 输出分割 PDF 内容编码为 Base64解码为二进制格式以保存文件。 |
| 文件名 | String | 输出分割的文件名 PDF。 |
请求示例
标题
Content-Type: application/json
Authorization: YOUR_API_KEY
JSON 有效载荷
{
"DocName": "batch-invoices.pdf",
"DocContent": "JVBERi0xLjQK...",
"Barcode String": "INV-",
"Barcode Filter": "Contains",
"Barcode Type": "Code128",
"Split Barcode Page": "After",
"Combine Pages With Same Consecutive Barcodes": true,
"Pdf Render Dpi": "300"
}
回复
{
"File Content": "BASE64_SPLIT_PDF_CONTENT",
"File Name": "batch-invoices-split.pdf"
}
代码示例
常见用例
Accounts payable teams receive consolidated PDF batches where each invoice has a Code128 barcode separator page. Split at each barcode (Split Barcode Page: Remove) to extract individual invoice PDFs for routing to the correct cost centre or approval queue automatically.
Bulk print mail runs produce a single PDF with a barcode cover sheet per recipient. Split the document at each barcode page (Split Barcode Page: After) to extract individual mail pieces. Use the barcode value (address or route code) to name each split file for downstream sorting and physical printing.
Scanned document batches from physical mailrooms often include a QR code separator sheet between each document. Set Barcode Type: QRCode, Barcode Filter: Contains the archive category code, and Split Barcode Page: Remove to get clean content-only PDFs ready for archiving: with no separator stubs included.
常见问题解答
▶ What barcode types does the Split PDF by Barcode API support?
The API supports common 1D and 2D formats including Code128, Code39, QR Code, EAN-13, EAN-8, DataMatrix, and PDF417. Specify the correct type in Barcode Type: using the wrong type causes the recognition engine to miss all barcodes and return the unsplit original document.
▶ What does the Barcode Filter parameter control?
Barcode Filter controls how Barcode String is matched against decoded barcode text on each page. Contains: barcode text includes the string anywhere. Equals, exact match only. StartsWith, text begins with the string. EndsWith, text ends with the string. Use Contains for partial patterns, Equals for strict control over exact barcode values.
▶ What does Split Barcode Page control?
Split Barcode Page determines what happens to the page containing the matching barcode. Before: that page starts the next output document. After, that page ends the current output document. Remove, that page is excluded from all output documents entirely. Use Remove for blank separator pages or cover sheets you do not want in any output.
▶ What does Combine Pages With Same Consecutive Barcodes do?
When set to true, consecutive pages sharing the same barcode value are grouped into one output document instead of being split individually. This is useful for multi-page records or forms where the same barcode appears on every page of a section: it prevents unnecessary splits within a single logical document.
▶ Why should I increase Pdf Render Dpi for small or dense barcodes?
The API renders each PDF page at the specified DPI before scanning. At 150 DPI, small barcodes (e.g. DataMatrix cells under 5mm wide) may not resolve with enough pixel density for accurate decoding. Use 300 DPI as your default. Increase to 400-600 DPI for very small or dense barcodes: note that higher DPI significantly increases processing time and memory usage.