Skip to content

Commit 8cbac79

Browse files
100299: addressed the feedback provided
1 parent e95ec0f commit 8cbac79

5 files changed

Lines changed: 163 additions & 62 deletions

File tree

Document-Processing/PDF/PDF-Library/javascript/DigitalSignature.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -887,49 +887,9 @@ document.destroy();
887887
{% endhighlight %}
888888
{% endtabs %}
889889

890-
## Document revisions
891-
892-
Digital signatures create incremental revisions in a PDF, preserving each version of the document as new signatures are added. These revisions allow you to view the state of the document at the time of signing and verify whether any changes occurred afterward. The API provides access to these versions through `getRevisions()` for all revisions and `getRevision()` for the specific revision tied to a signature.
893-
894-
{% tabs %}
895-
{% highlight typescript tabtitle="TypeScript" %}
896-
import {PdfDocument, PdfForm, PdfSignatureField} from '@syncfusion/ej2-pdf';
897-
898-
// Load an existing PDF document
899-
let document: PdfDocument = new PdfDocument(data);
900-
// Access loaded form
901-
let form: PdfForm = document.form;
902-
// Access the loaded form field
903-
let signature: PdfSignatureField = form.fieldAt(0);
904-
// Retrieve all revision indexes of the PDF document
905-
let revisions: number[] = document.getRevisions();
906-
// Gets the revision number associated with the signature field
907-
let revision: number = signature.getRevision();
908-
// Destroy the document
909-
document.destroy();
910-
911-
{% endhighlight %}
912-
{% highlight javascript tabtitle="JavaScript" %}
913-
914-
// Load an existing PDF document
915-
var document = new ej.pdf.PdfDocument(data);
916-
// Access loaded form
917-
var form = document.form;
918-
// Access the loaded form field
919-
var signature = form.fieldAt(0);
920-
// Retrieve all revision indexes of the PDF document
921-
var revisions = document.getRevisions();
922-
// Gets the revision number associated with the signature field
923-
var revision = signature.getRevision();
924-
// Destroy the document
925-
document.destroy();
926-
927-
{% endhighlight %}
928-
{% endtabs %}
929-
930890
## Sign existing signature field
931891

932-
This section explains how to sign an existing unsigned signature field in a PDF using the JavaScript PDF library. You can locate predefined signature fields and apply a digital signature directly by calling `field.setSignature()`, without altering the document layout. This is ideal for templates where signature placeholders already exist, allowing you to securely complete the field using a certificate and signature settings.
892+
This section explains how to sign an existing unsigned signature field in a PDF using the JavaScript PDF library. You can locate predefined signature fields and apply a digital signature directly by calling `field.setSignature()`, without altering the document layout. This is ideal for templates where signature placeholders already exist, allowing you to add digital signatures to the field using a certificate and signature settings.
933893

