Skip to content

Commit a06db13

Browse files
committed
999358-ug: Added proper changes.
1 parent 331de89 commit a06db13

9 files changed

Lines changed: 345 additions & 697 deletions

File tree

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

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,10 +1998,74 @@ This example demonstrates how to access a measurement annotation from a PDF page
19981998

19991999
Common types of measurement annotations include:
20002000

2001-
* Line - Represents a straight distance between two points.
2002-
* Circle - Used to measure circular dimensions.
2003-
* Square - Defines rectangular or square measurements.
2004-
* Angle - Displays angular measurements between two intersecting lines.
2001+
* Line - Represents a straight distance between two points.(distance)
2002+
* Circle - Used to measure circular dimensions.(Radius)
2003+
* Square - Defines rectangular or square measurements.(Area)
2004+
* Angle - Displays angular measurements between two intersecting lines.(degrees)
2005+
2006+
{% tabs %}
2007+
{% highlight typescript tabtitle="TypeScript" %}
2008+
import {PdfDocument, PdfPage, PdfLineAnnotation, PdfAnnotationLineEndingStyle, PdfLineEndingStyle, PdfAnnotationCaption, PdfLineCaptionType, PdfMeasurementUnit} from '@syncfusion/ej2-pdf';
2009+
2010+
// Creates a new PDF document
2011+
let document: PdfDocument = new PdfDocument();
2012+
// Adds a new page to the PDF
2013+
let page: PdfPage = document.addPage();
2014+
// Creates a new line annotation.
2015+
let lineAnnotation: PdfLineAnnotation = new PdfLineAnnotation({ x: 80, y: 420 }, { x: 150, y: 420 }, {
2016+
text: 'Line Annotation',
2017+
author: 'Syncfusion',
2018+
color: { r: 255, g: 0, b: 0 },
2019+
innerColor: { r: 255, g: 255, b: 0 },
2020+
lineEndingStyle: new PdfAnnotationLineEndingStyle({ begin: PdfLineEndingStyle.circle, end: PdfLineEndingStyle.diamond }),
2021+
opacity: 0.5,
2022+
measurementUnit: PdfMeasurementUnit.centimeter
2023+
});
2024+
// Assigns the leader line
2025+
lineAnnotation.leaderExt = 0;
2026+
lineAnnotation.leaderLine = 0;
2027+
// Assigns the line caption type
2028+
lineAnnotation.caption = new PdfAnnotationCaption({ cap: true, type: PdfLineCaptionType.inline });
2029+
// Adds annotation to the page
2030+
page.annotations.add(lineAnnotation);
2031+
// Saves and download the PDF document
2032+
document.save('output.pdf');
2033+
// Destroy the document
2034+
document.destroy();
2035+
2036+
{% endhighlight %}
2037+
{% highlight javascript tabtitle="JavaScript" %}
2038+
2039+
// Creates a new PDF document
2040+
var document = new ej.pdf.PdfDocument();
2041+
// Adds a new page to the PDF
2042+
var page = document.addPage();
2043+
// Creates a new line annotation.
2044+
var lineAnnotation = new ej.pdf.PdfLineAnnotation({x:80,y:420},{x:150,y:420},{
2045+
text:'Line Annotation',
2046+
author:'Syncfusion',
2047+
color:{r:255,g:0,b:0},
2048+
innerColor:{r:255,g:255,b:0},
2049+
lineEndingStyle:new ej.pdf.PdfAnnotationLineEndingStyle({begin:ej.pdf.PdfLineEndingStyle.circle,end:ej.pdf.PdfLineEndingStyle.diamond}),
2050+
opacity:0.5,
2051+
measurementUnit: PdfMeasurementUnit.centimeter
2052+
});
2053+
// Assigns the leader line
2054+
lineAnnotation.leaderExt = 0;
2055+
lineAnnotation.leaderLine = 0;
2056+
// Assigns the line caption type
2057+
lineAnnotation.caption = new ej.pdf.PdfAnnotationCaption({cap:true,type:ej.pdf.PdfLineCaptionType.inline});
2058+
// Adds annotation to the page
2059+
page.annotations.add(lineAnnotation);
2060+
// Saves and download the PDF document
2061+
document.save('output.pdf');
2062+
// Destroy the document
2063+
document.destroy();
2064+
2065+
{% endhighlight %}
2066+
{% endtabs %}
2067+
2068+
The following code snippet explains how to add a measurement annotation in an existing PDF document.
20052069

