johansonkatherine
johansonkatherine
Reputation Top 1%
johansonkatherine
17 Snippets  (45th place)
Published
1 Channel
Created
6 Channels
Following
426 points  (76th place)
Reputation
Top 10% Publisher
Junior Code Generator
Serious Code Generator
Senior Code Generator
Junior Publisher
Serious Publisher
Senior Publisher
Junior Topic Hub
Junior Trend Maker
Junior Judge
Serious Judge
Junior Popular Coder
Serious Popular Coder
Senior Popular Coder
Junior Autobiographer
Junior Famous Coder
Senior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by johansonkatherine

public by johansonkatherine  2185  0  6  2

PHP Code to Unprotect Word Document Using Aspose for Cloud API

The following technical tip shows how php developers can unprotect their word documents in cloud using Aspose for Cloud SDK in php.
use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Product;
use Aspose\Cloud\Common\Utils;
use Aspose\Cloud\Words\Document;

/**** Section 1 ****/
Product::$baseProductUri = 'http://api.aspose.com/v1.1';
AsposeApp::$appSID = "xxxxxxxxxxxxxxxxxxxxxxxx";
AsposeApp::$appKey = "xxxxxxxxxxxxxxxxxxxxxxxx";
AsposeApp::$outPutLocation = getcwd() . "/output/";
/**** End Section 1 ****/

/**** Section 2 ****/
$fileName = "Test.docx";
$password = "123456";
$protectionType = "NoProtection";

$doc = new Document($fileName);
$result = $doc->unprotectDocument($password, $protectionType);
/**** End Section 2 ****/
			
;

public by johansonkatherine  3336  3  6  1

PHP Code to Protect a Word Document Using Aspose for Cloud API

The following technical tip shows how php developers can protect their word documents in cloud using Aspose for Cloud SDK in php.
use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Product;
use Aspose\Cloud\Common\Utils;
use Aspose\Cloud\Words\Document;

/**** Section 1 ****/
Product::$baseProductUri = 'http://api.aspose.com/v1.1';
AsposeApp::$appSID = "xxxxxxxxxxxxxxxxxxxxxxxx";
AsposeApp::$appKey = "xxxxxxxxxxxxxxxxxxxxxxxx";
AsposeApp::$outPutLocation = getcwd() . "/output/";
/**** End Section 1 ****/

/**** Section 2 ****/
$fileName = "Test.docx";
$password = "123456";
$protectionType = "AllowOnlyComments";

$doc = new Document($fileName);
$result = $doc->protectDocument($password, $protectionType);
/**** End Section 2 ****/
			
;

public by johansonkatherine  3649  1  6  3

Convert Email to Other Formats using Cloud API in Ruby

This technical tip shows how developers can convert email messages to other formats like EML, MSG & MHT in cloud using ruby language.
require 'path/to/lib/asposecloudsdk'

app_sid = '****'
app_key = '****'

Aspose::Cloud::Common::AsposeApp.app_key = app_key
Aspose::Cloud::Common::AsposeApp.app_sid = app_sid
Aspose::Cloud::Common::AsposeApp.output_location = ''
Aspose::Cloud::Common::Product.set_base_product_uri('http://api.aspose.com/v1.1')

# Create Object of folder class
folder = Aspose::Cloud::AsposeStorage::Folder.new
folder.upload_file 'path/to/storage/email_test.eml'

# Create object of converter
con_obj = Aspose::Cloud::Email::Converter.new('path/to/storage/email_test.eml')
con_obj.convert('msg')
;

public by johansonkatherine  4817  2  6  2

Load Existing Email Message and Modify its Contents inside Android Apps

