diff --git a/javascript/pdf-add-form/README.md b/javascript/pdf-add-form/README.md new file mode 100644 index 0000000..26f6aac --- /dev/null +++ b/javascript/pdf-add-form/README.md @@ -0,0 +1,22 @@ +# How to Add Form Fields to an Existing PDF in JavaScript + +This project is a complete working application to add form fields to an existing PDF in JavaScript + +## Getting Started + +To get started you need to clone the `pdf-add-form` repository. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git +``` + +## Running + +You can run the application by simply opening the `index.html` file in any web browser. + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript-es5/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) diff --git a/javascript/pdf-add-form/index.html b/javascript/pdf-add-form/index.html new file mode 100644 index 0000000..4f6f8a9 --- /dev/null +++ b/javascript/pdf-add-form/index.html @@ -0,0 +1,175 @@ + + + + + + + +
+

Add Form fields to Existing PDF

+ +
+ \ No newline at end of file diff --git a/javascript/pdf-import-annotations/README.md b/javascript/pdf-import-annotations/README.md new file mode 100644 index 0000000..69b02bd --- /dev/null +++ b/javascript/pdf-import-annotations/README.md @@ -0,0 +1,22 @@ +# How to Import Annotations into a PDF in JavaScript + +This project is a complete working application to import annotation into PDF using JavaScript. + +## Getting Started + +To get started you need to clone the `pdf-import-annotations` repository. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git +``` + +## Running + +You can run the application by simply opening the `index.html` file in any web browser. + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript-es5/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) diff --git a/javascript/pdf-import-annotations/index.html b/javascript/pdf-import-annotations/index.html new file mode 100644 index 0000000..8ac78b4 --- /dev/null +++ b/javascript/pdf-import-annotations/index.html @@ -0,0 +1,52 @@ + + + + + +
+

Import Annotations to PDF

+ +
+ \ No newline at end of file diff --git a/javascript/pdf-import-export-form/README.md b/javascript/pdf-import-export-form/README.md new file mode 100644 index 0000000..11ddb3a --- /dev/null +++ b/javascript/pdf-import-export-form/README.md @@ -0,0 +1,22 @@ +# How to Import and Export PDF Form Data (FDF, XFDF, JSON) in JavaScript + +This project is a complete working application to import and export PDF form data (FDF, XFDF, JSON) in JavaScript + +## Getting Started + +To get started you need to clone the `pdf-import-export-form` repository. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git +``` + +## Running + +You can run the application by simply opening the `index.html` file in any web browser. + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript-es5/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) diff --git a/javascript/pdf-import-export-form/index.html b/javascript/pdf-import-export-form/index.html new file mode 100644 index 0000000..19565f6 --- /dev/null +++ b/javascript/pdf-import-export-form/index.html @@ -0,0 +1,86 @@ + + + + + + + +
+

Export Forms Data

+ + +
+ \ No newline at end of file diff --git a/javascript/pdf-manage-metadata/README.md b/javascript/pdf-manage-metadata/README.md new file mode 100644 index 0000000..006b006 --- /dev/null +++ b/javascript/pdf-manage-metadata/README.md @@ -0,0 +1,22 @@ +# How to Manage PDF Metadata (Document Properties) in JavaScript + +This project is a complete working application to manage PDF metadata (Document Properties) using JavaScript. + +## Getting Started + +To get started you need to clone the `pdf-manage-metadata` repository. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git +``` + +## Running + +You can run the application by simply opening the `index.html` file in any web browser. + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript-es5/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) diff --git a/javascript/pdf-manage-metadata/index.html b/javascript/pdf-manage-metadata/index.html new file mode 100644 index 0000000..bb8acda --- /dev/null +++ b/javascript/pdf-manage-metadata/index.html @@ -0,0 +1,77 @@ + + + + + + + +
+

Manage Meta Data