934894
{% tabs %}
935895
{% highlight typescript tabtitle="TypeScript" %}
@@ -990,8 +950,8 @@ let document: PdfDocument = new PdfDocument(data);
990950
// Access loaded form
991951
let form: PdfForm = document.form;
992952
// Access the loaded form field
993-
let field: PdfSignatureField = form.fieldAt(0);
994-
// Remove the form field
953+
let field: PdfSignatureField = form.fieldAt(0) as PdfSignatureField;
954+
// Remove the signature field
995955
if (field instanceof PdfSignatureField) {
996956
document.form.removeField(field);
997957
}
@@ -1007,12 +967,52 @@ var document = new ej.pdf.PdfDocument(data);
1007967
var form = document.form;
1008968
// Access the loaded form field
1009969
var field = form.fieldAt(0);
1010-
// Remove the form field
1011-
if (field instanceof ej.pdf.PdfSignatureField ) {
970+
// Remove the signature field
971+
if (field instanceof ej.pdf.PdfSignatureField) {
1012972
document.form.removeField(field);
1013973
}
1014974
// Destroy the document
1015975
document.destroy();
1016976

977+
{% endhighlight %}
978+
{% endtabs %}
979+
980+
## Document revisions
981+
982+
Digital signatures create incremental revisions in a PDF, preserving each version of the document as new signatures are added. These revisions allow you to view the state of the document at the time of signing and verify whether any changes occurred afterward. The API provides access to these versions through `getRevisions()` for all revisions and `getRevision()` for the specific revision tied to a signature.
983+
984+
{% tabs %}
985+
{% highlight typescript tabtitle="TypeScript" %}
986+
import {PdfDocument, PdfForm, PdfSignatureField} from '@syncfusion/ej2-pdf';
987+
988+
// Load an existing PDF document
989+
let document: PdfDocument = new PdfDocument(data);
990+
// Access loaded form
991+
let form: PdfForm = document.form;
992+
// Access the loaded form field
993+
let signature: PdfSignatureField = form.fieldAt(0);
994+
// Retrieve all revision indexes of the PDF document
995+
let revisions: number[] = document.getRevisions();
996+
// Gets the revision number associated with the signature field
997+
let revision: number = signature.getRevision();
998+
// Destroy the document
999+
document.destroy();
1000+
1001+
{% endhighlight %}
1002+
{% highlight javascript tabtitle="JavaScript" %}
1003+
1004+
// Load an existing PDF document
1005+
var document = new ej.pdf.PdfDocument(data);
1006+
// Access loaded form
1007+
var form = document.form;
1008+
// Access the loaded form field
1009+
var signature = form.fieldAt(0);
1010+
// Retrieve all revision indexes of the PDF document
1011+
var revisions = document.getRevisions();
1012+
// Gets the revision number associated with the signature field
1013+
var revision = signature.getRevision();
1014+
// Destroy the document
1015+
document.destroy();
1016+
10171017
{% endhighlight %}
10181018
{% endtabs %}

Document-Processing/PDF/PDF-Library/javascript/FormFields.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,14 +866,14 @@ let page: pdfPage = document.addPage();
866866
// Access loaded form
867867
let form: PdfForm = document.form;
868868
// Create a new text box field
869-
const field: PdfTextBoxField = new PdfTextBoxField(page, 'fieldF', {
869+
const field: PdfTextBoxField = new PdfTextBoxField(page, 'DateField', {
870870
x: 50, y: 200, width: 150, height: 20,
871871
});
872872
// Sets the text value to text box field
873873
field.text = '18/08/2003';
874874
// Sets date formate
875875
const format: string = 'yyyy-mm-dd';
876-
// Create a new `PdfJavaScriptAction` for adding the action
876+
// Add a JavaScript action to run custom scripts or validations
877877
field.actions.format = new PdfJavaScriptAction(`AFDate_FormatEx("${format}");`);
878878
field.actions.keyPressed = new PdfJavaScriptAction(`AFDate_KeystrokeEx("${format}"):`);
879879
field.actions.validate = new PdfJavaScriptAction(`AFDate_Validate("${format}");`);
@@ -901,7 +901,7 @@ const field = new ej.pdf.PdfTextBoxField(page, 'fieldF', {
901901
field.text = '18/08/2003';
902902
// Sets date formate
903903
const format = 'yyyy-mm-dd';
904-
// Create a new `PdfJavaScriptAction` for adding the action
904+
// Add a JavaScript action to run custom scripts or validations
905905
field.actions.format = new ej.pdf.PdfJavaScriptAction(`AFDate_FormatEx("${format}");`);
906906
field.actions.keyPressed = new ej.pdf.PdfJavaScriptAction(`AFDate_KeystrokeEx("${format}"):`);
907907
field.actions.validate = new ej.pdf.PdfJavaScriptAction(`AFDate_Validate("${format}");`);

Document-Processing/PDF/PDF-Library/javascript/HyperLinks.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,93 @@ document.save('Output.pdf');
162162
// Close the document
163163
document.destroy();
164164

165+
{% endhighlight %}
166+
{% endtabs %}
167+
168+
## Modifying or updating existing hyperlinks
169+
170+
This example shows how to update hyperlink annotations in a PDF using Syncfusion’s JavaScript PDF Library. By accessing an annotation through `page.annotations.at()`, you can check whether it’s a link annotation and then update its URL or bounding region. This makes it easy to refresh outdated links or adjust navigation behavior whenever the document changes.
171+
172+
{% tabs %}
173+
{% highlight typescript tabtitle="TypeScript" %}
174+
import { PdfDocument, PdfPage, PdfTextWebLinkAnnotation } from '@syncfusion/ej2-pdf';
175+
176+
// Load an existing PDF document
177+
let document: PdfDocument = new PdfDocument(data);
178+
// Access the first page
179+
let page: PdfPage = document.getPage(0);
180+
// Get the first annotation of the page
181+
let annotation: PdfTextWebLinkAnnotation = page.annotations.at(0) as PdfTextWebLinkAnnotation;
182+
// Modified its properties
183+
annotation.url = 'https://www.google.co.in/';
184+
// Save the document
185+
document.save('Output.pdf');
186+
// Close the document
187+
document.destroy();
188+
189+
{% endhighlight %}
190+
{% highlight javascript tabtitle="JavaScript" %}
191+
192+
// Load an existing PDF document
193+
var document = new ej.pdf.PdfDocument(data);
194+
// Access the first page
195+
var page = document.getPage(0);
196+
// Get the first annotation of the page
197+
var annotation = page.annotations.at(0);
198+
// Modified its properties
199+
if (annotation instanceof ej.pdf.PdfTextWebLinkAnnotation) {
200+
annotation.url = 'https://www.google.co.in/';
201+
}
202+
// Save the document
203+
document.save('Output.pdf');
204+
// Close the document
205+
document.destroy();
206+
207+
{% endhighlight %}
208+
{% endtabs %}
209+
210+
## Removing hyperlinks
211+
212+
This example demonstrates how to remove hyperlink annotations from a PDF using Syncfusion’s JavaScript PDF Library. By reviewing each annotation and checking whether it represents a hyperlink, you can remove it using either `remove()` or `removeAt()`. This helps clean up outdated or unwanted links while keeping the rest of the document content intact.
213+
214+
{% tabs %}
215+
{% highlight typescript tabtitle="TypeScript" %}
216+
import { PdfDocument, PdfPage, PdfTextWebLinkAnnotation } from '@syncfusion/ej2-pdf';
217+
218+
// Load an existing PDF document
219+
let document: PdfDocument = new PdfDocument(data);
220+
// Access the first page
221+
let page: PdfPage = document.getPage(0);
222+
// Access first annotation from the PDF page
223+
let annotation: PdfTextWebLinkAnnotation = page.annotations.at(0) as PdfTextWebLinkAnnotation;
224+
// Remove an annotation from the collection
225+
page.annotations.remove(annotation);
226+
// Remove an annotation with specific index
227+
page.annotations.removeAt(1);
228+
// Save the document
229+
document.save('output.pdf');
230+
// Close the document
231+
document.destroy();
232+
233+
{% endhighlight %}
234+
{% highlight javascript tabtitle="JavaScript" %}
235+
236+
// Load an existing PDF document
237+
var document = new ej.pdf.PdfDocument(data);
238+
// Access the first page
239+
var page = document.getPage(0);
240+
// Access first annotation from the PDF page
241+
var annotation = page.annotations.at(0);
242+
// Remove an annotation from the collection
243+
if (annotation instanceof ej.pdf.PdfTextWebLinkAnnotation) {
244+
page.annotations.remove(annotation);
245+
}
246+
// Remove an annotation with specific index
247+
page.annotations.removeAt(1);
248+
// Save the document
249+
document.save('output.pdf');
250+
// Close the document
251+
document.destroy();
252+
165253
{% endhighlight %}
166254
{% endtabs %}

Document-Processing/PDF/PDF-Library/javascript/Lists.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ let list: PdfUnorderedList = new PdfUnorderedList(new PdfListItemCollection(['PD
259259
// Set the marker style for the unordered list
260260
list.style = PdfUnorderedListStyle.circle;
261261
// Add a nested ordered list to the first list item
262-
list.items.at(0).subList = new PdfOrderedList(new PdfListItemCollection(['PDF.Base', 'PDF.Portable', 'Flutter', 'EJ2']));
262+
list.items.at(0).subList = new PdfOrderedList(new PdfListItemCollection(['JS', 'TS', 'Vue', 'Angular', 'ASP.Net Core']));
263263
// Draw the unordered list on the page
264264
list.draw(page, {x: 50, y: 150});
265265
// Save the document
@@ -279,7 +279,7 @@ var list = new ej.pdf.PdfUnorderedList(new ej.pdf.PdfListItemCollection(['PDF',
279279
// Set the marker style for the unordered list
280280
list.style = ej.pdf.PdfUnorderedListStyle.circle;
281281
// Add a nested ordered list to the first list item
282-
list.items.at(0).subList = new ej.pdf.PdfOrderedList(new ej.pdf.PdfListItemCollection(['PDF.Base', 'PDF.Portable', 'Flutter', 'EJ2']));
282+
list.items.at(0).subList = new ej.pdf.PdfOrderedList(new ej.pdf.PdfListItemCollection(['JS', 'TS', 'Vue', 'Angular', 'ASP.Net Core']));
283283
// Draw the unordered list on the page
284284
list.draw(page, {x: 50, y: 150});
285285
// Save the document
@@ -290,7 +290,7 @@ document.destroy();
290290
{% endhighlight %}
291291
{% endtabs %}
292292

293-
## list pagination
293+
## List pagination
294294

295295
This example shows how long lists automatically continue onto the next page when drawn using the `PdfUnorderedList` class. By applying a `PdfLayoutFormat`, the layout engine handles page breaks smoothly while preserving markers, indentation, and nested levels. This ensures consistent rendering of multi‑page or dynamically generated list content.
296296

Document-Processing/PDF/PDF-Library/javascript/Text.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,14 @@ let document: PdfDocument = new PdfDocument();
371371
let page: PdfPage = document.addPage();
372372
// Set font
373373
let font: PdfTrueTypeFont = document.embedFont(data, 13);
374-
// Draw text
375-
page.graphics.drawString(`שלום עולם!!!`, font, { x: 0, y: 200, width: 100, height: 100 }, new PdfBrush({ r: 0, g: 0, b: 0 }), new PdfStringFormat());
374+
// Create a new PDF string format
375+
let format: PdfStringFormat = new PdfStringFormat();
376+
// Sets the text alignment of form field as right
377+
format.alignment = PdfTextAlignment.right;
378+
// Sets the text direction of form field as rightToLeft
379+
format.textDirection = PdfTextDirection.rightToLeft;
380+
// Draw RTL text
381+
page.graphics.drawString(`שלום עולם!!!`, font, { x: 0, y: 200, width: 100, height: 100 }, new PdfBrush({ r: 0, g: 0, b: 0 }), format);
376382
// Save the document
377383
document.save('Output.pdf');
378384
// Close the document
@@ -387,8 +393,14 @@ var document = new ej.pdf.PdfDocument();
387393
var page = document.addPage();
388394
// Set font
389395
var font = document.embedFont(data, 13);
390-
// Draw text
391-
page.graphics.drawString(`שלום עולם!!!`, font, { x: 0, y: 200, width: 100, height: 100 }, new ej.pdf.PdfBrush({ r: 0, g: 0, b: 0 }), new ej.pdf.PdfStringFormat());
396+
// Create a new PDF string format
397+
let format = new ej.pdf.PdfStringFormat();
398+
// Sets the text alignment of form field as right
399+
format.alignment = PdfTextAlignment.right;
400+
// Sets the text direction of form field as rightToLeft
401+
format.textDirection = PdfTextDirection.rightToLeft;
402+
// Draw RTL text
403+
page.graphics.drawString(`שלום עולם!!!`, font, { x: 0, y: 200, width: 100, height: 100 }, new ej.pdf.PdfBrush({ r: 0, g: 0, b: 0 }), format);
392404
// Save the document
393405
document.save('Output.pdf');
394406
// Close the document
@@ -409,17 +421,18 @@ import { PdfDocument, PdfPage, PdfFont, PdfStandardFont, PdfCjkStandardFont, Pdf
409421
let document: PdfDocument = new PdfDocument();
410422
// Add a page
411423
let page: PdfPage = document.addPage();
412-
// Embed a font into the PDF document.
424+
// Embed a standard font into the PDF document.
413425
const embedded1: PdfStandardFont = document.embedFont(PdfFontFamily.timesRoman, 12, PdfFontStyle.regular);
414-
const embedded2: PdfCjkStandardFont = document.embedFont(PdfCjkFontFamily.hanyangSystemsGothicMedium, 12, PdfFontStyle.regular , true);
415426
// Gets a font variant from the base font with the given size and style
416-
const embedded3: PdfFont = embedded1.getFont(14, PdfFontStyle.bold);
417-
const embedded4: PdfFont = embedded2.getFont(14, PdfFontStyle.bold);
427+
const embedded2: PdfFont = embedded1.getFont(14, PdfFontStyle.bold);
428+
const embedded3: PdfFont = embedded1.getFont(14, PdfFontStyle.italic);
429+
// Embed a CJK font into the PDF document.
430+
const embedded4: PdfCjkStandardFont = document.embedFont(PdfCjkFontFamily.hanyangSystemsGothicMedium, 12, PdfFontStyle.regular , true);
418431
// Draw string using embed font.
419432
page.graphics.drawString('timesRoman with regular', embedded1, {x: 10, y: 10, width: 300, height: 24}, new PdfBrush({r: 0, g: 0, b: 255}));
420-
page.graphics.drawString('timesRoman with bold', embedded3, {x: 10, y: 50, width: 300, height: 24}, new PdfBrush({r: 0, g: 0, b: 255}));
421-
page.graphics.drawString('Cjkfont with regular', embedded2, {x: 200, y: 10, width: 300, height: 24}, new PdfBrush({r: 0, g: 0, b: 255}));
422-
page.graphics.drawString('Cjkfont with bold', embedded4, {x: 200, y: 50, width: 300, height: 24}, new PdfBrush({r: 0, g: 0, b: 255}));
433+
page.graphics.drawString('timesRoman with bold', embedded2, {x: 10, y: 50, width: 300, height: 24}, new PdfBrush({r: 0, g: 0, b: 255}));
434+
page.graphics.drawString('timesRoman with italic', embedded3, {x: 200, y: 50, width: 300, height: 24}, new PdfBrush({r: 0, g: 0, b: 255}));
435+
page.graphics.drawString('Cjkfont with regular', embedded4, {x: 200, y: 10, width: 300, height: 24}, new PdfBrush({r: 0, g: 0, b: 255}));
423436
// Save the document
424437
document.save('Output.pdf');
425438
// Close the document

0 commit comments

Comments
 (0)