JScript Document

From RealWorld Wiki

Jump to: navigation, search
RealWorld scripting reference

Document is a global object accessible in the JScript document operation.

[edit] Methods and properties

  • string Location (get/set) - the full path to the file.
  • string Name (get/set) - modifies the name and extension of a document.
  • void Save() - saves the document if the Location field is valid (see storage plug-ins).
  • void SaveCopyAs(string location) - saves the document to given location. The location of the document remains unchanged.
  • object Duplicate() - returns duplicate of the document. Changes made to the duplicate will not affect the original and the same applies for the opposite direction. Location of the duplicate is invalid.
  • object <interface name> (get) - obtain type-specific interface. The interfaces available depend on the actual document and on installed scripting interface plug-ins.

[edit] Interface wrappers

  • RasterImage - modify raster images pixel by pixel and set canvas size.
  • EXIF - access EXIF tags.
  • Palette - read and modify palette of indexed images.
  • Icon - add, delete or modify images in icons. Change icon file type.
  • Text - modify text.
  • Resources - modify resources in Win32 PE files. Currently, only icon libraries are supported.

[edit] Example

// create a duplicate
var dup = Document.Duplicate();
// modify the duplicate, for example:
// if the document is a raster image, make the first pixel grey
dup.RasterImage.SetPixel(0, 0, 0, 0, 0xff808080);
// save the modified document into C:\temp using original name
dup.SaveCopyAs("C:\\temp\\"+Document.Name);
// the original document remains unchanged
Personal tools