---------------------------------------------------------------------* * Segmented multi-page, multi-image converter * *---------------------------------------------------------------------*/ ! * \brief convertSegmentedFilesToPdf() * * \param[in] dirname directory name containing images * \param[in] substr [optional] substring filter on filenames; can be NULL
| 1409 | * </pre> |
| 1410 | */ |
| 1411 | l_int32 |
| 1412 | convertSegmentedFilesToPdf(const char *dirname, |
| 1413 | const char *substr, |
| 1414 | l_int32 res, |
| 1415 | l_int32 type, |
| 1416 | l_int32 thresh, |
| 1417 | BOXAA *baa, |
| 1418 | l_int32 quality, |
| 1419 | l_float32 scalefactor, |
| 1420 | const char *title, |
| 1421 | const char *fileout) |
| 1422 | { |
| 1423 | char *fname; |
| 1424 | l_uint8 *imdata, *data; |
| 1425 | l_int32 i, npages, nboxa, nboxes, ret; |
| 1426 | size_t imbytes, databytes; |
| 1427 | BOXA *boxa; |
| 1428 | L_BYTEA *ba; |
| 1429 | L_PTRA *pa_data; |
| 1430 | SARRAY *sa; |
| 1431 | |
| 1432 | PROCNAME("convertSegmentedFilesToPdf"); |
| 1433 | |
| 1434 | if (!dirname) |
| 1435 | return ERROR_INT("dirname not defined", procName, 1); |
| 1436 | if (!fileout) |
| 1437 | return ERROR_INT("fileout not defined", procName, 1); |
| 1438 | |
| 1439 | if ((sa = getNumberedPathnamesInDirectory(dirname, substr, 0, 0, 10000)) |
| 1440 | == NULL) |
| 1441 | return ERROR_INT("sa not made", procName, 1); |
| 1442 | |
| 1443 | npages = sarrayGetCount(sa); |
| 1444 | /* If necessary, extend the boxaa, which is page-aligned with |
| 1445 | * the image files, to be as large as the set of images. */ |
| 1446 | if (baa) { |
| 1447 | nboxa = boxaaGetCount(baa); |
| 1448 | if (nboxa < npages) { |
| 1449 | boxa = boxaCreate(1); |
| 1450 | boxaaExtendWithInit(baa, npages, boxa); |
| 1451 | boxaDestroy(&boxa); |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | /* Generate and save all the encoded pdf strings */ |
| 1456 | pa_data = ptraCreate(npages); |
| 1457 | for (i = 0; i < npages; i++) { |
| 1458 | fname = sarrayGetString(sa, i, L_NOCOPY); |
| 1459 | if (!strcmp(fname, "")) continue; |
| 1460 | boxa = NULL; |
| 1461 | if (baa) { |
| 1462 | boxa = boxaaGetBoxa(baa, i, L_CLONE); |
| 1463 | nboxes = boxaGetCount(boxa); |
| 1464 | if (nboxes == 0) |
| 1465 | boxaDestroy(&boxa); |
| 1466 | } |
| 1467 | ret = convertToPdfDataSegmented(fname, res, type, thresh, boxa, |
| 1468 | quality, scalefactor, title, |
nothing calls this directly
no test coverage detected