This technical tip shows how to load any existing email message and modify its contents before saving it back to disk using Aspose.Email for Android API. To do this successfully, specify the MessageFormat when loading the email message from disk. In addition, it is important to specify the correct MailMessageSaveType when saving the message back to
public static void UpdateAndSaveEmail()
{
    // Base folder for reading and writing files
String  strBaseFolder  = Environment.getExternalStorageDirectory().getPath();
strBaseFolder = strBaseFolder + "/";

    //Initialize and load an existing MSG file by specifying the MessageFormat
MailMessage email = MailMessage.load(strBaseFolder + "anEmail.msg", MessageFormat.getMsg());

    //Initialize a String variable to get the Email Subject
    String subject = email.getSubject();
    //Append some more information to Subject
subject = subject + " This text is added to the existing subject";
    //Set the Email Subject
email.setSubject(subject);

    //Initialize a String variable to get the Email's HTML Body
    String body = email.getHtmlBody();
    //Apppend some more information to the Body variable
body = body + "<br> This text is added to the existing body";
    //Set the Email Body
email.setHtmlBody(body);

    //Initialize MailAddressCollection object
MailAddressCollection contacts = new MailAddressCollection();

    //Retrieve Email's TO list
contacts = email.getTo();
    //Check if TO list has some values
if (contacts.size() > 0)
    {
        //Remove the first email address
contacts.remove(0);
        //Add another email address to collection
contacts.add("to1@domain.com");
    }
    //Set the collection as Email's TO list
email.setTo(contacts);

    //Initialize MailAddressCollection
contacts = new MailAddressCollection();

    //Retrieve Email's CC list
contacts = email.getCC();
    //Add another email address to collection
contacts.add("cc2@domain.com");
    //Set the collection as Email's CC list
email.setCC(contacts);

    //Save the Email message to disk by specifying the MessageFormat
email.save(strBaseFolder + "message.msg", MailMessageSaveType.getOutlookMessageFormat());
;

public by johansonkatherine  2680  3  6  1

PHP Code Sample to Replace Multiple Text in PDF File Using Cloud API

The following code sample shows how developers can replace multiple texts in a single API call in a PDF file using Aspose.Pdf for Cloud API in their applications. Developers can use Aspose REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Utils;
use Aspose\Cloud\Common\Product;
						
AsposeApp::$appSID = "77******-1***-4***-a***-80**********"; 
AsposeApp::$appKey = "********************************";

$filePath = getcwd() . "/Input/test.pdf";
$fileName = basename($filePath);
$oldText1 = "[!firm!]";
$newText1 = "Aspose";
$oldText2 = "[!client!]";
$newText2 = "Mark";
$oldText3 = "[!transaction_date!]";
$newText3 = "01-01-2014";

//build URI
echo "Uploading pdf file... <br/>";
$strURIRequest = "http://api.aspose.com/v1.1/storage/file/" . $fileName;
$signedURI = Utils::sign($strURIRequest);

echoUtils::uploadFileBinary($signedURI, $filePath); 
echo "Pdf file has been uploaded successully<br/>";

echo "Replacing text...<br/>";
//Build JSON to post
$fieldsArray = array('TextReplaces'=>array(array('OldValue'=>$oldText1, 'NewValue'=>$newText1, 'Regex'=>'false'),
	array('OldValue'=>$oldText2, 'NewValue'=>$newText2, 'Regex'=>'false'), 
	array('OldValue'=>$oldText3, 'NewValue'=>$newText3, 'Regex'=>'false')));
$json = json_encode($fieldsArray);

//Build URI to replace text
$strURI = "http://api.aspose.com/v1.1/pdf/" . $fileName . "/replaceTextList";
$signedURI = Utils::sign($strURI);

$responseStream = Utils::processCommand($signedURI, "POST", "json", $json);

//Save PDF file on server
//build URI
$strURI = "http://api.aspose.com/v1.1/storage/file/" . $fileName;
//sign URI
$signedURI = Utils::sign($strURI);
$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$outputPath = getcwd() . "/output/" . $fileName;
Utils::saveFile($responseStream, $outputPath);
echo "The text has been replaced and Pdf file has saved at: " . $outputPath;
;