Skip to main content

IRichEditPdfSettings Interface

Declares settings related to document export to PDF.

Declaration

export interface IRichEditPdfSettings

Remarks

To learn more about PDF export in the Rich Text Editor, see the following topic: Export to PDF.

Properties

blobStream Property

A constructor that creates a blobStream object.

Declaration

blobStream?: new () => any

Property Value

Type
() => any

Remarks

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.

convertImageToCompatibleFormat Property

Specifies a callback function that converts an image to JPEG or PNG format.

Declaration

convertImageToCompatibleFormat?: (base64: string) => Promise<string>

Property Value

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.

Remarks

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);

defaultFontName Property

Specifies a default font to which font families are mapped.

Declaration

defaultFontName?: string

Property Value

Type Description
string

The font name.

Remarks

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.

exportUrl Property

Specifies the path where the exported PDF document is sent for further processing.

Declaration

exportUrl?: string

Property Value

Type Description
string

The URL.

pdfDocument Property

A constructor that creates a PDFDocument object.

Declaration

pdfDocument?: new (options?: {
    autoFirstPage: boolean;
    defaultFont: any;
}) => any

Property Value

Type
(options?: {autoFirstPage: boolean, defaultFont: any}) => any

Remarks

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.

pdfKitScriptUrl Property

Specifies the path to the pdfkit library’s scripts.

Declaration

pdfKitScriptUrl?: string

Property Value

Type Description
string

The URL.