+ + +
+ \ No newline at end of file diff --git a/typescript/pdf-add-form/.github/workflows/gitleaks.yaml b/typescript/pdf-add-form/.github/workflows/gitleaks.yaml new file mode 100644 index 0000000..9ae62e1 --- /dev/null +++ b/typescript/pdf-add-form/.github/workflows/gitleaks.yaml @@ -0,0 +1,44 @@ +name: Secret Value found!! +on: + push: + public: +jobs: + scan: + name: gitleaks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Install the gitleaks + run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz + shell: pwsh + - name: Extract the tar file + run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz + - name: Generate the report + id: gitleaks + run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json + shell: bash + continue-on-error: true + - name: Setup NuGet.exe + if: steps.gitleaks.outcome != 'success' + uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - name: Install Mono + if: steps.gitleaks.outcome != 'success' + run: | + sudo apt update + sudo apt install -y mono-complete + - name: Install the dotnet SDK to a custom directory + if: steps.gitleaks.outcome != 'success' + run: | + mkdir -p $GITHUB_WORKSPACE/dotnet + curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir $GITHUB_WORKSPACE/dotnet --channel 6.0 + - name: Install the report tool packages + if: steps.gitleaks.outcome != 'success' + run: | + export PATH=$GITHUB_WORKSPACE/dotnet:$PATH + nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion + dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }} + exit 1 \ No newline at end of file diff --git a/typescript/pdf-add-form/README.md b/typescript/pdf-add-form/README.md new file mode 100644 index 0000000..d85cf95 --- /dev/null +++ b/typescript/pdf-add-form/README.md @@ -0,0 +1,43 @@ +# How to Add Form Fields to an Existing PDF in TypeScript + +This project is a complete working application to add form fields to an fxisting PDF using TypeScript. + +## Getting Started + +To get started you need to clone the `pdf-add-form` repository and navigate to `pdf-add-form` location. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git pdf-add-form +cd pdf-add-form +``` + +## Installing + +We can get all the Essential JS 2 components in a single npm package [`ej2`](https://www.npmjs.com/package/@syncfusion/ej2). + +We already configure the required packages in the `package.json` file. + +You can run the below command to install all dependent packages related to this seed project. + +``` +npm install @syncfusion/ej2-pdf +``` + +## Running + +The application is configured with [webpack-dev-server](https://webpack.js.org/configuration/dev-server/#devserver), so it will serve the web application in your default browser. + +We have used [Webpack](https://github.com/webpack/webpack) for module loading. + +You can use the below npm script to run the web application. + +``` +npm run start +``` + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) \ No newline at end of file diff --git a/typescript/pdf-add-form/e2e/index.spec.js b/typescript/pdf-add-form/e2e/index.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/typescript/pdf-add-form/e2e/protractor.conf.js b/typescript/pdf-add-form/e2e/protractor.conf.js new file mode 100644 index 0000000..43eee1b --- /dev/null +++ b/typescript/pdf-add-form/e2e/protractor.conf.js @@ -0,0 +1,21 @@ +exports.config = { + + allScriptsTimeout: 11000, + + capabilities: { + 'browserName': 'chrome' + }, + + framework: 'jasmine', + + jasmineNodeOpts: { + defaultTimeoutInterval: 10000 + }, + directConnect: true, + + onPrepare: function() { + browser.waitForAngularEnabled(false); + }, + + specs: ['./*.spec.js'] +}; \ No newline at end of file diff --git a/typescript/pdf-add-form/gulpfile.js b/typescript/pdf-add-form/gulpfile.js new file mode 100644 index 0000000..6a623f3 --- /dev/null +++ b/typescript/pdf-add-form/gulpfile.js @@ -0,0 +1,62 @@ +'use strict'; + +var gulp = require('gulp'); + +/** + * Compile TypeScript to JS + */ +gulp.task('compile', function (done) { + var webpack = require('webpack'); + var webpackStream = require('webpack-stream'); + gulp.src(['./src/app/app.ts']).pipe(webpackStream({ + config: require('./webpack.config.js') + }, webpack)) + .pipe(gulp.dest('./dist')) + .on('end', function () { + done(); + }); +}); + +/** + * Testing spec files + */ +var protractor = require('gulp-protractor').protractor; +var webdriver_standalone = require('gulp-protractor').webdriver_standalone; +var webdriver_update = require('gulp-protractor').webdriver_update_specific; + +gulp.task('e2e-serve', webdriver_standalone); + +gulp.task('e2e-webdriver-update', webdriver_update({ + webdriverManagerArgs: ['--ie', '--edge'] +})); + +gulp.task('e2e-test', gulp.series('compile', function (done) { + var browserSync = require('browser-sync'); + var bs = browserSync.create('Essential JS 2'); + var options = { + server: { + baseDir: [ + './dist/', + ], + directory: true + }, + ui: false, + open: false, + notify: false + }; + bs.init(options, function () { + gulp.src(['./spec/**/*.spec.js']) + .pipe(protractor({ + configFile: 'e2e/protractor.conf.js' + })) + .on('error', function (e) { + console.error('Error: ' + e.message); + done(); + process.exit(1); + }) + .on('end', function () { + done(); + process.exit(0); + }); + }); +})); \ No newline at end of file diff --git a/typescript/pdf-add-form/license b/typescript/pdf-add-form/license new file mode 100644 index 0000000..111c12a --- /dev/null +++ b/typescript/pdf-add-form/license @@ -0,0 +1,10 @@ +Essential JS 2 library is available under the Syncfusion Essential Studio program, and can be licensed either under the Syncfusion Community License Program or the Syncfusion commercial license. + +To be qualified for the Syncfusion Community License Program you must have a gross revenue of less than one (1) million U.S. dollars ($1,000,000.00 USD) per year and have less than five (5) developers in your organization, and agree to be bound by Syncfusion’s terms and conditions. + +Customers who do not qualify for the community license can contact sales@syncfusion.com for commercial licensing options. + +Under no circumstances can you use this product without (1) either a Community License or a commercial license and (2) without agreeing and abiding by Syncfusion’s license containing all terms and conditions. + +The Syncfusion license that contains the terms and conditions can be found at +https://www.syncfusion.com/content/downloads/syncfusion_license.pdf diff --git a/typescript/pdf-add-form/package.json b/typescript/pdf-add-form/package.json new file mode 100644 index 0000000..32cebf8 --- /dev/null +++ b/typescript/pdf-add-form/package.json @@ -0,0 +1,38 @@ +{ + "name": "ej2-quickstart", + "version": "0.0.1", + "description": "Essential JS 2 typescript quick start application", + "author": "Syncfusion Inc.", + "license": "SEE LICENSE IN license", + "repository": { + "type": "git", + "url": "https://github.com/syncfusion/ej2-quickstart.git" + }, + "scripts": { + "start": "webpack serve --mode development", + "build": "webpack --mode production", + "serve": "gulp e2e-serve", + "test": "gulp e2e-test", + "update-webdriver": "gulp e2e-webdriver-update" + }, + "devDependencies": { + "ajv": "^8.11.2", + "browser-sync": "^2.18.12", + "css-loader": "^6.7.2", + "gulp": "*", + "gulp-protractor": "*", + "gulp-typescript": "*", + "html-webpack-plugin": "^5.5.0", + "jasmine": "^2.6.0", + "mini-css-extract-plugin": "^2.7.0", + "ts-loader": "^9.5.1", + "typescript": "5.4.5", + "webpack": "^5.75.0", + "webpack-cli": "^5.0.0", + "webpack-dev-server": "^5.2.1", + "webpack-stream": "^7.0.0" + }, + "dependencies": { + "@syncfusion/ej2": "*" + } +} diff --git a/typescript/pdf-add-form/src/app/app.ts b/typescript/pdf-add-form/src/app/app.ts new file mode 100644 index 0000000..32b5622 --- /dev/null +++ b/typescript/pdf-add-form/src/app/app.ts @@ -0,0 +1,160 @@ +import { PdfDocument, PdfTextBoxField, PdfStandardFont, PdfFontFamily, PdfFontStyle, PdfBrush, PdfRadioButtonListField, PdfInteractiveBorder, PdfBorderStyle, PdfComboBoxField, PdfJavaScriptAction, PdfCheckBoxField, PdfButtonField, PdfHighlightMode } from '@syncfusion/ej2-pdf'; +import { Button } from '@syncfusion/ej2-buttons'; + +// Create button +const addForm = new Button({ cssClass: `e-primary` }); +addForm.appendTo('#addForm'); +// Add form to PDF on click +addForm.element.onclick = addFormFields; + +async function addFormFields(): Promise { + // Fetch the sample PDF bytes from the remote URL + const pdfBytes = await readFromPdfResources(templateURL); + // Create a PdfDocument instance from the fetched bytes + const document = new PdfDocument(pdfBytes); + const page = document.addPage(); + const graphics = page.graphics; + // Fonts + const font: PdfStandardFont = document.embedFont( + PdfFontFamily.helvetica, + 20, + PdfFontStyle.regular + ); + const radioFont = document.embedFont( + PdfFontFamily.helvetica, + 13, + PdfFontStyle.regular + ); + const comboFont = document.embedFont( + PdfFontFamily.helvetica, + 10, + PdfFontStyle.regular + ); + // Common styles + const black = { r: 0, g: 0, b: 0 }; + const white = { r: 255, g: 255, b: 255 }; + const brush = new PdfBrush(black); + const solidBorder = new PdfInteractiveBorder({ + width: 1, + style: PdfBorderStyle.solid + }); + // Name field + graphics.drawString('Name:', font, { x: 10, y: 58, width: 300, height: 400 }, brush); + const nameField = new PdfTextBoxField(page, 'Name', { + x: 100, + y: 60, + width: 200, + height: 22 + }); + document.form.add(nameField); + // Gender field + graphics.drawString('Gender:', font, { x: 10, y: 98, width: 300, height: 400 }, brush); + graphics.drawString('Male', radioFont, { x: 100, y: 105, width: 300, height: 400 }, brush); + graphics.drawString('Female', radioFont, { x: 150, y: 105, width: 300, height: 400 }, brush); + graphics.drawString('Other', radioFont, { x: 220, y: 105, width: 300, height: 400 }, brush); + const genderField = new PdfRadioButtonListField(page, 'Gender', { + items: [ + { name: 'Male', bounds: { x: 130, y: 108, width: 14, height: 10 } }, + { name: 'Female', bounds: { x: 195, y: 108, width: 14, height: 10 } }, + { name: 'Other', bounds: { x: 255, y: 108, width: 14, height: 10 } } + ], + selectedIndex: 1 + }); + document.form.add(genderField); + // Mail field + graphics.drawString('Mail:', font, { x: 10, y: 138, width: 300, height: 400 }, brush); + const mailField = new PdfTextBoxField(page, 'Name', { + x: 100, + y: 140, + width: 200, + height: 22 + }); + document.form.add(mailField); + // State dropdown + graphics.drawString('State:', font, { x: 10, y: 178, width: 300, height: 400 }, brush); + const stateField = new PdfComboBoxField( + page, + 'State', + { x: 100, y: 180, width: 200, height: 22 }, + { + items: [ + { text: 'California', value: 'CA' }, + { text: 'Washington D.C', value: 'DC' }, + { text: 'London', value: 'LN' } + ], + color: black, + backColor: white, + borderColor: black, + border: solidBorder, + selectedIndex: 0, + font: comboFont + } + ); + document.form.add(stateField); + // Date of birth field + graphics.drawString('DOB:', font, { x: 10, y: 218, width: 300, height: 400 }, brush); + const dateField = new PdfTextBoxField(page, 'DateField', { + x: 100, + y: 220, + width: 200, + height: 22 + }); + // Default date value + dateField.text = '18/08/2003'; + // Date format validation + const format = 'yyyy-mm-dd'; + dateField.actions.format = + new PdfJavaScriptAction(`AFDate_FormatEx("${format}");`); + dateField.actions.keyPressed = + new PdfJavaScriptAction(`AFDate_KeystrokeEx("${format}"):`); + dateField.actions.validate = + new PdfJavaScriptAction(`AFDate_Validate("${format}");`); + document.form.add(dateField); + // Terms and conditions checkbox + graphics.drawString('T&C', font, { x: 10, y: 258, width: 300, height: 400 }, brush); + const checkboxField = new PdfCheckBoxField( + 'AcceptTerms', + { x: 100, y: 262, width: 14, height: 14 }, + page, + { + toolTip: 'Accept the terms and conditions', + backColor: white, + borderColor: black, + border: solidBorder, + checked: true + } + ); + document.form.add(checkboxField); + // Submit button + const buttonField = new PdfButtonField( + page, + 'Submit', + { x: 10, y: 300, width: 120, height: 28 }, + { + toolTip: 'Submit form', + color: white, + backColor: { r: 0, g: 122, b: 204 }, + borderColor: black, + border: solidBorder, + text: 'Submit', + highlightMode: PdfHighlightMode.push + } + ); + // Generate button appearance + buttonField.setAppearance(true); + document.form.add(buttonField); + // Save PDF + document.save('AddFormFields.pdf'); + // Release resources + document.destroy(); +} +const templateURL = 'https://cdn.syncfusion.com/content/pdf-resources/pdf-succinctly.pdf'; +// Fetch URL and return Uint8Array +async function readFromPdfResources(url: string): Promise { + const res = await fetch(url); + if (!res.ok) { + throw new Error(`Failed to fetch PDF: ${res.status} ${res.statusText}`); + } + const buf = await res.arrayBuffer(); + return new Uint8Array(buf); +} \ No newline at end of file diff --git a/typescript/pdf-add-form/src/index.html b/typescript/pdf-add-form/src/index.html new file mode 100644 index 0000000..fd83915 --- /dev/null +++ b/typescript/pdf-add-form/src/index.html @@ -0,0 +1,12 @@ + + + + Add Form fields + + + +
+

