MCPcopy Create free account
hub / github.com/creatale/node-dv / convertSegmentedFilesToPdf

Function convertSegmentedFilesToPdf

deps/leptonica/src/pdfio1.c:1411–1509  ·  view source on GitHub ↗

---------------------------------------------------------------------* * 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

Source from the content-addressed store, hash-verified

1409 * </pre>
1410 */
1411l_int32
1412convertSegmentedFilesToPdf(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{
1423char *fname;
1424l_uint8 *imdata, *data;
1425l_int32 i, npages, nboxa, nboxes, ret;
1426size_t imbytes, databytes;
1427BOXA *boxa;
1428L_BYTEA *ba;
1429L_PTRA *pa_data;
1430SARRAY *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,

Callers

nothing calls this directly

Calls 15

sarrayGetCountFunction · 0.85
boxaaGetCountFunction · 0.85
boxaCreateFunction · 0.85
boxaaExtendWithInitFunction · 0.85
boxaDestroyFunction · 0.85
ptraCreateFunction · 0.85
sarrayGetStringFunction · 0.85
boxaaGetBoxaFunction · 0.85
boxaGetCountFunction · 0.85
l_byteaInitFromMemFunction · 0.85
ptraAddFunction · 0.85

Tested by

no test coverage detected