Use the search bar above to ask our documentation AI to write code samples for you.
Requirements
You'll nee to have your Mindee client configured correctly as described in the Configure the Client page.
Overview
Overall, the steps to sending a file are:
Load a source file.
Optional: adjust the source file before sending.
Use the Mindee client instance to send the file.
Load a Source File
You can load a source file from a path, from raw bytes, from a bytes stream, or from a language-specific object. Choose the appropriate type based on your application requirements.
If you're unsure of which to use, we recommend loading from a path.
In some cases, PDFs will have some superfluous pages present.
For example a cover page or terms and conditions which are not useful to the desired data extraction.
These extra pages count towards your billing and slow down processing.
It is therefore in your best interest to remove them before sending.
Parameters:
"Page Indexes" is required and is a list of 0-based page indexes.
Use negative values to specify indexes starting from the end, i.e. -1 for the last page.
"Operation" specifies whether to keep only specified pages or remove specified pages.
One of "Keep Only" or "Remove".
"On Min Pages" is optional and specifies the minimum number of pages a document must have for the operation to take place. The value of 0 means any number of pages.
Exact naming of parameters will depend on the language, see below.
Using the input_source instance created above.
from mindee import PageOptions
# Set the options as follows:
# For all documents, keep only the first page
page_options = PageOptions(
operation="KEEP_ONLY",
page_indexes=[0],
)
# Apply in-memory
input_source.apply_page_options(page_options)
Some other examples:
# Only for documents having 3 or more pages:
# Keep only these pages: first, penultimate, last
PageOptions(
operation="KEEP_ONLY",
on_min_pages=3,
page_indexes=[0, -2, -1],
)
# For all documents:
# Remove the first page
PageOptions(
operation="REMOVE",
page_indexes=[0],
)
# Only for documents having 10 or more pages:
# Remove the first 5 pages
PageOptions(
operation="REMOVE",
on_min_pages=10,
page_indexes=list(range(5)),
)
Using the inputSource instance created above.
// Set the options as follows:
// For all documents, keep only the first page
const pageOptions: mindee.PageOptions = {
operation: mindee.PageOptionsOperation.KeepOnly,
pageIndexes: [0],
};
// Apply in-memory
await inputDoc.applyPageOptions(pageOptions);
Some other examples:
// Only for documents having 3 or more pages:
// Keep only these pages: first, penultimate, last
const pageOptions: mindee.PageOptions = {
operation: mindee.PageOptionsOperation.KeepOnly,
onMinPages: 3,
pageIndexes: [0, -2, -1],
};
// For all documents:
// Remove the first page
const pageOptions: mindee.PageOptions = {
operation: mindee.PageOptionsOperation.Remove,
pageIndexes: [0],
};
// Only for documents having 10 or more pages:
// Remove the first 5 pages
const pageOptions: mindee.PageOptions = {
operation: mindee.PageOptionsOperation.Remove,
onMinPages: 10,
pageIndexes: [0, 1, 2, 3, 4],
};
Using the $inputSource instance created above.
use Mindee\Input\PageOptions;
use const Mindee\Input\KEEP_ONLY;
// Set the options as follows:
// For all documents, keep only the first page
$pageOptions = new PageOptions(
pageIndexes: [0],
operation: KEEP_ONLY
);
// Apply in-memory
$inputSource->applyPageOptions($pageOptions);
Some other examples:
use Mindee\Input\PageOptions;
use const Mindee\Input\KEEP_ONLY;
use const Mindee\Input\REMOVE;
// Only for documents having 3 or more pages:
// Keep only these pages: first, penultimate, last
$pageOptions = new PageOptions(
pageIndexes: [0, -2, -1],
operation: KEEP_ONLY,
onMinPage: 3
);
// For all documents:
// Remove the first page
$pageOptions = new PageOptions(
pageIndexes: [0],
operation: REMOVE
);
// Only for documents having 10 or more pages:
// Remove the first 5 pages
$pageOptions = new PageOptions(
pageIndexes: [0, 1, 2, 3, 4],
operation: REMOVE,
onMinPage: 10
);
Using the inputSource instance created above.
import com.mindee.input.PageOptions;
import com.mindee.input.PageOptionsOperation;
// Set the options as follows:
// For all documents, keep only the first page
PageOptions pageOptions = new PageOptions.Builder()
.pageIndexes(new Integer[]{ 0 })
.operation(PageOptionsOperation.KEEP_ONLY)
.build();
Some other examples:
import com.mindee.input.PageOptions;
import com.mindee.input.PageOptionsOperation;
// Only for documents having 3 or more pages:
// Keep only these pages: first, penultimate, last
PageOptions pageOptions = new PageOptions.Builder()
.pageIndexes(new Integer[]{ 0, -2, -1 })
.operation(PageOptionsOperation.KEEP_ONLY)
.onMinPages(3)
.build();
// For all documents:
// Remove the first page
PageOptions pageOptions = new PageOptions.Builder()
.pageIndexes(new Integer[]{ 0 })
.operation(PageOptionsOperation.REMOVE)
.build();
// Only for documents having 10 or more pages:
// Remove the first 5 pages
PageOptions pageOptions = new PageOptions.Builder()
.pageIndexes(new Integer[]{ 0, 1, 2, 3, 4 })
.operation(PageOptionsOperation.REMOVE)
.onMinPages(10)
.build();
Using the inputSource instance created above.
// Set the options as follows:
// For all documents, keep only the first page
var pageOptions = new PageOptions(
operation: PageOptionsOperation.KeepOnly
, pageIndexes: [ 0 ]);
// Apply in-memory
inputSource.ApplyPageOptions(pageOptions);
Some other examples:
// Only for documents having 3 or more pages:
// Keep only these pages: first, penultimate, last
new PageOptions(
operation: PageOptionsOperation.KeepOnly
, onMinPages: 3
, pageIndexes: new short[] { 0, -2, -1 }
);
// For all documents:
// Remove the first page
new PageOptions(
operation: PageOptionsOperation.Remove
, pageIndexes: new short[] { 0 }
);
// Only for documents having 10 or more pages:
// Remove the first 5 pages
new PageOptions(
operation: PageOptionsOperation.Remove
, onMinPages: 10
, pageIndexes: new short[] { 0, 1, 2, 3, 4 }
);
Send the File
Now that your file is ready, you'll want to send it to the Mindee servers for processing.
Head on over to the Send for Processing section for details on the next step.