How to Extract a Birth Date from a 13-Digit CNP in Adobe Acrobat
Question details
The user needs a method to automatically extract the birth date component from a 13-digit CNP (Personal Identification Number) and display it in a separate PDF form field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form that requires automated data parsing from a specific identification number field.
- Observed behavior
- The target field automatically populates with the correctly formatted birth date only when a valid 13-digit CNP is entered.
Ensure you have a PDF editor that supports JavaScript form calculations (like Adobe Acrobat Pro) and verify that the source field containing the CNP is named exactly 'CNP'.
Use a Custom Calculation Script in Adobe Acrobat
Apply a custom JavaScript snippet to the target date field to accurately extract and format the birth date from the source CNP string.
In a standard 13-digit CNP, digits two through seven represent the birth date in the 'yymmdd' format. By using Adobe Acrobat's custom calculation script feature, you can automatically capture these digits, parse them into a date object, and output them in a standard date format like 'mm/dd/yyyy'.
Open your PDF document in Adobe Acrobat, go to the 'Tools' menu, and select 'Prepare Form'.
Right-click on the specific text field where you want the extracted date of birth to appear, then select 'Properties'.
In the Text Field Properties dialog box, click on the 'Calculate' tab located at the top.
Select the 'Custom calculation script' option and click the 'Edit' button. Paste the following JavaScript code into the editor: var CNP = this.getField("CNP").valueAsString; if (CNP.length != 13) event.value = ""; else { var dobString = CNP.substring(1, 7); var dobObj = util.scand("yymmdd", dobString); event.value = util.printd("mm/dd/yyyy", dobObj); }
Click 'OK' to save your script, then click 'Close' to exit the Properties window. Type a 13-digit number into the 'CNP' field to verify that the target field populates with the correct date.

Edit and Manage PDF Forms Easily with WPS Office
WPS Office includes a highly capable PDF editor that allows you to effortlessly view, edit, fill out, and manage complex PDF forms. It provides a user-friendly interface to handle daily document tasks seamlessly.
- 1. Download and Install: Visit the official WPS Office website to download the free installer and complete the setup process.
- 2. Open Your PDF File: Launch WPS Office and click on 'Open' to load the PDF document containing your forms.
- 3. Edit PDF Forms: Navigate to the 'Form' tab to interact with, fill out, or modify existing form fields such as text boxes and checkboxes.
- 4. Save the Document: After testing or filling out the forms, click 'Save' or press Ctrl+S to preserve your changes.

Frequently Asked Questions
What does the substring function do in this calculation script?
The substring(1, 7) function is used to extract specific characters from the CNP text string. Because JavaScript indexing starts at 0, this extracts the 2nd through 7th digits of the CNP, which correspond to the year, month, and day of birth.
Why does the target date field remain blank when I type the CNP?
The script includes a strict validation check: if (CNP.length != 13). If the number entered in the CNP field does not contain exactly 13 digits, the script forces the output field to remain empty to prevent parsing errors.
Will this JavaScript calculation work in all PDF readers?
While the script relies on standard Adobe Acrobat JavaScript API methods (like util.scand and util.printd), basic PDF viewers or browser-based readers may not support JavaScript form calculations. For best results, users should open the form in Acrobat, WPS PDF, or another advanced PDF editor.




