INTEGRAL DSL Reference Guide
Jump directly to:
::my.app.ExportToFile(filename, filetype, width, height, additional_pages = 0, page = DX_PAGE_CURR, transp = DX_TRANSP_NO, quality = 75, anim_delay = 50, anim_loops = 0)
::my.app.Export(filetype, width, height, additional_pages = 0, page = DX_PAGE_CURR, transp = DX_TRANSP_NO, quality = 75, anim_delay = 50, anim_loops = 0)
These functions export one or more pages in the current INTEGRAL document to an output file in the specified format. ExportToFile writes its output to the file specified by the filename parameter while Export writes directly to the INTEGRAL output buffer. The two functions are identical otherwise.
Parameters
filename
A string containing the name (path) of the output file to be created. This path is relative to the current working directory. If a file with the same name already exists, its content is overwritten. This parameter applies only to ExportToFile.
filetype
An integer that defines the format of the output file. It must be one of the following:
Raster (bitmap) image formats that support animation:
- const DX_FORMAT_APNG = 301 — APNG format (animated PNG; an extension of the PNG format).
- const DX_FORMAT_GIF = 300 — Standard GIF format.
Scalable vector graphic formats:
- const DX_FORMAT_SVG_LARGE = 200 — SVG format without symbol factorization.
- const DX_FORMAT_SVG_SMALL = 201 — SVG format with symbol factorization. This is the standard SVG export format.
- const DX_FORMAT_SVG_LARGE_MODERN = 202 — Same as DX_FORMAT_SVG_LARGE but intended for modern web browsers that support SVG 2 specification.
- const DX_FORMAT_SVG_SMALL_MODERN = 203 — Same as DX_FORMAT_SVG_SMALL but intended for modern web browsers that support SVG 2 specification.
- const DX_FORMAT_SVG = 201 — Standard SVG export format; same as DX_FORMAT_SVG_SMALL.
Document formats:
- const DX_FORMAT_PDF_WFRAME = 103 — PDF format containing vector graphics and bitmap images; any text in the document is exported in the form of wireframes that represent glyph bounding boxes. This format is intended primarily for debugging purposes.
- const DX_FORMAT_PDF_NORMAL = 102 — PDF format containing text (and related fonts which are always embedded), vector graphics and bitmap images. This is the standard PDF export format.
- const DX_FORMAT_PDF_VECTOR = 101 — PDF format containing only vector graphics and bitmap images; any text in the document is converted to vector graphics.
- const DX_FORMAT_PDF_BITMAP = 100 — PDF format containing only bitmap images; any text and vector graphics in the document are converted to bitmaps.
- const DX_FORMAT_PDF = 102 — Standard PDF export format; same as DX_FORMAT_PDF_NORMAL.
Raster (bitmap) image formats:
- const DX_FORMAT_JPG = 3 — Standard JPEG format.
- const DX_FORMAT_PNG = 2 — Standard PNG format.
- const DX_FORMAT_BMP = 1 — Windows BMP format.
- const DX_FORMAT_RAW = 0 — Raw RGB bitmap (32-bpp).
width
An integer that defines the width of the exported page(s), in INTEGRAL document units.
height
An integer that defines the height of the exported page(s), in INTEGRAL document units.
additional_pages
An integer that defines what additional pages to export (i.e. pages to follow the page specified by the page parameter) and their order.
- If additional_pages = 0, the only page in the output file will be page (i.e. no additional pages will be included).
- If additional_pages > 0, the output file will contain the following pages: page, (page + 1), (page + 2), ... , (page + additional_pages).
- If additional_pages < 0, the output file will contain the following pages: page, (page - 1), (page - 2), ... , (page - abs(additional_pages)).
However, not all export formats respect this parameter. Export formats that support only one page per output file (e.g. all raster image formats) will ignore this parameter, which means the output will be the same as if additional_pages was set to 0.
page
An integer that defines the first page to export. This must be either a non-negative integer representing a specific page to export or, alternatively, DX_PAGE_CURR which means the current page.
- const DX_PAGE_CURR = -1 — Current page.
transp
An integer that defines the transparency setting of the background. It must be one of the following:
- const DX_TRANSP_NO = 0 — no transparent background (always supported)
- const DX_TRANSP_BASIC = 1 — basic transparency setting
- const DX_TRANSP_ALPHA = 3 — alpha transparency (supported in PNG and APNG formats only)
This value is respected only with raster image formats; in other cases it is ignored.
quality
An integer that defines the quality level of the export. It must be a value in the 0 - 100 range. 0 is the lowest quality level, 100 is the highest. The value of 75 is recommended for medium to high quality JPEGs. For GIFs, quality levels over 75 utilize dithering (and result in a lower export speed). This value is respected only with lossy compression formats such as GIF or JPEG; in other cases it is ignored.
anim_delay
A non-negative integer that defines the animation delay between pages (which are treated as animation frames), in 1/100 seconds. This value is respected only with export formats that support animation, such as GIF or APNG; in other cases it is ignored.
anim_loops
A non-negative integer that indicates the number of times that the animation should play; if 0, the animation should play indefinitely. If positive, the animation should stop on the final frame, at the end of the last loop. This value is respected only with export formats that support animation, such as GIF or APNG; in other cases it is ignored.
Return Value
Both functions return DV_RET_OK on success and DV_RET_ERR on failure.
- const DV_RET_ERR = 0 — failure
- const DV_RET_OK = 1 — success
Notes
Both functions can be called multiple times during a web session. However, it makes sense to call Export only once. This is because each call to Export overwrites the contents of the INTEGRAL output buffer. This means that only the most recently generated file stays in the output buffer. Also, once Export is called, the buffer output mode is set to binary; any subsequent calls to Print or any other function that writes to the output buffer in text mode will fail.
Example 1
::my.app.ExportToFile("private/document.pdf", DX_FORMAT_PDF, 1000, 1800, 1, 0);
Example 2
::my.app.Export(DX_FORMAT_PDF, 1000, 1800, -2, 4);
Example 3
::my.app.Export(DX_FORMAT_GIF, 400, 200, 8, 0, DX_TRANSP_ALPHA, 50, 100, 3);
Example 4
::my.app.SetHeaders("Content-Disposition: attachment; filename=\"animation.gif\"\r\n");
::my.app.Export(DX_FORMAT_GIF, 400, 200, 8, 0, DX_TRANSP_ALPHA, 50, 100, 3);
Example 5
::my.app.ExportToFile("private/animation.gif", DX_FORMAT_GIF, 400, 200, 8, 0, DX_TRANSP_ALPHA, 50, 100, 3);
Example 6
::my.app.SetHeaders("Content-Language: fr\r\nContent-Disposition: attachment; filename=\"fichier_2149.pdf\"\r\n");
::my.app.ExportToFile("storage/fichier_2149.pdf", DX_FORMAT_PDF, 1000, 1800, 10);
::my.app.Write("storage/fichier_2149.pdf");