PDF Editing Issues

How to Extract a Birth Date from a 13-Digit CNP in Adobe Acrobat

Adam DavisAdam Davis Nov 3, 2026 869 views

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.

How to Extract a Birth Date from a 13-Digit CNP in Adobe Acrobat
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.
Before you start

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'.

Solution 1Recommended

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'.

1
Open the Prepare Form Tool

Open your PDF document in Adobe Acrobat, go to the 'Tools' menu, and select 'Prepare Form'.

2
Access Field Properties

Right-click on the specific text field where you want the extracted date of birth to appear, then select 'Properties'.

3
Navigate to the Calculate Tab

In the Text Field Properties dialog box, click on the 'Calculate' tab located at the top.

4
Enter the Custom Script

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); }

5
Save and Test

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.

Use a Custom Calculation Script in Adobe Acrobat
Adjusting the Date Format: You can change how the final output date is formatted by modifying the 'mm/dd/yyyy' string in the util.printd function of the script to your preferred layout, such as 'dd-mm-yyyy'.
Powerful PDF Editor

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. 1. Download and Install: Visit the official WPS Office website to download the free installer and complete the setup process.
  2. 2. Open Your PDF File: Launch WPS Office and click on 'Open' to load the PDF document containing your forms.
  3. 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. 4. Save the Document: After testing or filling out the forms, click 'Save' or press Ctrl+S to preserve your changes.
Easily create, fill, and manage interactive PDF form fieldsFully compatible with Microsoft Office formats (.docx, .xlsx, .pptx) and standard Adobe PDFsLightweight application that runs smoothly even on older hardwareAll-in-one workspace for documents, spreadsheets, presentations, and PDFs
microsoft office alternative - wps office

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.