20062070
{% tabs %}
20072071
{% highlight typescript tabtitle="TypeScript" %}
@@ -2174,12 +2238,7 @@ N> Setting `document.flatten = true;` flattens all interactive elements in the P
21742238

21752239
## Importing annotations
21762240

2177-
This example demonstrates how to import annotations into a PDF document using the PdfDocument. `importAnnotations` method. The DataFormat enum specifies the format of the annotation data you are importing or exporting:
2178-
2179-
* fdf (Forms Data Format): Compact, PDF specific key/value representation.
2180-
* xfdf (XML Forms Data Format): XML-based FDF for wider tool interoperability.
2181-
* json: Human readable and easy to parse in web apps/services.
2182-
* xml: Generic XML structure suitable for systems that prefer XML processing.
2241+
This example demonstrates how to import annotations into a PDF document using the PdfDocument. `importAnnotations` method. The DataFormat enum specifies the format of the annotation data being imported, such as FDF, XFDF, JSON, or XML.
21832242

21842243
{% tabs %}
21852244
{% highlight typescript tabtitle="TypeScript" %}
@@ -2210,7 +2269,7 @@ pdfDocument.destroy();
22102269

22112270
## Exporting annotations
22122271

2213-
This example demonstrates how to export annotations from a PDF document using the PdfDocument.exportAnnotations method.
2272+
This example demonstrates how to export annotations from a PDF document using the PdfDocument.exportAnnotations method. The DataFormat enum specifies the format of the annotation data being exported, such as FDF, XFDF, JSON, or XML.
22142273

22152274
{% tabs %}
22162275
{% highlight typescript tabtitle="TypeScript" %}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ image.draw(graphics, { x: 10, y: 10});
3434
document.save('Output.pdf');
3535
// Close the document
3636
document.destroy();
37+
3738
{% endhighlight %}
3839
{% highlight javascript tabtitle="JavaScript" %}
40+
3941
// Create a new PDF document
4042
var document = new ej.pdf.PdfDocument();
4143
// Add a page
@@ -50,6 +52,7 @@ image.draw(graphics, { x: 10, y: 10 });
5052
document.save('Output.pdf');
5153
// Close the document
5254
document.destroy();
55+
5356
{% endhighlight %}
5457
{% endtabs %}
5558

@@ -75,8 +78,10 @@ image.draw(graphics, { x: 10, y: 10});
7578
document.save('Output.pdf');
7679
// Close the document
7780
document.destroy();
81+
7882
{% endhighlight %}
7983
{% highlight javascript tabtitle="JavaScript" %}
84+
8085
// Load an existing PDF document
8186
var document = new ej.pdf.PdfDocument(data);
8287
// Access first page
@@ -91,6 +96,7 @@ image.draw(graphics, {x: 10, y: 10});
9196
document.save('Output.pdf');
9297
// Close the document
9398
document.destroy();
99+
94100
{% endhighlight %}
95101
{% endtabs %}
96102

@@ -121,8 +127,10 @@ graphics.restore(state);
121127
document.save('Output.pdf');
122128
// Close the document
123129
document.destroy();
130+
124131
{% endhighlight %}
125132
{% highlight javascript tabtitle="JavaScript" %}
133+
126134
// Create a new PDF document
127135
var document = new ej.pdf.PdfDocument();
128136
// Add a page
@@ -142,6 +150,7 @@ graphics.restore(state);
142150
document.save('Output.pdf');
143151
// Close the document
144152
document.destroy();
153+
145154
{% endhighlight %}
146155
{% endtabs %}
147156

