Newer Version Available
Blob Class
Contains methods for the Blob primitive data type.
Namespace
Usage
For more information on Blobs, see Primitive Data Types.
Blob Methods
The following are methods for Blob.
size()
Returns the number of characters in the Blob.
Signature
public Integer size()
Return Value
Type: Integer
Example
1String myString = 'StringToBlob';
2Blob myBlob = Blob.valueof(myString);
3Integer size = myBlob.size();toPdf(stringToConvert)
Creates a binary object out of the given string, encoding
it as a PDF file.
Signature
public static Blob toPdf(String stringToConvert)
Parameters
- stringToConvert
- Type: String
Return Value
Type: Blob
Example
1String pdfContent = 'This is a test string';
2Account a = new account(name = 'test');
3insert a;
4Attachment attachmentPDF = new Attachment();
5attachmentPdf.parentId = a.id;
6attachmentPdf.name = account.name + '.pdf';
7attachmentPdf.body = blob.toPDF(pdfContent);
8insert attachmentPDF;toString()
Casts the Blob into a String.
Signature
public String toString()
Return Value
Type: String
Example
1String myString = 'StringToBlob';
2Blob myBlob = Blob.valueof(myString);
3System.assertEquals('StringToBlob', myBlob.toString());