Перейти к основному содержимому

Расколоть PDF по штрихкоду API

Что делает эта конечная точка: Он PDF4me Расколоть PDF по штрихкоду REST API сканирует PDF Документ для страниц, содержащих определенное значение штрихкода, разделяется на части на каждой соответствующей странице. Определите строка штрихкода, метод фильтрации и тип штрихкодазатем выберите, резать ли. до, после или путем удаления Страница со штрихкодом. API использует настраиваемый DPI Обеспечивает надежное распознавание штрихкодов при любом качестве печати и позволяет, при необходимости, группировать последовательные страницы с одинаковым штрихкодом в один выходной раздел. Идеально подходит для автоматизированной обработки счетов-фактур, сортировки почты, пакетной маршрутизации документов и любых рабочих процессов, использующих штрихкоды в качестве физических разделителей документов.

Похожие записи в блоге
Пока нет публикации в блоге, посвященной этой функции — она скоро появится.
А пока что, загляните в блог PDF4me, где вы найдете обучающие материалы и рабочие процессы для всех платформ.
Посетите блог →

Аутентификация вашего API Запрос​

Каждый PDF4me REST API В звонке необходимо указать ваш API ключ в Authorization заголовок. Получите свой ключ на панели разработчика.

Важные факты, которые нельзя пропустить​

All eight parameters are required for reliable barcode splitting

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.

Barcode Type must match the actual barcode format printed in the PDF

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.

Increase Pdf Render Dpi to 300+ for small or dense barcodes

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

Базовый URL: https://api.pdf4me.com

Параметры​

⚠️ Все восемь параметров необходимы. для корректного распознавания штрихкодов и разделения кода.

ПараметрНеобходимыйТипЧто это делаетПример
DocNameRequiredStringFilename of the source PDF including the .pdf extension. Used for processing identification and output file naming.batch-invoices.pdf
DocContentRequiredBase64The complete PDF file encoded as a Base64 string. The PDF must contain pages with machine-readable barcodes.JVBERi0xLjQK...
Barcode StringRequiredStringThe barcode text or pattern to search for. Matched against decoded barcode values on each page using the Barcode Filter method.INV-
Barcode FilterRequiredEnumHow 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 TypeRequiredStringThe barcode format printed in the PDF. Must match the actual barcode standard used. Common values: Code128 · Code39 · QRCode · EAN13 · EAN8 · DataMatrix · PDF417Code128
Split Barcode PageRequiredEnumControls 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 BarcodesRequiredBooleanWhen 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 DpiRequiredStringDPI 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

Поля вывода​

ПараметрНеобходимыйЧто это делаетПример
jobIdExtOptionalYour own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string.
integrationsOptionalIntegration identifiers, forwarded unchanged with the job's notification settings. Type: array.
isAsyncOptionalSet to `true` to process the action asynchronously and get a job to poll at `/api/v2/GetActionStatus`. Only honoured by actions that support asynchronous processing. Type: boolean.
docNameOptionalSource file name including its extension. Several actions dispatch on the extension, so it should always be set; when omitted a per-action default is used. Type: string.Filename of the output split PDF.
docContentRequiredThe source file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference to a previously uploaded blob, or an `https` URL to the source document. Required: an empty value fails with `File is empty`. Type: string.The output split PDF content encoded as Base64. Decode to binary to save the file.
docContentBytesOptionalAlternative raw byte payload for the source file. Type: string.
callBackUrlOptionalOptional URL notified when an asynchronous job completes. Type: string.
barcodeStringOptionalOnly split on barcodes whose value matches this string. Type: string.
barcodeFilterOptionalAn unrecognised value is rejected with 400. Type: string.
barcodeTypeOptionalAn unrecognised value is rejected with 400. Type: string.
splitBarcodePageOptionalAn unrecognised value is rejected with 400. Type: string.
combinePagesWithSameConsecutiveBarcodesOptionalKeep consecutive pages with the same barcode value together in one output document. Type: boolean.
pdfRenderDpiOptionalResolution used to render pages before barcode detection. Accepted values are `100`, `150`, `200` and `250`; anything else, including empty, uses `300`. Type: string.

Пример запроса​

Заголовки​

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"
}

Примеры кода​

Типичные сценарии использования​

Invoice Batch Processing

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.

Mail and Parcel Sorting

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.

Document Archive Organisation

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.

Связанные API​

Расколоть PDF текстом
Расколоть PDFs На страницах, содержащих определенную текстовую фразу, используйте этот метод, если в документах вместо штрихкодов используются печатные текстовые разделители.
Расколоть PDF
Разделение документа по номерам страниц происходит, когда количество страниц в каждом разделе фиксировано и известно; при этом не требуется распознавание штрих-кодов или текста.
Считывание штрихкода с PDF
Извлечение значений штрихкода из PDF Использование без разделения страниц позволяет проверять содержимое штрихкодов и значения строковых значений штрихкода перед его разделением.

Получить помощь​