@@ -177,8 +186,10 @@ graphics.restore(state);
177186
document.save('Output.pdf');
178187
// Close the document
179188
document.destroy();
189+
180190
{% endhighlight %}
181191
{% highlight javascript tabtitle="JavaScript" %}
192+
182193
// Create a new PDF document
183194
var document = new ej.pdf.PdfDocument();
184195
// Add a page
@@ -203,5 +214,6 @@ graphics.restore(state);
203214
document.save('Output.pdf');
204215
// Close the document
205216
document.destroy();
217+
206218
{% endhighlight %}
207219
{% endtabs %}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ list.draw(page, { x: 0, y: 20, width: 500, height: 700 });
4343
document.save('output.pdf');
4444
// Destroy the document
4545
document.destroy();
46+
4647
{% endhighlight %}
4748
{% highlight javascript tabtitle="JavaScript" %}
49+
4850
// Load an existing document
4951
var document = new ej.pdf.PdfDocument(data);
5052
// Access the first page
@@ -68,6 +70,7 @@ list.draw(page, { x: 0, y: 20, width: 500, height: 700 });
6870
document.save('output.pdf');
6971
// Destroy the document
7072
document.destroy();
73+
7174
{% endhighlight %}
7275
{% endtabs %}
7376

@@ -104,8 +107,10 @@ list.draw(page, { x: 0, y: 20, width: 500, height: 700 });
104107
document.save('output.pdf');
105108
// Destroy the document
106109
document.destroy();
110+
107111
{% endhighlight %}
108112
{% highlight javascript tabtitle="JavaScript" %}
113+
109114
// Load the existing document
110115
var document = new ej.pdf.PdfDocument(data);
111116
// Access the first page
@@ -129,5 +134,6 @@ list.draw(page, { x: 0, y: 20, width: 500, height: 700 });
129134
document.save('output.pdf');
130135
// Destroy the document
131136
document.destroy();
137+
132138
{% endhighlight %}
133139
{% endtabs %}

Document-Processing/PDF/PDF-Library/javascript/Open-and-save-PDF-files.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ Open an encrypted PDF document using the `PdfDocument` class by providing the co
7272
{% tabs %}
7373
{% highlight typescript tabtitle="TypeScript" %}
7474
// Load an existing PDF document with password
75-
let document: PdfDocument = new PdfDocument(data, "password");
75+
let document: PdfDocument = new PdfDocument(data, 'password');
7676
{% endhighlight %}
7777
{% highlight javascript tabtitle="JavaScript" %}
7878
// Load an existing PDF document with password
79-
var document = new ej.pdf.PdfDocument(data, "password");
79+
var document = new ej.pdf.PdfDocument(data, 'password');
8080
{% endhighlight %}
8181
{% endtabs %}
8282

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

