Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Document-Processing/PDF/PDF-Library/javascript/Annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ N> Setting `document.flatten = true;` flattens all interactive elements in the P

## Importing annotations

This example demonstrates how to import annotations into a PDF document using the PdfDocument. `importAnnotations` method. The DataFormat enum specifies the format of the annotation data being imported, such as FDF, XFDF, JSON, or XML.
This example demonstrates how to import annotations into a PDF document using the `importAnnotations` method. The DataFormat enum specifies the format of the annotation data being imported, such as FDF, XFDF, JSON, or XML.

{% tabs %}
{% highlight typescript tabtitle="TypeScript" %}
Expand Down Expand Up @@ -1333,7 +1333,7 @@ document.destroy();

## Exporting annotations

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

{% tabs %}
{% highlight typescript tabtitle="TypeScript" %}
Expand All @@ -1345,7 +1345,7 @@ let document: PdfDocument = new PdfDocument(data);
let settings: PdfAnnotationExportSettings = new PdfAnnotationExportSettings();
settings.dataFormat = DataFormat.json;
// Export annotations to JSON format
let jsonData = document.exportAnnotations('annotations.json', settings);
document.exportAnnotations('annotations.json', settings);
// Destroy the document
document.destroy();

Expand All @@ -1357,7 +1357,7 @@ var document = new ej.pdf.PdfDocument(data);
var settings = new ej.pdf.PdfAnnotationExportSettings();
settings.dataFormat = ej.pdf.DataFormat.json;
// Export annotations to JSON format
var jsonData = document.exportAnnotations('annotations.json', settings);
document.exportAnnotations('annotations.json', settings);
// Close the document
document.destroy();