Add Form fields to Existing PDF

+ +
+ \ No newline at end of file diff --git a/typescript/pdf-add-form/src/resources/favicon.ico b/typescript/pdf-add-form/src/resources/favicon.ico new file mode 100644 index 0000000..d8d5c15 Binary files /dev/null and b/typescript/pdf-add-form/src/resources/favicon.ico differ diff --git a/typescript/pdf-add-form/src/styles/styles.css b/typescript/pdf-add-form/src/styles/styles.css new file mode 100644 index 0000000..0da413e --- /dev/null +++ b/typescript/pdf-add-form/src/styles/styles.css @@ -0,0 +1 @@ +@import '../../node_modules/@syncfusion/ej2/material.css'; \ No newline at end of file diff --git a/typescript/pdf-add-form/tsconfig.json b/typescript/pdf-add-form/tsconfig.json new file mode 100644 index 0000000..3292391 --- /dev/null +++ b/typescript/pdf-add-form/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "ES6", + "sourceMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "bundler" + } +} diff --git a/typescript/pdf-add-form/webpack.config.js b/typescript/pdf-add-form/webpack.config.js new file mode 100644 index 0000000..8a2b060 --- /dev/null +++ b/typescript/pdf-add-form/webpack.config.js @@ -0,0 +1,45 @@ +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const path = require('path'); + +module.exports = { + entry: ['./src/app/app.ts', './src/styles/styles.css'], + module: { + rules: [ + { + test: /\.ts?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + { + test: /\.css$/, + use: [ MiniCssExtractPlugin.loader, "css-loader" ] + }, + ], + }, + resolve: { + extensions: ['.ts', '.js'], + }, + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, 'dist'), + }, + plugins: [ + new HtmlWebpackPlugin({ + template: 'src/index.html' + }), + new MiniCssExtractPlugin({ + filename: "bundle.css" + }) + ], + devServer: { + static: { + directory: path.join(__dirname, "dist"), + }, + compress: true, + port: 4000, + open: true, + hot: true, + historyApiFallback: true + }, +}; diff --git a/typescript/pdf-import-annotations/.github/workflows/gitleaks.yaml b/typescript/pdf-import-annotations/.github/workflows/gitleaks.yaml new file mode 100644 index 0000000..9ae62e1 --- /dev/null +++ b/typescript/pdf-import-annotations/.github/workflows/gitleaks.yaml @@ -0,0 +1,44 @@ +name: Secret Value found!! +on: + push: + public: +jobs: + scan: + name: gitleaks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Install the gitleaks + run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz + shell: pwsh + - name: Extract the tar file + run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz + - name: Generate the report + id: gitleaks + run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json + shell: bash + continue-on-error: true + - name: Setup NuGet.exe + if: steps.gitleaks.outcome != 'success' + uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - name: Install Mono + if: steps.gitleaks.outcome != 'success' + run: | + sudo apt update + sudo apt install -y mono-complete + - name: Install the dotnet SDK to a custom directory + if: steps.gitleaks.outcome != 'success' + run: | + mkdir -p $GITHUB_WORKSPACE/dotnet + curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir $GITHUB_WORKSPACE/dotnet --channel 6.0 + - name: Install the report tool packages + if: steps.gitleaks.outcome != 'success' + run: | + export PATH=$GITHUB_WORKSPACE/dotnet:$PATH + nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion + dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }} + exit 1 \ No newline at end of file diff --git a/typescript/pdf-import-annotations/README.md b/typescript/pdf-import-annotations/README.md new file mode 100644 index 0000000..239a17d --- /dev/null +++ b/typescript/pdf-import-annotations/README.md @@ -0,0 +1,43 @@ +# How to to Import Annotations into PDF using TypeScript + +This project is a complete working application to import annotations into PDF in TypeScript. + +## Getting Started + +To get started you need to clone the `pdf-import-annotations` repository and navigate to `pdf-import-annotations` location. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git pdf-import-annotations +cd pdf-import-annotations +``` + +## Installing + +We can get all the Essential JS 2 components in a single npm package [`ej2`](https://www.npmjs.com/package/@syncfusion/ej2). + +We already configure the required packages in the `package.json` file. + +You can run the below command to install all dependent packages related to this seed project. + +``` +npm install @syncfusion/ej2-pdf +``` + +## Running + +The application is configured with [webpack-dev-server](https://webpack.js.org/configuration/dev-server/#devserver), so it will serve the web application in your default browser. + +We have used [Webpack](https://github.com/webpack/webpack) for module loading. + +You can use the below npm script to run the web application. + +``` +npm run start +``` + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) \ No newline at end of file diff --git a/typescript/pdf-import-annotations/e2e/index.spec.js b/typescript/pdf-import-annotations/e2e/index.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/typescript/pdf-import-annotations/e2e/protractor.conf.js b/typescript/pdf-import-annotations/e2e/protractor.conf.js new file mode 100644 index 0000000..43eee1b --- /dev/null +++ b/typescript/pdf-import-annotations/e2e/protractor.conf.js @@ -0,0 +1,21 @@ +exports.config = { + + allScriptsTimeout: 11000, + + capabilities: { + 'browserName': 'chrome' + }, + + framework: 'jasmine', + + jasmineNodeOpts: { + defaultTimeoutInterval: 10000 + }, + directConnect: true, + + onPrepare: function() { + browser.waitForAngularEnabled(false); + }, + + specs: ['./*.spec.js'] +}; \ No newline at end of file diff --git a/typescript/pdf-import-annotations/gulpfile.js b/typescript/pdf-import-annotations/gulpfile.js new file mode 100644 index 0000000..6a623f3 --- /dev/null +++ b/typescript/pdf-import-annotations/gulpfile.js @@ -0,0 +1,62 @@ +'use strict'; + +var gulp = require('gulp'); + +/** + * Compile TypeScript to JS + */ +gulp.task('compile', function (done) { + var webpack = require('webpack'); + var webpackStream = require('webpack-stream'); + gulp.src(['./src/app/app.ts']).pipe(webpackStream({ + config: require('./webpack.config.js') + }, webpack)) + .pipe(gulp.dest('./dist')) + .on('end', function () { + done(); + }); +}); + +/** + * Testing spec files + */ +var protractor = require('gulp-protractor').protractor; +var webdriver_standalone = require('gulp-protractor').webdriver_standalone; +var webdriver_update = require('gulp-protractor').webdriver_update_specific; + +gulp.task('e2e-serve', webdriver_standalone); + +gulp.task('e2e-webdriver-update', webdriver_update({ + webdriverManagerArgs: ['--ie', '--edge'] +})); + +gulp.task('e2e-test', gulp.series('compile', function (done) { + var browserSync = require('browser-sync'); + var bs = browserSync.create('Essential JS 2'); + var options = { + server: { + baseDir: [ + './dist/', + ], + directory: true + }, + ui: false, + open: false, + notify: false + }; + bs.init(options, function () { + gulp.src(['./spec/**/*.spec.js']) + .pipe(protractor({ + configFile: 'e2e/protractor.conf.js' + })) + .on('error', function (e) { + console.error('Error: ' + e.message); + done(); + process.exit(1); + }) + .on('end', function () { + done(); + process.exit(0); + }); + }); +})); \ No newline at end of file diff --git a/typescript/pdf-import-annotations/license b/typescript/pdf-import-annotations/license new file mode 100644 index 0000000..111c12a --- /dev/null +++ b/typescript/pdf-import-annotations/license @@ -0,0 +1,10 @@ +Essential JS 2 library is available under the Syncfusion Essential Studio program, and can be licensed either under the Syncfusion Community License Program or the Syncfusion commercial license. + +To be qualified for the Syncfusion Community License Program you must have a gross revenue of less than one (1) million U.S. dollars ($1,000,000.00 USD) per year and have less than five (5) developers in your organization, and agree to be bound by Syncfusion’s terms and conditions. + +Customers who do not qualify for the community license can contact sales@syncfusion.com for commercial licensing options. + +Under no circumstances can you use this product without (1) either a Community License or a commercial license and (2) without agreeing and abiding by Syncfusion’s license containing all terms and conditions. + +The Syncfusion license that contains the terms and conditions can be found at +https://www.syncfusion.com/content/downloads/syncfusion_license.pdf diff --git a/typescript/pdf-import-annotations/package.json b/typescript/pdf-import-annotations/package.json new file mode 100644 index 0000000..32cebf8 --- /dev/null +++ b/typescript/pdf-import-annotations/package.json @@ -0,0 +1,38 @@ +{ + "name": "ej2-quickstart", + "version": "0.0.1", + "description": "Essential JS 2 typescript quick start application", + "author": "Syncfusion Inc.", + "license": "SEE LICENSE IN license", + "repository": { + "type": "git", + "url": "https://github.com/syncfusion/ej2-quickstart.git" + }, + "scripts": { + "start": "webpack serve --mode development", + "build": "webpack --mode production", + "serve": "gulp e2e-serve", + "test": "gulp e2e-test", + "update-webdriver": "gulp e2e-webdriver-update" + }, + "devDependencies": { + "ajv": "^8.11.2", + "browser-sync": "^2.18.12", + "css-loader": "^6.7.2", + "gulp": "*", + "gulp-protractor": "*", + "gulp-typescript": "*", + "html-webpack-plugin": "^5.5.0", + "jasmine": "^2.6.0", + "mini-css-extract-plugin": "^2.7.0", + "ts-loader": "^9.5.1", + "typescript": "5.4.5", + "webpack": "^5.75.0", + "webpack-cli": "^5.0.0", + "webpack-dev-server": "^5.2.1", + "webpack-stream": "^7.0.0" + }, + "dependencies": { + "@syncfusion/ej2": "*" + } +} diff --git a/typescript/pdf-import-annotations/src/app/app.ts b/typescript/pdf-import-annotations/src/app/app.ts new file mode 100644 index 0000000..8b9f52f --- /dev/null +++ b/typescript/pdf-import-annotations/src/app/app.ts @@ -0,0 +1,42 @@ +import { Button } from '@syncfusion/ej2-buttons'; +import { PdfDocument, DataFormat } from '@syncfusion/ej2-pdf'; + +// Create the Import Annotations button +const importBtn = new Button({ cssClass: `e-primary` }); +importBtn.appendTo('#importBtn'); +// Import annotations when the button is clicked +importBtn.element.onclick = importAnnotations; + +// Import annotations into a PDF document +function importAnnotations() { + Promise.all([ + fetchAsUint8Array('https://cdn.syncfusion.com/content/pdf-resources/ImportAnnotations.pdf'), + fetchAsUint8Array('https://cdn.syncfusion.com/content/pdf-resources/ImportAnnotations.json') + ]) + .then(function ([pdfBytes, jsonData]) { + // Load the PDF document + const document: PdfDocument = new PdfDocument(pdfBytes); + // Import annotations from the JSON file + document.importAnnotations(jsonData, DataFormat.json); + // Save the updated PDF document + document.save('output.pdf'); + // Dispose the document + document.destroy(); + }); +} + +// Fetch a file as a Uint8Array +function fetchAsUint8Array(url: any): Promise { + return fetch(url, { cache: 'no-cache' }) + .then(function (res) { + if (!res.ok) { + throw new Error( + 'Failed to fetch ' + url + ': ' + res.status + ' ' + res.statusText + ); + } + return res.arrayBuffer(); + }) + .then(function (buf) { + return new Uint8Array(buf); + }); +} \ No newline at end of file diff --git a/typescript/pdf-import-annotations/src/index.html b/typescript/pdf-import-annotations/src/index.html new file mode 100644 index 0000000..65e8fc7 --- /dev/null +++ b/typescript/pdf-import-annotations/src/index.html @@ -0,0 +1,9 @@ + + + + Import Annotation to PDF + + + + + \ No newline at end of file diff --git a/typescript/pdf-import-annotations/src/resources/favicon.ico b/typescript/pdf-import-annotations/src/resources/favicon.ico new file mode 100644 index 0000000..d8d5c15 Binary files /dev/null and b/typescript/pdf-import-annotations/src/resources/favicon.ico differ diff --git a/typescript/pdf-import-annotations/src/styles/styles.css b/typescript/pdf-import-annotations/src/styles/styles.css new file mode 100644 index 0000000..0da413e --- /dev/null +++ b/typescript/pdf-import-annotations/src/styles/styles.css @@ -0,0 +1 @@ +@import '../../node_modules/@syncfusion/ej2/material.css'; \ No newline at end of file diff --git a/typescript/pdf-import-annotations/tsconfig.json b/typescript/pdf-import-annotations/tsconfig.json new file mode 100644 index 0000000..3292391 --- /dev/null +++ b/typescript/pdf-import-annotations/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "ES6", + "sourceMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "bundler" + } +} diff --git a/typescript/pdf-import-annotations/webpack.config.js b/typescript/pdf-import-annotations/webpack.config.js new file mode 100644 index 0000000..8a2b060 --- /dev/null +++ b/typescript/pdf-import-annotations/webpack.config.js @@ -0,0 +1,45 @@ +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const path = require('path'); + +module.exports = { + entry: ['./src/app/app.ts', './src/styles/styles.css'], + module: { + rules: [ + { + test: /\.ts?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + { + test: /\.css$/, + use: [ MiniCssExtractPlugin.loader, "css-loader" ] + }, + ], + }, + resolve: { + extensions: ['.ts', '.js'], + }, + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, 'dist'), + }, + plugins: [ + new HtmlWebpackPlugin({ + template: 'src/index.html' + }), + new MiniCssExtractPlugin({ + filename: "bundle.css" + }) + ], + devServer: { + static: { + directory: path.join(__dirname, "dist"), + }, + compress: true, + port: 4000, + open: true, + hot: true, + historyApiFallback: true + }, +}; diff --git a/typescript/pdf-import-export-form/.github/workflows/gitleaks.yaml b/typescript/pdf-import-export-form/.github/workflows/gitleaks.yaml new file mode 100644 index 0000000..9ae62e1 --- /dev/null +++ b/typescript/pdf-import-export-form/.github/workflows/gitleaks.yaml @@ -0,0 +1,44 @@ +name: Secret Value found!! +on: + push: + public: +jobs: + scan: + name: gitleaks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Install the gitleaks + run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz + shell: pwsh + - name: Extract the tar file + run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz + - name: Generate the report + id: gitleaks + run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json + shell: bash + continue-on-error: true + - name: Setup NuGet.exe + if: steps.gitleaks.outcome != 'success' + uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - name: Install Mono + if: steps.gitleaks.outcome != 'success' + run: | + sudo apt update + sudo apt install -y mono-complete + - name: Install the dotnet SDK to a custom directory + if: steps.gitleaks.outcome != 'success' + run: | + mkdir -p $GITHUB_WORKSPACE/dotnet + curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir $GITHUB_WORKSPACE/dotnet --channel 6.0 + - name: Install the report tool packages + if: steps.gitleaks.outcome != 'success' + run: | + export PATH=$GITHUB_WORKSPACE/dotnet:$PATH + nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion + dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }} + exit 1 \ No newline at end of file diff --git a/typescript/pdf-import-export-form/README.md b/typescript/pdf-import-export-form/README.md new file mode 100644 index 0000000..dd5735b --- /dev/null +++ b/typescript/pdf-import-export-form/README.md @@ -0,0 +1,43 @@ +# How to Import and Export PDF Form Data (FDF, XFDF, JSON) in TypeScript + +This project is a complete working application to import and export PDF form data (FDF, XFDF, JSON) using TypeScript. + +## Getting Started + +To get started you need to clone the `pdf-import-export-form` repository and navigate to `pdf-import-export-form` location. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git pdf-import-export-form +cd pdf-import-export-form +``` + +## Installing + +We can get all the Essential JS 2 components in a single npm package [`ej2`](https://www.npmjs.com/package/@syncfusion/ej2). + +We already configure the required packages in the `package.json` file. + +You can run the below command to install all dependent packages related to this seed project. + +``` +npm install @syncfusion/ej2-pdf +``` + +## Running + +The application is configured with [webpack-dev-server](https://webpack.js.org/configuration/dev-server/#devserver), so it will serve the web application in your default browser. + +We have used [Webpack](https://github.com/webpack/webpack) for module loading. + +You can use the below npm script to run the web application. + +``` +npm run start +``` + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) \ No newline at end of file diff --git a/typescript/pdf-import-export-form/e2e/index.spec.js b/typescript/pdf-import-export-form/e2e/index.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/typescript/pdf-import-export-form/e2e/protractor.conf.js b/typescript/pdf-import-export-form/e2e/protractor.conf.js new file mode 100644 index 0000000..43eee1b --- /dev/null +++ b/typescript/pdf-import-export-form/e2e/protractor.conf.js @@ -0,0 +1,21 @@ +exports.config = { + + allScriptsTimeout: 11000, + + capabilities: { + 'browserName': 'chrome' + }, + + framework: 'jasmine', + + jasmineNodeOpts: { + defaultTimeoutInterval: 10000 + }, + directConnect: true, + + onPrepare: function() { + browser.waitForAngularEnabled(false); + }, + + specs: ['./*.spec.js'] +}; \ No newline at end of file diff --git a/typescript/pdf-import-export-form/gulpfile.js b/typescript/pdf-import-export-form/gulpfile.js new file mode 100644 index 0000000..6a623f3 --- /dev/null +++ b/typescript/pdf-import-export-form/gulpfile.js @@ -0,0 +1,62 @@ +'use strict'; + +var gulp = require('gulp'); + +/** + * Compile TypeScript to JS + */ +gulp.task('compile', function (done) { + var webpack = require('webpack'); + var webpackStream = require('webpack-stream'); + gulp.src(['./src/app/app.ts']).pipe(webpackStream({ + config: require('./webpack.config.js') + }, webpack)) + .pipe(gulp.dest('./dist')) + .on('end', function () { + done(); + }); +}); + +/** + * Testing spec files + */ +var protractor = require('gulp-protractor').protractor; +var webdriver_standalone = require('gulp-protractor').webdriver_standalone; +var webdriver_update = require('gulp-protractor').webdriver_update_specific; + +gulp.task('e2e-serve', webdriver_standalone); + +gulp.task('e2e-webdriver-update', webdriver_update({ + webdriverManagerArgs: ['--ie', '--edge'] +})); + +gulp.task('e2e-test', gulp.series('compile', function (done) { + var browserSync = require('browser-sync'); + var bs = browserSync.create('Essential JS 2'); + var options = { + server: { + baseDir: [ + './dist/', + ], + directory: true + }, + ui: false, + open: false, + notify: false + }; + bs.init(options, function () { + gulp.src(['./spec/**/*.spec.js']) + .pipe(protractor({ + configFile: 'e2e/protractor.conf.js' + })) + .on('error', function (e) { + console.error('Error: ' + e.message); + done(); + process.exit(1); + }) + .on('end', function () { + done(); + process.exit(0); + }); + }); +})); \ No newline at end of file diff --git a/typescript/pdf-import-export-form/license b/typescript/pdf-import-export-form/license new file mode 100644 index 0000000..111c12a --- /dev/null +++ b/typescript/pdf-import-export-form/license @@ -0,0 +1,10 @@ +Essential JS 2 library is available under the Syncfusion Essential Studio program, and can be licensed either under the Syncfusion Community License Program or the Syncfusion commercial license. + +To be qualified for the Syncfusion Community License Program you must have a gross revenue of less than one (1) million U.S. dollars ($1,000,000.00 USD) per year and have less than five (5) developers in your organization, and agree to be bound by Syncfusion’s terms and conditions. + +Customers who do not qualify for the community license can contact sales@syncfusion.com for commercial licensing options. + +Under no circumstances can you use this product without (1) either a Community License or a commercial license and (2) without agreeing and abiding by Syncfusion’s license containing all terms and conditions. + +The Syncfusion license that contains the terms and conditions can be found at +https://www.syncfusion.com/content/downloads/syncfusion_license.pdf diff --git a/typescript/pdf-import-export-form/package.json b/typescript/pdf-import-export-form/package.json new file mode 100644 index 0000000..32cebf8 --- /dev/null +++ b/typescript/pdf-import-export-form/package.json @@ -0,0 +1,38 @@ +{ + "name": "ej2-quickstart", + "version": "0.0.1", + "description": "Essential JS 2 typescript quick start application", + "author": "Syncfusion Inc.", + "license": "SEE LICENSE IN license", + "repository": { + "type": "git", + "url": "https://github.com/syncfusion/ej2-quickstart.git" + }, + "scripts": { + "start": "webpack serve --mode development", + "build": "webpack --mode production", + "serve": "gulp e2e-serve", + "test": "gulp e2e-test", + "update-webdriver": "gulp e2e-webdriver-update" + }, + "devDependencies": { + "ajv": "^8.11.2", + "browser-sync": "^2.18.12", + "css-loader": "^6.7.2", + "gulp": "*", + "gulp-protractor": "*", + "gulp-typescript": "*", + "html-webpack-plugin": "^5.5.0", + "jasmine": "^2.6.0", + "mini-css-extract-plugin": "^2.7.0", + "ts-loader": "^9.5.1", + "typescript": "5.4.5", + "webpack": "^5.75.0", + "webpack-cli": "^5.0.0", + "webpack-dev-server": "^5.2.1", + "webpack-stream": "^7.0.0" + }, + "dependencies": { + "@syncfusion/ej2": "*" + } +} diff --git a/typescript/pdf-import-export-form/src/app/app.ts b/typescript/pdf-import-export-form/src/app/app.ts new file mode 100644 index 0000000..4d1cb78 --- /dev/null +++ b/typescript/pdf-import-export-form/src/app/app.ts @@ -0,0 +1,64 @@ +import { PdfDocument, PdfFormFieldExportSettings, DataFormat } from '@syncfusion/ej2-pdf'; +import { Button } from '@syncfusion/ej2-buttons'; +// Create the Import Form Data button +var importForm = new Button({ cssClass: `e-primary` }); +importForm.appendTo('#importForm'); +// Import form data when the button is clicked +importForm.element.onclick = importFormFields; +// Create the Export Form Data button +var exportForm = new Button({ cssClass: `e-primary` }); +exportForm.appendTo('#exportForm'); +// Export form data when the button is clicked +exportForm.element.onclick = exportFormFields; +// Import JSON data into a PDF form +function importFormFields() { + Promise.all([ + fetchAsUint8Array( + 'https://cdn.syncfusion.com/content/pdf-resources/form-filling-document.pdf' + ), + fetchAsUint8Array( + 'https://cdn.syncfusion.com/content/pdf-resources/ExportedFormData.json' + ) + ]) + .then(function ([pdfBytes, formData]: [Uint8Array, Uint8Array]) { + // Load the PDF document + const document: PdfDocument = new PdfDocument(pdfBytes); + // Import the form data + document.importFormData(formData, DataFormat.json); + // Save the updated PDF document + document.save('ImportedForm.pdf'); + // Dispose the document + document.destroy(); + }) + .catch(function (err) { + console.error(err); + alert('Error:' + err); + alert('Failed to create fillable form PDF'); + }); +} +// Export PDF form data to a JSON file +function exportFormFields() { + fetchAsUint8Array( + 'https://cdn.syncfusion.com/content/pdf-resources/filled-form.pdf' + ) + .then(function (pdfBytes) { + // Load the PDF document + const pdf = new PdfDocument(pdfBytes); + // Create export settings + let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings(); + settings.dataFormat = DataFormat.json; + // Export the form data + pdf.exportFormData('ExportedFormData.json', settings); + // Dispose the document + pdf.destroy(); + }); +} +// Fetch a file as a Uint8Array +async function fetchAsUint8Array(url: string): Promise { + const res = await fetch(url, { cache: 'no-cache' }); + if (!res.ok) { + throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`); + } + const buf = await res.arrayBuffer(); + return new Uint8Array(buf); +} \ No newline at end of file diff --git a/typescript/pdf-import-export-form/src/index.html b/typescript/pdf-import-export-form/src/index.html new file mode 100644 index 0000000..3a5d0e7 --- /dev/null +++ b/typescript/pdf-import-export-form/src/index.html @@ -0,0 +1,13 @@ + + + + PDF Forms + + + +
+

