Skip to content

Commit 969f8a9

Browse files
committed
994201-dev: Added proper code example.
1 parent dc577a9 commit 969f8a9

11 files changed

+234
-755
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ import { PdfDocument, PdfPage, PdfStandardFont, PdfPen, PdfBrush } from '@syncfu
7070

7171
document.getElementById('normalButton').onclick = (): void => {
7272
// Create a new PDF document
73-
var pdf = new PdfDocument();
73+
const document = new PdfDocument();
7474
// Add a new page
75-
var page = pdf.addPage();
75+
const page: PdfPage = document.addPage();
7676
// Get graphics from the page
77-
let graphics = page.graphics;
77+
const graphics: PdfGraphics = page.graphics;
7878
// Set font
79-
var font = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, pdf.PdfFontStyle.regular);
79+
const font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 36, PdfFontStyle.regular);
8080
// Create a new black brush
81-
var brush = new pdf.PdfBrush({r: 0, g: 0, b: 0});
81+
const brush = new PdfBrush({r: 0, g: 0, b: 0});
8282
// Draw text
8383
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
8484
// Save and download PDF
85-
pdf.save('Output.pdf');
85+
document.save('Output.pdf');
8686
// Destroy the PDF document instance
87-
pdf.destroy();
87+
document.destroy();
8888
});
8989
};
9090

@@ -101,6 +101,4 @@ ng serve --open
101101

102102
By executing the program, you will get the PDF document as follows.
103103

