Creates document content and converts it to new formats using the transformation API:
// create a plain text doc and convert to PDF, generated file will be placed in same space as original
var doc1 = userhome.createFile('transform_me1.txt');
doc1.mimetype = 'text/plain';
doc1.content = 'This is plain text';
var trans1 = doc1.transformDocument('application/pdf');
// create an HTML doc and convert to plain text, generated file will be created under the companyhome space
var doc2 = userhome.createFile('transform_me2.html');
doc2.mimetype = 'text/html';
doc2.content = 'This is an HTML document!';
var trans2 = doc2.transformDocument('text/plain', companyhome);
// create an HTML doc and convert to flash swf file, generated file will be created under the companyhome space
var doc3 = userhome.createFile('transform_me3.html');
doc3.mimetype = 'text/html';
doc3.content = 'This is an HTML document!';
var trans3 = doc3.transformDocument('application/x-shockwave-flash', companyhome);
Converts an image document to other formats:
// convert an image document to GIF format and place it in company home
var gifImage = document.transformImage('image/gif', companyhome);
// convert an image to JPG format and resize to thumbnail image
var thumbImage = document.transformImage('image/jpeg', '-resize 120');
Resize image (update image document):
//create a temporary folder to store the resized image (same name as original document)
var transformedImagesFolder = space.createFolder('_temp_resize_folder_' + _document.name);
//create a new resized image
var transformedImage = document.transformImage('image/jpeg', '-resize 1024x768', transformedImagesFolder);
//update the original image content with the resized image
document.properties.content.write(transformedImage.properties.content);
//delete the temporary resized image + folder
transformedImage.remove();
transformedImagesFolder.remove();
文档更新时间: 2020-02-16 16:07 作者:凌云文档