aspnetcore-js-devexpress-dot-richedit-f4b7a2ef.md
Declares settings related to document export to PDF.
export interface IRichEditPdfSettings
To learn more about PDF export in the Rich Text Editor, see the following topic: Export to PDF.
A constructor that creates a blobStream object.
blobStream?: new () => any
| Type |
|---|
| () => any |
To export a document to PDF, the RichEdit control requires a blobStream constructor. Depending on the framework and the way the library is built, this constructor can be placed in different directories. The control searches for the constructor in window.BlobStream. If the constructor is in another directory, specify the blobStream property.
Specifies a callback function that converts an image to JPEG or PNG format.
convertImageToCompatibleFormat?: (base64: string) => Promise<string>
| Type | Description |
|---|---|
| (base64: string) => Promise<string> |
A callback function that accepts an image in an incompatible format and returns an image in JPEG or PNG format.
|
The Rich Text Editor uses the PDFKit library when the control exports documents to PDF format. This library only supports JPEG and PNG image formats. Convert images of other formats to JPEG or PNG format to keep them in the resulting PDF document.
The convertImageToCompatibleFormat property specifies the function that converts an image in an incompatible format to JPEG or PNG format before exporting. The conversion does not affect images in the source document.
The example below demonstrates how to convert GIF images to a compatible format:
const options = DevExpress.RichEdit.createOptions();
options.pdf.convertImageToCompatibleFormat = (base64: string) => {
// Gets the image format
const match = /^data:.+;base64,(.*)$/.exec(base64);
const header = match[1].substring(0, 8);
const data = Buffer.from(header, 'base64');
const format = data.toString('ascii');
// Converts GIF images to a compatible format
if (format === 'GIF87a' || format === 'GIF89a') {
var gifFrames = require('gif-frames');
return gifFrames({ url: base64, frames: 0 }).
then(frameData => {
if (frameData.length > 0) {
const stream = frameData[0].getImage();
return stream.read().toString('base64');
}
});
}
// Ignores images of other incompatible formats
else
return new Promise(() => base64);
};
var richContainer = document.getElementById("rich-container");
const richEdit = DevExpress.RichEdit.create(richContainer, options);
Specifies a default font to which font families are mapped.
defaultFontName?: string
| Type | Description |
|---|---|
| string |
The font name.
|
The defaultFontName property specifies the name of the default font to which font families are mapped (when there is no appropriate rule in the rules collection).
Note
The defaultFontName property value should match the name property value of a font listed in the fonts collection.
Specifies the path where the exported PDF document is sent for further processing.
exportUrl?: string
| Type | Description |
|---|---|
| string |
The URL.
|
A constructor that creates a PDFDocument object.
pdfDocument?: new (options?: {
autoFirstPage: boolean;
defaultFont: any;
}) => any
| Type |
|---|
| (options?: {autoFirstPage: boolean, defaultFont: any}) => any |
To export a document to PDF, the RichEdit control requires a PDFDocument constructor. Depending on the framework and the way the library is built, this constructor can be placed in different directories. The control searches for the constructor in window.PDFDocument. If the constructor is in another directory, specify the pdfDocument property.
Specifies the path to the pdfkit library’s scripts.
pdfKitScriptUrl?: string
| Type | Description |
|---|---|
| string |
The URL.
|