104-
![Output PDF document](Getting_started_images/Output.png)
105-
106-
104+
![Output PDF document](Getting_started_images/Output.png)

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-asp-net-core.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ This guide explains how to integrate the JavaScript PDF library into an ASP.NET
5353
<script>
5454
document.getElementById('btnCreatePdf').addEventListener('click', function () {
5555
// Create a new PDF document
56-
var pdf = new ej.pdf.PdfDocument();
56+
let pdf = new ej.pdf.PdfDocument();
5757
// Add a new page
58-
var page = pdf.addPage();
58+
let page: ej.pdf.PdfPage = document.addPage();
5959
// Get graphics from the page
60-
let graphics = page.graphics;
60+
let graphics: ej.pdf.PdfGraphics = page.graphics;
6161
// Set font
62-
var font = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
62+
let font: ej.pdf.PdfStandardFont = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
6363
// Create a new black brush
64-
var brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
64+
let brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
6565
// Draw text
6666
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
6767
// Save and download PDF

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-asp-net-mvc.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ This guide explains how to integrate the JavaScript PDF library into an ASP.NET
5353
<script>
5454
document.getElementById('btnCreatePdf').addEventListener('click', function () {
5555
// Create a new PDF document
56-
var pdf = new ej.pdf.PdfDocument();
56+
let pdf = new ej.pdf.PdfDocument();
5757
// Add a new page
58-
var page = pdf.addPage();
58+
let page: ej.pdf.PdfPage = document.addPage();
5959
// Get graphics from the page
60-
let graphics = page.graphics;
60+
let graphics: ej.pdf.PdfGraphics = page.graphics;
6161
// Set font
62-
var font = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
62+
let font: ej.pdf.PdfStandardFont = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
6363
// Create a new black brush
64-
var brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
64+
let brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
6565
// Draw text
6666
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
6767
// Save and download PDF

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ The Essential JS 2 for JavaScript (global script) is an ES5 formatted pure JavaS
5757
<script>
5858
document.getElementById('btnCreatePdf').addEventListener('click', function () {
5959
// Create a new PDF document
60-
var pdf = new ej.pdf.PdfDocument();
60+
let pdf = new ej.pdf.PdfDocument();
6161
// Add a new page
62-
var page = pdf.addPage();
62+
let page: ej.pdf.PdfPage = document.addPage();
6363
// Get graphics from the page
64-
let graphics = page.graphics;
64+
let graphics: ej.pdf.PdfGraphics = page.graphics;
6565
// Set font
66-
var font = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
66+
let font: ej.pdf.PdfStandardFont = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
6767
// Create a new black brush
68-
var brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
68+
let brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
6969
// Draw text
7070
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
7171
// Save and download PDF
@@ -81,5 +81,4 @@ The Essential JS 2 for JavaScript (global script) is an ES5 formatted pure JavaS
8181

8282
By executing the program, you will get the PDF document as follows.
8383

84-
![Output PDF document](Getting_started_images/Output.png)
85-
84+
![Output PDF document](Getting_started_images/Output.png)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ import React from 'react';
3636
export default function App() {
3737
const createPdf = () => {
3838
// Create a new PDF document
39-
var pdf = new ej.pdf.PdfDocument();
39+
let pdf = new ej.pdf.PdfDocument();
4040
// Add a new page
41-
var page = pdf.addPage();
41+
let page: ej.pdf.PdfPage = document.addPage();
4242
// Get graphics from the page
43-
let graphics = page.graphics;
43+
let graphics: ej.pdf.PdfGraphics = page.graphics;
4444
// Set font
45-
var font = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
45+
let font: ej.pdf.PdfStandardFont = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
4646
// Create a new black brush
47-
var brush = new window.ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
47+
let brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
4848
// Draw text
4949
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
5050
// Save and download PDF

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ import { PdfDocument, PdfPage, PdfStandardFont, PdfPen, PdfBrush } from '@syncfu
5858
{% highlight html tabtitle="index.ts" %}
5959

6060
document.getElementById('normalButton').onclick = (): void => {
61-
// Create a new PDF document
62-
var pdf = new pdf.PdfDocument();
61+
// Create a new PDF document
62+
let pdf = new PdfDocument();
6363
// Add a new page
64-
var page = pdf.addPage();
64+
let page: PdfPage = document.addPage();
6565
// Get graphics from the page
66-
let graphics = page.graphics;
66+
let graphics: PdfGraphics = page.graphics;
6767
// Set font
68-
var font = pdf.embedFont(PdfFontFamily.helvetica, 36, PdfFontStyle.regular);
68+
let font: PdfStandardFont = pdf.embedFont(PdfFontFamily.helvetica, 36, PdfFontStyle.regular);
6969
// Create a new black brush
70-
var brush = new pdf.PdfBrush({r: 0, g: 0, b: 0});
70+
let brush = new PdfBrush({r: 0, g: 0, b: 0});
7171
// Draw text
7272
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
7373
// Save and download PDF
@@ -89,5 +89,4 @@ npm start
8989

9090
By executing the program, you will get the PDF document as follows.
9191

92-
![Output PDF document](Getting_started_images/Output.png)
93-
92+
![Output PDF document](Getting_started_images/Output.png)

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@ export default {
6363
methods: {
6464
createPdf() {
6565

66-
// Create a new PDF document
67-
const pdf = new ej.pdf.PdfDocument();
68-
// Add a new page
69-
const page = pdf.addPage() as PdfPage;
70-
// Get graphics from the page
71-
const graphics = page.graphics;
72-
// Set font (Syncfusion EJ2 API)
73-
const font = new PdfStandardFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
74-
// Create a new black brush (RGB array)
75-
const brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
76-
// Draw text inside a rectangle [x, y, width, height]
77-
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
78-
// Save and download PDF
79-
pdf.save('Output.pdf');
80-
// Destroy the PDF document instance
81-
pdf.destroy();
66+
// Create a new PDF document
67+
const pdf = new ej.pdf.PdfDocument();
68+
// Add a new page
69+
const page: ej.pdf.PdfPage = document.addPage();
70+
// Get graphics from the page
71+
const graphics: ej.pdf.PdfGraphics = page.graphics;
72+
// Set font
73+
const font: ej.pdf.PdfStandardFont = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
74+
// Create a new black brush
75+
const brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
76+
// Draw text
77+
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
78+
// Save and download PDF
79+
pdf.save('Output.pdf');
80+
// Destroy the PDF document instance
81+
pdf.destroy();
8282

8383
}
8484
}

Document-Processing/PDF/PDF-Library/javascript/Working-with-PDF-Pages.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Working with PDF pages | Syncfusion
3-
description: This section explains how to add, rearrange, remove pages and detect empty pages from the PDF document
3+
description: This section explains how to add, rearrange, remove pages and detect empty pages from the PDF file
44
platform: document-processing
55
control: PDF
66
documentation: UG
@@ -21,7 +21,7 @@ The following code sample demonstrates how to add a `PdfPage` to a PDF document.
2121
// Add a page
2222
let page: PdfPage = document.addPage();
2323
// Get graphics from the page
24-
let graphics = page.graphics;
24+
let graphics: PdfGraphics = page.graphics;
2525
// Set font
2626
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
2727
// Draw text
@@ -54,7 +54,7 @@ The `PdfPageSettings` class is used to define properties such as margins, orient
5454
// Add a page
5555
let page: PdfPage = section.addPage();
5656
// Get graphics from the page
57-
let graphics = page.graphics;
57+
let graphics: PdfGraphics = page.graphics;
5858
// Set font
5959
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
6060
// Draw text
@@ -89,7 +89,7 @@ This example demonstrates how to add sections with different page settings in a
8989
// Add a page
9090
let page: PdfPage = document.addPage(pageSetting);
9191
// Get graphics from the page
92-
let graphics = page.graphics;
92+
let graphics: PdfGraphics = page.graphics;
9393
// Set font
9494
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
9595
// Draw text
@@ -219,7 +219,7 @@ This example demonstrates how to rotate a PDF page using the `rotation` property
219219
// Add a page
220220
let page: PdfPage = document.addPage(pageSetting);
221221
// Get graphics from the page
222-
let graphics = page.graphics;
222+
let graphics: PdfGraphics = page.graphics;
223223
// Set font
224224
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
225225
// Draw text

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Working with PDF Document | Syncfusion
3-
description: This section explains how to set document Settings and properties to the PDF document using Essential PDF
3+
description: This section explains how to set document Settings and properties to the PDF file using Essential PDF
44
platform: document-processing
55
control: PDF
66
documentation: UG
@@ -29,7 +29,7 @@ This example shows how to configure custom page settings before adding a page to
2929
// Add a page
3030
let page: PdfPage = document.addPage(pageSettings);
3131
// Get graphics from the page
32-
let graphics = page.graphics;
32+
let graphics: PdfGraphics = page.graphics;
3333
// Set font
3434
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
3535
// Draw text
@@ -64,7 +64,7 @@ This example demonstrates how to create a section in a PDF document with custom
6464
// Add a page
6565
let page: PdfPage = section.addPage();
6666
// Get graphics from the page
67-
let graphics = page.graphics;
67+
let graphics: PdfGraphics = page.graphics;
6868
// Set font
6969
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
7070
// Draw text
@@ -103,7 +103,7 @@ This example demonstrates how to create a PDF document, set its metadata propert
103103
// Add a page
104104
let page: PdfPage = document.addPage();
105105
// Get graphics from the page
106-
let graphics = page.graphics;
106+
let graphics: PdfGraphics = page.graphics;
107107
// Set font
108108
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
109109
// Draw text
@@ -132,7 +132,7 @@ The `isIncrementalUpdate` property allows you to check if the PDF document suppo
132132
// Add a page
133133
let page: PdfPage = document.addPage();
134134
// Get graphics from the page
135-
let graphics = page.graphics;
135+
let graphics: PdfGraphics = page.graphics;
136136
// Set font
137137
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
138138
// Draw text

0 commit comments

Comments
 (0)