Lines changed: 6 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ document.save('Output.pdf');
4040
document.destroy();
4141
{% endhighlight %}
4242
{% highlight javascript tabtitle="JavaScript" %}
43+
4344
// Create a new PDF document
4445
var document = new ej.pdf.PdfDocument();
4546
// Create a new PDF page settings instance
@@ -61,65 +62,7 @@ graphics.drawString('Hello World', font, { x: 10, y: 20, width: 100, height: 200
6162
document.save('Output.pdf');
6263
// Close the document
6364
document.destroy();
64-
{% endhighlight %}
65-
{% endtabs %}
66-
67-
## Creating sections in a PDF
68-
69-
This example demonstrates how to create a section in a PDF document with custom page settings. It shows how to configure rotation, orientation, margins, and page size using `PdfPageSettings`. The `PdfSection` class is used to apply different page customizations within a single PDF document.
7065

71-
{% tabs %}
72-
{% highlight typescript tabtitle="TypeScript" %}
73-
import { PdfDocument, PdfPage, PdfPageSettings, PdfRotationAngle, PdfMargins, PdfPageOrientation, PdfStandardFont, PdfFontFamily, PdfFontStyle, PdfBrush } from '@syncfusion/ej2-pdf';
74-
75-
// Create a new PDF document
76-
let document: PdfDocument = new PdfDocument();
77-
// Create a new PDF page settings with custom options
78-
let pageSettings = new PdfPageSettings({
79-
orientation: PdfPageOrientation.landscape,
80-
size: { width: 842, height: 595 },
81-
margins: new PdfMargins(40),
82-
rotation: PdfRotationAngle.angle90
83-
});
84-
// Add a section to the document with the specified settings
85-
let section: PdfSection = document.addSection(pageSettings);
86-
// Add a page
87-
let page: PdfPage = section.addPage();
88-
// Get graphics from the page
89-
let graphics: PdfGraphics = page.graphics;
90-
// Set font
91-
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
92-
// Draw text
93-
graphics.drawString('Hello World', font, { x: 10, y: 20, width: 100, height: 200}, new PdfBrush({r: 0, g: 0, b: 255}));
94-
// Save the document
95-
document.save('Output.pdf');
96-
// Close the document
97-
document.destroy();
98-
{% endhighlight %}
99-
{% highlight javascript tabtitle="JavaScript" %}
100-
// Create a new PDF document
101-
var document = new ej.pdf.PdfDocument();
102-
// Create a new PDF page settings with custom options
103-
let pageSettings = new ej.pdf.PdfPageSettings({
104-
orientation: ej.pdf.PdfPageOrientation.landscape,
105-
size: { width: 842, height: 595 },
106-
margins: new ej.pdf.PdfMargins(40),
107-
rotation: ej.pdf.PdfRotationAngle.angle90
108-
});
109-
// Add a section to the document with the specified settings
110-
var section = document.addSection(pageSettings);
111-
// Add a page
112-
var page = section.addPage();
113-
// Get graphics from the page
114-
var graphics = page.graphics;
115-
// Set font
116-
var font = document.embedFont(ej.pdf.PdfFontFamily.helvetica, 10, ej.pdf.PdfFontStyle.regular);
117-
// Draw text
118-
graphics.drawString('Hello World', font, { x: 10, y: 20, width: 100, height: 200 }, new ej.pdf.PdfBrush({ r: 0, g: 0, b: 255 }));
119-
// Save the document
120-
document.save('Output.pdf');
121-
// Close the document
122-
document.destroy();
12366
{% endhighlight %}
12467
{% endtabs %}
12568

@@ -166,20 +109,14 @@ let language = documentProperties.language;
166109
let creationDate = documentProperties.creationDate;
167110
// Gets the modification date of the PDF document
168111
let modificationDate = documentProperties.modificationDate;
169-
// Add a page
170-
let page: PdfPage = document.addPage();
171-
// Get graphics from the page
172-
let graphics: PdfGraphics = page.graphics;
173-
// Set font
174-
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
175-
// Draw text
176-
graphics.drawString('Hello World', font, { x: 10, y: 20, width: 100, height: 200}, new PdfBrush({r: 0, g: 0, b: 255}));
177112
// Save the document
178113
document.save('Output.pdf');
179114
// Close the document
180115
document.destroy();
116+
181117
{% endhighlight %}
182118
{% highlight javascript tabtitle="JavaScript" %}
119+
183120
// Create a PDF document
184121
var document = new ej.pdf.PdfDocument();
185122
// Set or update document properties
@@ -214,14 +151,6 @@ var language = documentProperties.language;
214151
var creationDate = documentProperties.creationDate;
215152
// Gets the modification date of the PDF document
216153
var modificationDate = documentProperties.modificationDate;
217-
// Add a page
218-
var page = document.addPage();
219-
// Get graphics from the page
220-
var graphics = page.graphics;
221-
// Set font
222-
var font = document.embedFont(ej.pdf.PdfFontFamily.helvetica, 10, ej.pdf.PdfFontStyle.regular);
223-
// Draw text
224-
graphics.drawString('Hello World', font, { x: 10, y: 20, width: 100, height: 200 }, new ej.pdf.PdfBrush({ r: 0, g: 0, b: 255 }));
225154
// Save the document
226155
document.save('Output.pdf');
227156
// Close the document
@@ -253,8 +182,10 @@ graphics.drawString('Hello World', font, { x: 10, y: 20, width: 100, height: 200
253182
document.save('Output.pdf');
254183
// Close the document
255184
document.destroy();
185+
256186
{% endhighlight %}
257187
{% highlight javascript tabtitle="JavaScript" %}
188+
258189
// Create a PDF document
259190
var document = new ej.pdf.PdfDocument();
260191
// Disable incremental update to rewrite the entire file
@@ -271,5 +202,6 @@ graphics.drawString('Hello World', font, { x: 10, y: 20, width: 100, height: 200
271202
document.save('Output.pdf');
272203
// Close the document
273204
document.destroy();
205+
274206
{% endhighlight %}
275207
{% endtabs %}

0 commit comments

Comments
 (0)