PDF Forms

+ + +
+ \ No newline at end of file diff --git a/typescript/pdf-import-export-form/src/resources/favicon.ico b/typescript/pdf-import-export-form/src/resources/favicon.ico new file mode 100644 index 0000000..d8d5c15 Binary files /dev/null and b/typescript/pdf-import-export-form/src/resources/favicon.ico differ diff --git a/typescript/pdf-import-export-form/src/styles/styles.css b/typescript/pdf-import-export-form/src/styles/styles.css new file mode 100644 index 0000000..0da413e --- /dev/null +++ b/typescript/pdf-import-export-form/src/styles/styles.css @@ -0,0 +1 @@ +@import '../../node_modules/@syncfusion/ej2/material.css'; \ No newline at end of file diff --git a/typescript/pdf-import-export-form/tsconfig.json b/typescript/pdf-import-export-form/tsconfig.json new file mode 100644 index 0000000..3292391 --- /dev/null +++ b/typescript/pdf-import-export-form/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "ES6", + "sourceMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "bundler" + } +} diff --git a/typescript/pdf-import-export-form/webpack.config.js b/typescript/pdf-import-export-form/webpack.config.js new file mode 100644 index 0000000..8a2b060 --- /dev/null +++ b/typescript/pdf-import-export-form/webpack.config.js @@ -0,0 +1,45 @@ +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const path = require('path'); + +module.exports = { + entry: ['./src/app/app.ts', './src/styles/styles.css'], + module: { + rules: [ + { + test: /\.ts?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + { + test: /\.css$/, + use: [ MiniCssExtractPlugin.loader, "css-loader" ] + }, + ], + }, + resolve: { + extensions: ['.ts', '.js'], + }, + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, 'dist'), + }, + plugins: [ + new HtmlWebpackPlugin({ + template: 'src/index.html' + }), + new MiniCssExtractPlugin({ + filename: "bundle.css" + }) + ], + devServer: { + static: { + directory: path.join(__dirname, "dist"), + }, + compress: true, + port: 4000, + open: true, + hot: true, + historyApiFallback: true + }, +}; diff --git a/typescript/pdf-manage-metadata/.github/workflows/gitleaks.yaml b/typescript/pdf-manage-metadata/.github/workflows/gitleaks.yaml new file mode 100644 index 0000000..9ae62e1 --- /dev/null +++ b/typescript/pdf-manage-metadata/.github/workflows/gitleaks.yaml @@ -0,0 +1,44 @@ +name: Secret Value found!! +on: + push: + public: +jobs: + scan: + name: gitleaks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Install the gitleaks + run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz + shell: pwsh + - name: Extract the tar file + run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz + - name: Generate the report + id: gitleaks + run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json + shell: bash + continue-on-error: true + - name: Setup NuGet.exe + if: steps.gitleaks.outcome != 'success' + uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - name: Install Mono + if: steps.gitleaks.outcome != 'success' + run: | + sudo apt update + sudo apt install -y mono-complete + - name: Install the dotnet SDK to a custom directory + if: steps.gitleaks.outcome != 'success' + run: | + mkdir -p $GITHUB_WORKSPACE/dotnet + curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir $GITHUB_WORKSPACE/dotnet --channel 6.0 + - name: Install the report tool packages + if: steps.gitleaks.outcome != 'success' + run: | + export PATH=$GITHUB_WORKSPACE/dotnet:$PATH + nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion + dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/net6.0/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }} + exit 1 \ No newline at end of file diff --git a/typescript/pdf-manage-metadata/README.md b/typescript/pdf-manage-metadata/README.md new file mode 100644 index 0000000..6e81f7c --- /dev/null +++ b/typescript/pdf-manage-metadata/README.md @@ -0,0 +1,43 @@ +# How to Manage PDF Metadata (Document Properties) in TypeScript + +This project is a complete working application to manage PDF metadata (Document Properties) using TypeScript. + +## Getting Started + +To get started you need to clone the `pdf-manage-metadata` repository and navigate to `pdf-manage-metadata` location. + +``` +git clone https://github.com/SyncfusionExamples/javascript-pdf-examples.git pdf-manage-metadata +cd pdf-manage-metadata +``` + +## Installing + +We can get all the Essential JS 2 components in a single npm package [`ej2`](https://www.npmjs.com/package/@syncfusion/ej2). + +We already configure the required packages in the `package.json` file. + +You can run the below command to install all dependent packages related to this seed project. + +``` +npm install @syncfusion/ej2-pdf +``` + +## Running + +The application is configured with [webpack-dev-server](https://webpack.js.org/configuration/dev-server/#devserver), so it will serve the web application in your default browser. + +We have used [Webpack](https://github.com/webpack/webpack) for module loading. + +You can use the below npm script to run the web application. + +``` +npm run start +``` + +## Resources + +You can also refer the below resources to know more details about Javascript PDF Library. + +* [JavaScript PDF Library Demos](https://document.syncfusion.com/demos/pdf/javascript/#/tailwind3/pdf/default.html) +* [JavaScript PDF Library Documentation](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/overview) \ No newline at end of file diff --git a/typescript/pdf-manage-metadata/e2e/index.spec.js b/typescript/pdf-manage-metadata/e2e/index.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/typescript/pdf-manage-metadata/e2e/protractor.conf.js b/typescript/pdf-manage-metadata/e2e/protractor.conf.js new file mode 100644 index 0000000..43eee1b --- /dev/null +++ b/typescript/pdf-manage-metadata/e2e/protractor.conf.js @@ -0,0 +1,21 @@ +exports.config = { + + allScriptsTimeout: 11000, + + capabilities: { + 'browserName': 'chrome' + }, + + framework: 'jasmine', + + jasmineNodeOpts: { + defaultTimeoutInterval: 10000 + }, + directConnect: true, + + onPrepare: function() { + browser.waitForAngularEnabled(false); + }, + + specs: ['./*.spec.js'] +}; \ No newline at end of file diff --git a/typescript/pdf-manage-metadata/gulpfile.js b/typescript/pdf-manage-metadata/gulpfile.js new file mode 100644 index 0000000..6a623f3 --- /dev/null +++ b/typescript/pdf-manage-metadata/gulpfile.js @@ -0,0 +1,62 @@ +'use strict'; + +var gulp = require('gulp'); + +/** + * Compile TypeScript to JS + */ +gulp.task('compile', function (done) { + var webpack = require('webpack'); + var webpackStream = require('webpack-stream'); + gulp.src(['./src/app/app.ts']).pipe(webpackStream({ + config: require('./webpack.config.js') + }, webpack)) + .pipe(gulp.dest('./dist')) + .on('end', function () { + done(); + }); +}); + +/** + * Testing spec files + */ +var protractor = require('gulp-protractor').protractor; +var webdriver_standalone = require('gulp-protractor').webdriver_standalone; +var webdriver_update = require('gulp-protractor').webdriver_update_specific; + +gulp.task('e2e-serve', webdriver_standalone); + +gulp.task('e2e-webdriver-update', webdriver_update({ + webdriverManagerArgs: ['--ie', '--edge'] +})); + +gulp.task('e2e-test', gulp.series('compile', function (done) { + var browserSync = require('browser-sync'); + var bs = browserSync.create('Essential JS 2'); + var options = { + server: { + baseDir: [ + './dist/', + ], + directory: true + }, + ui: false, + open: false, + notify: false + }; + bs.init(options, function () { + gulp.src(['./spec/**/*.spec.js']) + .pipe(protractor({ + configFile: 'e2e/protractor.conf.js' + })) + .on('error', function (e) { + console.error('Error: ' + e.message); + done(); + process.exit(1); + }) + .on('end', function () { + done(); + process.exit(0); + }); + }); +})); \ No newline at end of file diff --git a/typescript/pdf-manage-metadata/license b/typescript/pdf-manage-metadata/license new file mode 100644 index 0000000..111c12a --- /dev/null +++ b/typescript/pdf-manage-metadata/license @@ -0,0 +1,10 @@ +Essential JS 2 library is available under the Syncfusion Essential Studio program, and can be licensed either under the Syncfusion Community License Program or the Syncfusion commercial license. + +To be qualified for the Syncfusion Community License Program you must have a gross revenue of less than one (1) million U.S. dollars ($1,000,000.00 USD) per year and have less than five (5) developers in your organization, and agree to be bound by Syncfusion’s terms and conditions. + +Customers who do not qualify for the community license can contact sales@syncfusion.com for commercial licensing options. + +Under no circumstances can you use this product without (1) either a Community License or a commercial license and (2) without agreeing and abiding by Syncfusion’s license containing all terms and conditions. + +The Syncfusion license that contains the terms and conditions can be found at +https://www.syncfusion.com/content/downloads/syncfusion_license.pdf diff --git a/typescript/pdf-manage-metadata/package.json b/typescript/pdf-manage-metadata/package.json new file mode 100644 index 0000000..32cebf8 --- /dev/null +++ b/typescript/pdf-manage-metadata/package.json @@ -0,0 +1,38 @@ +{ + "name": "ej2-quickstart", + "version": "0.0.1", + "description": "Essential JS 2 typescript quick start application", + "author": "Syncfusion Inc.", + "license": "SEE LICENSE IN license", + "repository": { + "type": "git", + "url": "https://github.com/syncfusion/ej2-quickstart.git" + }, + "scripts": { + "start": "webpack serve --mode development", + "build": "webpack --mode production", + "serve": "gulp e2e-serve", + "test": "gulp e2e-test", + "update-webdriver": "gulp e2e-webdriver-update" + }, + "devDependencies": { + "ajv": "^8.11.2", + "browser-sync": "^2.18.12", + "css-loader": "^6.7.2", + "gulp": "*", + "gulp-protractor": "*", + "gulp-typescript": "*", + "html-webpack-plugin": "^5.5.0", + "jasmine": "^2.6.0", + "mini-css-extract-plugin": "^2.7.0", + "ts-loader": "^9.5.1", + "typescript": "5.4.5", + "webpack": "^5.75.0", + "webpack-cli": "^5.0.0", + "webpack-dev-server": "^5.2.1", + "webpack-stream": "^7.0.0" + }, + "dependencies": { + "@syncfusion/ej2": "*" + } +} diff --git a/typescript/pdf-manage-metadata/src/app/app.ts b/typescript/pdf-manage-metadata/src/app/app.ts new file mode 100644 index 0000000..00ee25b --- /dev/null +++ b/typescript/pdf-manage-metadata/src/app/app.ts @@ -0,0 +1,66 @@ +import { PdfDocument, PdfXmpMetadata, PdfDocumentInformation } from '@syncfusion/ej2-pdf'; +import { Button } from '@syncfusion/ej2-buttons'; + +// Create the Add Metadata button +const addBtn = new Button({ cssClass: 'e-primary' }); +addBtn.appendTo('#addBtn'); +// Add metadata when the button is clicked +addBtn.element.onclick = addMetaData; + +// Create the Modify Metadata button +const modifyBtn = new Button({ cssClass: 'e-primary' }); +modifyBtn.appendTo('#modifyBtn'); +// Modify metadata when the button is clicked +modifyBtn.element.onclick = modifyMetaData; + +// Add metadata to a new PDF document +function addMetaData() { + // Create a PDF document + let document: PdfDocument = new PdfDocument(); + // Get the document information + let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false); + // Access the XMP metadata + let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata; + // Set basic metadata + xmpMetadata.basicSchema.creatorTool = 'My App'; + xmpMetadata.basicSchema.createDate = new Date(); + xmpMetadata.basicSchema.modifyDate = new Date(); + // Set Dublin Core metadata + xmpMetadata.dublinCoreSchema.title = { 'en-US': 'Sample PDF' }; + xmpMetadata.dublinCoreSchema.creator = ['Syncfusion']; + // Save the PDF document + document.save('AddedMetaData.pdf'); + // Dispose the document + document.destroy(); +} + +// Modify metadata in an existing PDF document +function modifyMetaData() { + fetchAsUint8Array( + 'https://cdn.syncfusion.com/content/pdf-resources/AddedMetaData.pdf' + ).then(function (pdfBytes) { + // Load the PDF document + let document: PdfDocument = new PdfDocument(pdfBytes); + // Get the document information + let documentProperties: PdfDocumentInformation = document.getDocumentInformation(false); + // Access the XMP metadata + let xmpMetadata: PdfXmpMetadata = documentProperties.xmpMetadata; + // Update the metadata values + xmpMetadata.basicSchema.creatorTool = 'Updated Tool'; + xmpMetadata.dublinCoreSchema.title = { 'en-US': 'Updated Title' }; + // Save the updated PDF document + document.save('ModifiedMetaData.pdf'); + // Dispose the document + document.destroy(); + }); +} + +// Fetch a file as a Uint8Array +async function fetchAsUint8Array(url: string): Promise { + const res = await fetch(url, { cache: 'no-cache' }); + if (!res.ok) { + throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`); + } + const buf = await res.arrayBuffer(); + return new Uint8Array(buf); +} \ No newline at end of file diff --git a/typescript/pdf-manage-metadata/src/index.html b/typescript/pdf-manage-metadata/src/index.html new file mode 100644 index 0000000..f3cd32a --- /dev/null +++ b/typescript/pdf-manage-metadata/src/index.html @@ -0,0 +1,13 @@ + + + + PDF Forms + + + +
+

