You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Library/javascript/FormFields.md
-64Lines changed: 0 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -851,70 +851,6 @@ document. Destroy();
851
851
{% endhighlight %}
852
852
{% endtabs %}
853
853
854
-
## Add a date field to a PDF form
855
-
856
-
This section shows how to add a date field to a PDF form, allowing users to enter or select a date within the document. The JavaScript PDF library lets you configure the date field’s appearance, format, and behavior. You can also attach actions that run custom scripts or validations whenever the field is focused, changed, or submitted.
857
-
858
-
{% tabs %}
859
-
{% highlight typescript tabtitle="TypeScript" %}
860
-
import {PdfDocument, pdfPage, PdfForm, PdfTextBoxField, PdfJavaScriptAction } from '@syncfusion/ej2-pdf';
861
-
862
-
// Create a new PDF document
863
-
let document: PdfDocument = new PdfDocument();
864
-
// Add a new page to the document
865
-
let page: pdfPage = document.addPage();
866
-
// Access loaded form
867
-
let form: PdfForm = document.form;
868
-
// Create a new text box field
869
-
const field: PdfTextBoxField = new PdfTextBoxField(page, 'DateField', {
870
-
x: 50, y: 200, width: 150, height: 20,
871
-
});
872
-
// Sets the text value to text box field
873
-
field.text = '18/08/2003';
874
-
// Sets date formate
875
-
const format: string = 'yyyy-mm-dd';
876
-
// Add a JavaScript action to run custom scripts or validations
877
-
field.actions.format = new PdfJavaScriptAction(`AFDate_FormatEx("${format}");`);
878
-
field.actions.keyPressed = new PdfJavaScriptAction(`AFDate_KeystrokeEx("${format}"):`);
879
-
field.actions.validate = new PdfJavaScriptAction(`AFDate_Validate("${format}");`);
880
-
// Add a new form field
881
-
form.add(field);
882
-
// Save the document
883
-
document.save('output.pdf');
884
-
// Destroy the document
885
-
document. Destroy();
886
-
887
-
{% endhighlight %}
888
-
{% highlight javascript tabtitle="JavaScript" %}
889
-
890
-
// Create a new PDF document instance
891
-
var document = new ej.pdf.PdfDocument();
892
-
// Add a new page to the document
893
-
var page = document.addPage();
894
-
// Access loaded form
895
-
var form = document.form;
896
-
// Create a new text box field
897
-
const field = new ej.pdf.PdfTextBoxField(page, 'fieldF', {
898
-
x: 50, y: 200, width: 150, height: 20
899
-
});
900
-
// Sets the text value to text box field
901
-
field.text = '18/08/2003';
902
-
// Sets date formate
903
-
const format = 'yyyy-mm-dd';
904
-
// Add a JavaScript action to run custom scripts or validations
905
-
field.actions.format = new ej.pdf.PdfJavaScriptAction(`AFDate_FormatEx("${format}");`);
906
-
field.actions.keyPressed = new ej.pdf.PdfJavaScriptAction(`AFDate_KeystrokeEx("${format}"):`);
907
-
field.actions.validate = new ej.pdf.PdfJavaScriptAction(`AFDate_Validate("${format}");`);
908
-
// Add a new form field
909
-
form.add(field);
910
-
// Save the document
911
-
document.save('Output.pdf');
912
-
// Destroy the document
913
-
document. Destroy();
914
-
915
-
{% endhighlight %}
916
-
{% endtabs %}
917
-
918
854
## Field Auto Naming
919
855
920
856
To prevent grouping when adding fields with the same name, you can enable the `fieldAutoNaming` property of `PdfForm` class. Setting fieldAutoNaming to true ensures that each field gets a unique name internally, even if you specify the same name during creation.
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Library/javascript/Text.md
-55Lines changed: 0 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -406,60 +406,5 @@ document.save('Output.pdf');
406
406
// Close the document
407
407
document.destroy();
408
408
409
-
{% endhighlight %}
410
-
{% endtabs %}
411
-
412
-
## Embedded font
413
-
414
-
This example shows how to embed fonts using `PdfDocument.embedFont()` method to ensure consistent text rendering across all platforms. The library supports embedding `PdfStandardFont`, `PdfCjkStandardFont`, and `PdfTrueTypeFont` for reliable Unicode text display. After embedding, the font can be applied through `PdfFont.getFont()` method, allowing precise control over size and style. Additionally, using embedded fonts helps reduce overall PDF size, since the font dictionary is not duplicated for each usage—ensuring cleaner and more efficient output.
0 commit comments