PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
ComPDF provides a comprehensive API for adding, editing, and deleting Bates numbers in PDF documents, facilitating the management of user security information.
In a PDF document, only one Bates number can exist, and adding a new Bates number will overwrite the old Bates numbers.
The steps to add Bates numbers are as follows:
This example shows how to add Bates numbers:
// Open document from file path.
CPDFDocument document = new CPDFDocument(context);
document.open(pdfPath, password);
CPDFBates bates = document.getBates();
int index = 0;
bates.setText(index, "<<#3#5#Prefix-#-Suffix>>");
bates.setTextColor(index, Color.RED);
bates.setFontSize(index, 14.0);
bates.setPages("0-" + (document.getPageCount() - 1));
bates.update();val document = CPDFDocument(context)
document.open(pdfPath, password)
document.bates.apply {
val index = 0
setText(index, "<<#3#5#Prefix-#-Suffix>>")
setTextColor(index, Color.RED)
setFontSize(index, 14.0F)
pages = "0-${(document.pageCount - 1)}"
update()
}The regular expression for Bates numbers supports a specific format: <<#\d+#\d+#\w+#\w+>>
For example: When the text is set to "<<#3#1#ab#cd>>," the text displayed on the first page will be "ab001cd."
The steps to remove Bates numbers are as follows:
This example shows how to remove the Bates numbers:
CPDFBates bates = document.getBates();
bates.clear();document.bates.clear()