PDF Forms

+ + +
+ \ No newline at end of file diff --git a/typescript/pdf-manage-metadata/src/resources/favicon.ico b/typescript/pdf-manage-metadata/src/resources/favicon.ico new file mode 100644 index 0000000..d8d5c15 Binary files /dev/null and b/typescript/pdf-manage-metadata/src/resources/favicon.ico differ diff --git a/typescript/pdf-manage-metadata/src/styles/styles.css b/typescript/pdf-manage-metadata/src/styles/styles.css new file mode 100644 index 0000000..0da413e --- /dev/null +++ b/typescript/pdf-manage-metadata/src/styles/styles.css @@ -0,0 +1 @@ +@import '../../node_modules/@syncfusion/ej2/material.css'; \ No newline at end of file diff --git a/typescript/pdf-manage-metadata/tsconfig.json b/typescript/pdf-manage-metadata/tsconfig.json new file mode 100644 index 0000000..3292391 --- /dev/null +++ b/typescript/pdf-manage-metadata/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "ES6", + "sourceMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "bundler" + } +} diff --git a/typescript/pdf-manage-metadata/webpack.config.js b/typescript/pdf-manage-metadata/webpack.config.js new file mode 100644 index 0000000..8a2b060 --- /dev/null +++ b/typescript/pdf-manage-metadata/webpack.config.js @@ -0,0 +1,45 @@ +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const path = require('path'); + +module.exports = { + entry: ['./src/app/app.ts', './src/styles/styles.css'], + module: { + rules: [ + { + test: /\.ts?$/, + use: 'ts-loader', + exclude: /node_modules/, + }, + { + test: /\.css$/, + use: [ MiniCssExtractPlugin.loader, "css-loader" ] + }, + ], + }, + resolve: { + extensions: ['.ts', '.js'], + }, + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, 'dist'), + }, + plugins: [ + new HtmlWebpackPlugin({ + template: 'src/index.html' + }), + new MiniCssExtractPlugin({ + filename: "bundle.css" + }) + ], + devServer: { + static: { + directory: path.join(__dirname, "dist"), + }, + compress: true, + port: 4000, + open: true, + hot: true, + historyApiFallback: true + }, +};