Expand Down
48 changes: 24 additions & 24 deletions Document-Processing/PDF/PDF-Library/javascript/Bookmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ let page: PdfPage = document.addPage();
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Add a new bookmark to the PDF document
let bookmark: PdfBookmark = bookmarks.add('Introduction', 0, {
destination: new PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new PdfNamedDestination('First', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: PdfTextStyle.bold});
destination: new PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new PdfNamedDestination('First', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: PdfTextStyle.bold});
// Save the document
document.save('output.pdf');
// Close the document
Expand All @@ -45,10 +45,10 @@ var page = document.addPage();
var bookmarks = document.bookmarks;
// Add a new bookmark to the PDF document
var bookmark = bookmarks.add('Introduction', 0, {
destination: new ej.pdf.PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new ej.pdf.PdfNamedDestination('First', new ej.pdf.PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: ej.pdf.PdfTextStyle.bold});
destination: new ej.pdf.PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new ej.pdf.PdfNamedDestination('First', new ej.pdf.PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: ej.pdf.PdfTextStyle.bold});
// Save the document
document.save('output.pdf');
// Close the document
Expand Down Expand Up @@ -117,16 +117,16 @@ let page: PdfPage = document.addPage();
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Add a new bookmark to the PDF document
let bookmark: PdfBookmark = bookmarks.add('Introduction', 0, {
destination: new PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new PdfNamedDestination('First', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: PdfTextStyle.bold});
destination: new PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new PdfNamedDestination('First', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: PdfTextStyle.bold});
// Add a child bookmark to the PDF document
let childbookmark: PdfBookmark = bookmark.add('FirstChild', 0, {
destination: new PdfDestination(page, { x: 100, y: 150 }, { zoom: 1 }),
namedDestination: new PdfNamedDestination('Second', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: PdfTextStyle.bold});
destination: new PdfDestination(page, { x: 100, y: 150 }, { zoom: 1 }),
namedDestination: new PdfNamedDestination('Second', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: PdfTextStyle.bold});
// Save the document
document.save('output.pdf');
// Close the document
Expand All @@ -143,16 +143,16 @@ var page= document.addPage();
var bookmarks = document.bookmarks;
// Add a new bookmark to the PDF document
var bookmark = bookmarks.add('Introduction', 0, {
destination: new ej.pdf.PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new ej.pdf.PdfNamedDestination('First', new ej.pdf.PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: ej.pdf.PdfTextStyle.bold});
destination: new ej.pdf.PdfDestination(page, { x: 100, y: 100 }, { zoom: 1 }),
namedDestination: new ej.pdf.PdfNamedDestination('First', new ej.pdf.PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: ej.pdf.PdfTextStyle.bold});
// Add a child bookmark to the PDF document
var childbookmark = bookmark.add('FirstChild', 0, {
destination: new ej.pdf.PdfDestination(page, { x: 100, y: 150 }, { zoom: 1 }),
namedDestination: new ej.pdf.PdfNamedDestination('Second', new ej.pdf.PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: ej.pdf.PdfTextStyle.bold});
destination: new ej.pdf.PdfDestination(page, { x: 100, y: 150 }, { zoom: 1 }),
namedDestination: new ej.pdf.PdfNamedDestination('Second', new ej.pdf.PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
color: { r: 0, g: 0, b: 255 },
textStyle: ej.pdf.PdfTextStyle.bold});
// Save the document
document.save('output.pdf');
// Close the document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Step 6: **Create a PDF document**: Add the script in `~/Views/Home/Index.cshtml`
</div>
@section Scripts {
<script>
document.getElementById('btnCreatePdf').addEventListener('click', function () {
document.getElementById('btnCreatePdf').addEventListener('click', function () {
// Create a new PDF document
let pdf = new ej.pdf.PdfDocument();
// Add a new page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Step 4: **Create a PDF document**: Add the script in `index.html` by creating a
<button id="btnCreatePdf" class="btn btn-primary">Generate PDF document</button>
</div>
@section Scripts {
<script>
document.getElementById('btnCreatePdf').addEventListener('click', function () {
<script>
document.getElementById('btnCreatePdf').addEventListener('click', function () {
// Create a new PDF document
var pdf = new ej.pdf.PdfDocument();
// Add a new page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ import { PdfDocument, PdfGraphics, PdfPage, PdfFont, PdfFontFamily, PdfFontStyle
{% tabs %}
{% highlight ts tabtitle="index.ts" %}
document.getElementById('normalButton').onclick = (): void => {
// Create a new PDF document
let pdf = new PdfDocument();
// Add a new page
let page: PdfPage = pdf.addPage();
// Get graphics from the page
let graphics: PdfGraphics = page.graphics;
// Set font
let font: PdfFont = pdf.embedFont(PdfFontFamily.helvetica, 36, PdfFontStyle.regular);
// Create a new black brush
let brush = new PdfBrush({r: 0, g: 0, b: 0});
// Draw text
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
// Save and download PDF
pdf.save('output.pdf');
// Destroy the PDF document instance
pdf.destroy();
// Create a new PDF document
let pdf = new PdfDocument();
// Add a new page
let page: PdfPage = pdf.addPage();
// Get graphics from the page
let graphics: PdfGraphics = page.graphics;
// Set font
let font: PdfFont = pdf.embedFont(PdfFontFamily.helvetica, 36, PdfFontStyle.regular);
// Create a new black brush
let brush = new PdfBrush({r: 0, g: 0, b: 0});
// Draw text
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
// Save and download PDF
pdf.save('output.pdf');
// Destroy the PDF document instance
pdf.destroy();
};
{% endhighlight %}
{% endtabs %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,22 @@ export default {
name: 'App',
methods: {
createPdf() {

// Create a new PDF document
const pdf = new ej.pdf.PdfDocument();
// Add a new page
const page: ej.pdf.PdfPage = pdf.addPage();
// Get graphics from the page
const graphics: ej.pdf.PdfGraphics = page.graphics;
// Set font
const font: ej.pdf.PdfStandardFont = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
// Create a new black brush
const brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
// Draw text
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
// Save and download PDF
pdf.save('Output.pdf');
// Destroy the PDF document instance
pdf.destroy();
// Create a new PDF document
const pdf = new ej.pdf.PdfDocument();
// Add a new page
const page: ej.pdf.PdfPage = pdf.addPage();
// Get graphics from the page
const graphics: ej.pdf.PdfGraphics = page.graphics;
// Set font
const font: ej.pdf.PdfStandardFont = pdf.embedFont(ej.pdf.PdfFontFamily.helvetica, 36, ej.pdf.PdfFontStyle.regular);
// Create a new black brush
const brush = new ej.pdf.PdfBrush({r: 0, g: 0, b: 0});
// Draw text
graphics.drawString('Hello World!!!', font, {x: 20, y: 20, width: graphics.clientSize.width - 20, height: 60}, brush);
// Save and download PDF
pdf.save('Output.pdf');
// Destroy the PDF document instance
pdf.destroy();

}
}
Expand Down
105 changes: 15 additions & 90 deletions Document-Processing/PDF/PDF-Library/javascript/FormFields.md
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,7 @@ document.destroy();

## Importing form fields data

### Importing FDF file to PDF

This example demonstrates how to import form data from an FDF file into a PDF document using the `importFormData` method. Importing FDF data allows you to populate form fields in a PDF with values from an external data source.
This example demonstrates how to import form data from an FDF file into a PDF document using the `importFormData` method. The DataFormat enum specifies the format of the annotation data being imported, such as FDF, XFDF, JSON, or XML.

{% tabs %}
{% highlight typescript tabtitle="TypeScript" %}
Expand All @@ -1083,43 +1081,14 @@ document.importFormData(fdfData, DataFormat.fdf);
document.save('Output.pdf');
// Close the document
document.destroy();
{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}
// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data);
// Imports form data into the PDF document.
document.importFormData(fdfData, ej.pdf.DataFormat.fdf);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
{% endhighlight %}
{% endtabs %}

### Importing XFDF file to PDF

This example demonstrates how to import form data from an XFDF file into a PDF document using the `importFormData` method. Importing XFDF data allows you to populate form fields in a PDF with values from an external data source.

{% tabs %}
{% highlight typescript tabtitle="TypeScript" %}
import {PdfDocument, DataFormat} from '@syncfusion/ej2-pdf';

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Imports form data into the PDF document.
document.importFormData(xfdfData, DataFormat.xfdf);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}

// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data);
// Imports form data into the PDF document.
document.importFormData(xfdfData, ej.pdf.DataFormat.xfdf);
document.importFormData(fdfData, ej.pdf.DataFormat.fdf);
// Save the document
document.save('Output.pdf');
// Close the document
Expand All @@ -1130,78 +1099,34 @@ document.destroy();

## Exporting form fields data

### Export PDF file to FDF

This example demonstrates how to export form data from a PDF document to an FDF file using the `exportFormData` method. Exporting FDF data allows you to save the values of form fields in a lightweight format for reuse or integration with other systems.
This example demonstrates how to export form data from a PDF document to an FDF file using the `exportFormData` method. The DataFormat enum specifies the format of the annotation data being imported, such as FDF, XFDF, JSON, or XML.

{% tabs %}
{% highlight typescript tabtitle="TypeScript" %}
import {PdfDocument, PdfFormFieldExportSettings, DataFormat } from '@syncfusion/ej2-pdf';

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Sets the form field data export settings with output data format.
let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
settings.dataFormat = DataFormat.fdf;
// Export form field to fdf format
let fdf: Uint8Array = document.exportFormData(settings);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}

// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data);
// Sets the form field data export settings with output data format.
var settings = new ej.pdf.PdfFormFieldExportSettings();
settings.dataFormat = ej.pdf.DataFormat.fdf;
// Export form field to fdf format
var fdf = document.exportFormData(settings);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% endtabs %}

### Export PDF file to XFDF

This example demonstrates how to export form data from a PDF document to an XFDF file using the `exportFormData` method. Exporting XFDF data allows you to save the values of form fields in a lightweight format for reuse or integration with other systems.

{% tabs %}
{% highlight typescript tabtitle="TypeScript" %}
import {PdfDocument, PdfFormFieldExportSettings, DataFormat } from '@syncfusion/ej2-pdf';

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Sets the form field data export settings with output data format.
// Sets the form field data export settings with output data format
let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
settings.dataFormat = DataFormat.xfdf;
// Export form field to XFDF format
let xfdf: Uint8Array = document.exportFormData(settings);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
settings.dataFormat = DataFormat.json;
// Export form field to JSON format
document.exportFormData('formData.json', settings);
// Destroy the document
document. Destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}

// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data);
// Sets the form field data export settings with output data format.
// Sets the form field data export settings with output data format
var settings = new ej.pdf.PdfFormFieldExportSettings();
settings.dataFormat = ej.pdf.DataFormat.xfdf;
// Export form field to XFDF format
var xfdf = document.exportFormData(settings);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
settings.dataFormat = ej.pdf.DataFormat.json;
// Export form field to JSON format
document.exportFormData('formData.json', settings);
// Destroy the document
document. Destroy();

{% endhighlight %}
{% endtabs %}
Loading