-
Notifications
You must be signed in to change notification settings - Fork 10
997018-dev: Added Getting started sample project for EJ2 PDF library #1911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| --- | ||
| layout: post | ||
| title: Getting started with Angular PDF library component | Syncfusion | ||
| description: Learn how to create a PDF file in Angular with easy steps using Syncfusion .NET Core PDF library without depending on Adobe. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Learn how to create or generate a PDF file in Angular applications with easy steps using Syncfusion JavaScript PDF library without depending on Adobe. |
||
| platform: document-processing | ||
| control: PDF | ||
| documentation: ug | ||
| domainurl: ##DomainURL## | ||
| --- | ||
|
|
||
| # Getting started with Angular PDF library | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create or Generate PDF file in Angular |
||
|
|
||
| The Syncfusion<sup>®</sup> Angular PDF library is used to create, read, and edit PDF documents. This library also offers functionality to merge, split, stamp, fill forms, and secure PDF files. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Syncfusion® JavaScript PDF library is used to create, read, and edit PDF documents. This library also offers functionality to merge, split, stamp, forms, and secure PDF files. |
||
|
|
||
| This guide explains how to integrate the EJ2 PDF library component into an Angular application. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This guide explains how to integrate the JavaScript PDF library into an Angular application. |
||
|
|
||
| N> For Angular 17+, see the following links: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove this |
||
|
|
||
| * [Create a Standalone PDF Viewer in Angular 17 and above with-no-standalone-flag](./how-to/create-a-standalone-pdf-viewer-in-angular-17-and-above-with-no-standalone-flag). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove these viewer component information |
||
| * [Create a Standalone PDF Viewer in Angular 17 and above without --no-standalone flag](./how-to/create-a-standalone-pdf-viewer-in-angular-17-and-above-without-no-standalone-flag). | ||
|
|
||
| ## Setup Angular Environment | ||
|
|
||
| You can use the [`Angular CLI`](https://github.com/angular/angular-cli) to setup your Angular applications. | ||
| To install the latest Angular CLI globally use the following command. | ||
|
|
||
| ```bash | ||
| npm install -g @angular/cli | ||
| ``` | ||
|
|
||
| N> Use the command **npm install --save @angular/cli@12.0.2** to install the Angular CLI version 12.0.2 | ||
|
|
||
| ## Create an Angular Application | ||
|
|
||
| Start a new Angular application using the Angular CLI command as follows. | ||
|
|
||
| ```bash | ||
| ng new my-app | ||
| cd my-app | ||
| ``` | ||
| ## Create a PDF document using TypeScript. | ||
|
|
||
| * Add a simple button to `main.ts` and attach a click handler that uses the EJ2 PDF API to create a new PDF document. | ||
|
|
||
| {% tabs %} | ||
| {% highlight ts tabtitle="main.ts" %} | ||
|
|
||
| <html> | ||
| <head> | ||
| <title>Button onclick Example</title> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change title as PDF creation example |
||
| </head> | ||
| <body> | ||
| <button id="normalButton">Create PDF document</button> | ||
| </body> | ||
| </html> | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| * Include the following namespaces in `app.component.ts` file. | ||
|
|
||
| {% endhighlight %} | ||
| {% highlight html tabtitle="app.component.ts" %} | ||
| import { NgModule } from '@angular/core'; | ||
| import { PdfDocument, PdfPage, PdfStandardFont, PdfPen, PdfBrush } from '@syncfusion/ej2-pdf'; | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| * Include the following code example in the click event of the button in `app.component.ts` to generate a PDF document. | ||
|
|
||
| {% endhighlight %} | ||
| {% highlight html tabtitle="app.component.ts" %} | ||
|
|
||
| document.getElementById('normalButton').onclick = (): void => { | ||
| // Create a new PDF document | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sample code is not up to dated - API changes not considered font: PdfStandardFont = new PdfStandardFont(PdfFontFamily.helvetica, 10); PdfBrush([0, 0, 0]) -> PdfBrush({r: 0, g: 0, b: 0}) PdfPen([255, 0, 0], 1) -> PdfPen({r: 255, g: 0, b: 0}, 1) graphics.drawString('Hello World!!!', font, [70, 10, 200, 50], new PdfPen([255, 0, 0], 1), new PdfBrush([0, 0, 0])); |
||
| var pdf = new PdfDocument(); | ||
| // Add a new page | ||
| var page = pdf.addPage(); | ||
| // Get graphics from the page | ||
| let graphics = page.graphics; | ||
| // Set font | ||
| font: PdfStandardFont = new PdfStandardFont(PdfFontFamily.helvetica, 10); | ||
| // Draw text | ||
| graphics.drawString('Hello World!!!', font, [70, 10, 200, 50], new PdfPen([255, 0, 0], 1), new PdfBrush([0, 0, 0])); | ||
| // Save and download PDF | ||
| pdf.save('Output.pdf'); | ||
| // Destroy the PDF document instance | ||
| pdf.destroy(); | ||
| }); | ||
| }; | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| ## Run the application | ||
|
|
||
| Use the following command to run the application in browser. | ||
|
|
||
| ```javascript | ||
| ng serve --open | ||
| ``` | ||
|
|
||
| By executing the program, you will get the PDF document as follows. | ||
|
|
||
|  | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| --- | ||
| layout: post | ||
| title: Getting started with the ASP.NET Core PDF library | Syncfusion | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create or Generate PDF file in ASP.NET Core | Syncfusion |
||
| description: Learn how to create a PDF file in ASP.NET Core with easy steps using Syncfusion .NET Core PDF library without depending on Adobe. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Learn how to create or generate a PDF file in ASP.NET Core applications with easy steps using Syncfusion JavaScript PDF library without depending on Adobe. |
||
| platform: document-processing | ||
| control: PDF | ||
| documentation: ug | ||
| keywords: .net core create pdf, edit pdf, merge, pdf form, fill form, digital sign, table, c#, dotnet core pdf, asp generate pdf, aspx generate pdf | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove C# from keywords, add javascript |
||
| --- | ||
|
|
||
| # Getting started with the ASP.NET Core PDF library | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create or Generate PDF file in ASP.NET Core |
||
|
|
||
| The Syncfusion<sup>®</sup> .NET Core PDF library is used to create, read, and edit PDF documents. This library also offers functionality to merge, split, stamp, forms, and secure PDF files. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Syncfusion® JavaScript PDF library is used to create, read, and edit PDF documents. This library also offers functionality to merge, split, stamp, forms, and secure PDF files. |
||
|
|
||
| This guide explains how to integrate the EJ2 PDF library control into an ASP.NET Core application using Visual Studio. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This guide explains how to integrate the JavaScript PDF library into an ASP.NET Core application. |
||
|
|
||
| ## Prerequisites | ||
|
|
||
| [System requirements for ASP.NET Core controls](https://help.syncfusion.com/document-processing/system-requirements) | ||
|
|
||
| ## Integrate PDF Viewer into an ASP.NET Core application | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Integrate PDF library into an ASP.NET Core application |
||
|
|
||
| 1. Start Visual Studio and select **Create a new project**. | ||
| 2. In the **Create a new project** dialog, select **ASP.NET Core Web App**. | ||
|  | ||
| 3. In the **Configure your new project** dialog, enter the project name and select **Next**. | ||
|  | ||
| 4. In the **Additional information** dialog, select a .NET LTS version (for example, **.NET 8.0 (Long-term Support)**) and then select **Create**. | ||
|  | ||
|
|
||
| 5. **Add script reference** : Add the required scripts using the CDN inside the `<head>` of `~/Views/Shared/_Layout.cshtml` as follows: | ||
|
|
||
| {% tabs %} | ||
| {% highlight c# tabtitle="~/_Layout.cshtml" %} | ||
|
|
||
| <head> | ||
| ... | ||
| <!-- Syncfusion EJ2 PDF Library (CDN) --> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No description provided. |
||
| <script src="https://cdn.syncfusion.com/ej2/31.2.15/dist/ej2.min.js"></script> | ||
| </head> | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| 6. **Create a PDF document** : Add the script in `~/Views/Home/Index.cshtml` by creating a button and attaching a click event that uses the EJ2 PDF API to generate a PDF document. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not mention EJ2 in UG, use JavaScript |
||
|
|
||
| {% tabs %} | ||
| {% highlight c# tabtitle="~/Index.cshtml" %} | ||
|
|
||
| <div class="container py-4"> | ||
| <h1 class="h4 mb-3">Create PDF document</h1> | ||
| <p class="text-muted">Click the button to generate and download a PDF.</p> | ||
| <button id="btnCreatePdf" class="btn btn-primary">Generate PDF</button> | ||
| </div> | ||
|
|
||
| @section Scripts { | ||
| <script> | ||
| document.getElementById('btnCreatePdf').addEventListener('click', function () { | ||
| // Create a new PDF document | ||
| var pdf = new ej.pdf.PdfDocument(); | ||
| // Add a new page | ||
| var page = pdf.addPage(); | ||
| // Get graphics from the page | ||
| let graphics = page.graphics; | ||
| // Set font | ||
| font: PdfStandardFont = new ej.pdf.PdfStandardFont(PdfFontFamily.helvetica, 10); | ||
| // Draw text | ||
| graphics.drawString('Hello World!!!', font, [70, 10, 200, 50], new ej.pdf.PdfPen([255, 0, 0], 1), new ej.pdf.PdfBrush([0, 0, 0])); | ||
| // Save and download PDF | ||
| pdf.save('Output.pdf'); | ||
| // Destroy the PDF document instance | ||
| pdf.destroy(); | ||
| }); | ||
| </script> | ||
| } | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| 7. **Build the project** : Click on Build > Build Solution or press Ctrl + Shift + B to build the project. | ||
|
|
||
| 8. **Run the project** : Click the Start button (green arrow) or press F5 to run the app. | ||
|
|
||
| By executing the program, you will generate the following PDF document. | ||
|
|
||
|  | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| layout: post | ||
| title: Getting started with ASP.NET MVC PDF library | Syncfusion | ||
| description: Learn how to create a PDF file in ASP.NET Core MVC with easy steps using Syncfusion .NET Core PDF library without depending on Adobe. | ||
| platform: document-processing | ||
| control: PDF | ||
| documentation: ug | ||
| --- | ||
|
|
||
| # Getting Started with ASP.NET MVC PDF library | ||
|
|
||
| The Syncfusion<sup>®</sup> .NET Core PDF library is used to create, read, and edit PDF documents. This library also offers functionality to merge, split, stamp, fill forms, and secure PDF files. | ||
|
|
||
| This guide explains how to integrate the EJ2 PDF library control into an ASP.NET Core MVC application using Visual Studio. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| [System requirements for ASP.NET MVC controls](https://help.syncfusion.com/document-processing/system-requirements) | ||
|
|
||
| ## Integrate PDF Viewer into an ASP.NET MVC application | ||
|
|
||
| 1. Start Visual Studio and select **Create a new project**. | ||
| 2. Create a new ASP.NET MVC Web Application project. | ||
|  | ||
| 3. Choose the target framework. | ||
|  | ||
| 4. Select Web Application pattern (MVC) for the project and then select **Create** button. | ||
|  | ||
|
|
||
| 5. **Add script reference** : Add the required scripts using the CDN inside the `<head>` of `~/Views/Shared/_Layout.cshtml` as follows: | ||
|
|
||
| {% tabs %} | ||
| {% highlight c# tabtitle="~/_Layout.cshtml" %} | ||
|
|
||
| <head> | ||
| ... | ||
| <!-- Syncfusion EJ2 PDF Library (CDN) --> | ||
| <script src="https://cdn.syncfusion.com/ej2/31.2.15/dist/ej2.min.js"></script> | ||
| </head> | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| 6. **Create a PDF document** : Add the script in `~/Views/Home/Index.cshtml` by creating a button and attaching a click event that uses the EJ2 PDF API to generate a PDF document. | ||
|
|
||
| {% tabs %} | ||
| {% highlight c# tabtitle="~/Index.cshtml" %} | ||
|
|
||
| <div class="container py-4"> | ||
| <h1 class="h4 mb-3">Create PDF document</h1> | ||
| <p class="text-muted">Click the button to generate and download a PDF.</p> | ||
| <button id="btnCreatePdf" class="btn btn-primary">Generate PDF</button> | ||
| </div> | ||
|
|
||
| @section Scripts { | ||
| <script> | ||
| document.getElementById('btnCreatePdf').addEventListener('click', function () { | ||
| // Create a new PDF document | ||
| var pdf = new ej.pdf.PdfDocument(); | ||
| // Add a new page | ||
| var page = pdf.addPage(); | ||
| // Get graphics from the page | ||
| let graphics = page.graphics; | ||
| // Set font | ||
| font: PdfStandardFont = new ej.pdf.PdfStandardFont(PdfFontFamily.helvetica, 10); | ||
| // Draw text | ||
| graphics.drawString('Hello World!!!', font, [70, 10, 200, 50], new ej.pdf.PdfPen([255, 0, 0], 1), new ej.pdf.PdfBrush([0, 0, 0])); | ||
| // Save and download PDF | ||
| pdf.save('Output.pdf'); | ||
| // Destroy the PDF document instance | ||
| pdf.destroy(); | ||
| }); | ||
| </script> | ||
| } | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| 7. **Build the project** : Click on Build > Build Solution or press Ctrl + Shift + B to build the project. | ||
|
|
||
| 8. **Run the project** : Click the Start button (green arrow) or press F5 to run the app. | ||
|
|
||
| By executing the program, you will generate the following PDF document. | ||
|
|
||
|  |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| --- | ||
| layout: post | ||
| title: Getting started with JavaScript PDF library control | Syncfusion | ||
| description: Learn how to create a PDF file in JavaScript with easy steps using Syncfusion .NET Core PDF library without depending on Adobe. | ||
| platform: document-processing | ||
| control: PDF | ||
| documentation: ug | ||
| domainurl: ##DomainURL## | ||
| --- | ||
|
|
||
| # Getting started in JavaScript PDF Library | ||
|
|
||
| The Essential JS 2 for JavaScript (global script) is an ES5 formatted pure JavaScript framework which can be directly used in latest web browsers. | ||
|
|
||
| ## Component Initialization with CDN link for script and style reference | ||
|
|
||
| **Step 1:** Create an app folder `my-app` for the Essential JS 2 JavaScript components. | ||
|
|
||
| **Step 2:** The Essential JS 2 component's global scripts and styles are already hosted in the below CDN link formats. | ||
|
|
||
| **Syntax:** | ||
| > Script: `https://cdn.syncfusion.com/ej2/{Version}/dist/{PACKAGE_NAME}.min.js` | ||
| > | ||
| > Styles: `https://cdn.syncfusion.com/ej2/{Version}/{PACKAGE_NAME}/styles/material.css` | ||
|
|
||
| **Example:** | ||
| > Script: [`https://cdn.syncfusion.com/ej2/31.2.15/dist/ej2.min.js`](https://cdn.syncfusion.com/ej2/31.2.15/dist/ej2.min.js) | ||
| > | ||
| > Styles: [`https://cdn.syncfusion.com/ej2/31.2.15/ej2-base/styles/material.css`](https://cdn.syncfusion.com/ej2/31.2.15/ej2-base/styles/material.css) | ||
|
|
||
| **Step 3:** Create a HTML page (index.html) in `my-app` location and add the CDN link references. | ||
|
|
||
| {% tabs %} | ||
| {% highlight ts tabtitle="index.html" %} | ||
|
|
||
| <head> | ||
| ... | ||
| <!-- Syncfusion EJ2 PDF Library (CDN) --> | ||
| <script src="https://cdn.syncfusion.com/ej2/31.2.15/dist/ej2.min.js"></script> | ||
| </head> | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| **Step 4:** **Create a PDF document** : Add the script in `index.html` by creating a button and attaching a click event that uses the EJ2 PDF API to generate a PDF document. | ||
|
|
||
| {% tabs %} | ||
| {% highlight c# tabtitle="~/Index.html" %} | ||
|
|
||
| <div class="container py-4"> | ||
| <h1 class="h4 mb-3">Create PDF document</h1> | ||
| <p class="text-muted">Click the button to generate and download a PDF.</p> | ||
| <button id="btnCreatePdf" class="btn btn-primary">Generate PDF</button> | ||
| </div> | ||
|
|
||
| @section Scripts { | ||
| <script> | ||
| document.getElementById('btnCreatePdf').addEventListener('click', function () { | ||
| // Create a new PDF document | ||
| var pdf = new ej.pdf.PdfDocument(); | ||
| // Add a new page | ||
| var page = pdf.addPage(); | ||
| // Get graphics from the page | ||
| let graphics = page.graphics; | ||
| // Set font | ||
| font: PdfStandardFont = new ej.pdf.PdfStandardFont(PdfFontFamily.helvetica, 10); | ||
| // Draw text | ||
| graphics.drawString('Hello World!!!', font, [70, 10, 200, 50], new ej.pdf.PdfPen([255, 0, 0], 1), new ej.pdf.PdfBrush([0, 0, 0])); | ||
| // Save and download PDF | ||
| pdf.save('Output.pdf'); | ||
| // Destroy the PDF document instance | ||
| pdf.destroy(); | ||
| }); | ||
| </script> | ||
| } | ||
|
|
||
| {% endhighlight %} | ||
| {% endtabs %} | ||
|
|
||
| By executing the program, you will get the PDF document as follows. | ||
|
|
||
|  | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create or Generate PDF file in Angular | Syncfusion