Blob Class
Contains methods for the Blob primitive data type.
Salesforce supports Blob manipulation only with Apex class methods that are supplied by Salesforce. For more information on Blobs, see Primitive Data Types.
The following are methods for Blob.
-
Returns the number of bytes in the Blob.
-
Creates a binary object out of the given string, encoding it as a PDF file.
-
Casts the Blob into a String.
-
Casts the specified String to a Blob.
Returns the number of bytes in the Blob.
public Integer size()
Type: Integer
Creates a binary object out of the given string, encoding it as a PDF file.
public static Blob toPdf(String stringToConvert)
-
stringToConvert:
Type: String
Type: Blob
Blob.toPDF(stringToConvert) works with any string value. Since the Spring ’26 release, Blob.toPDF() uses the same PDF rendering service as Visualforce.
See Render a Visualforce Page as a PDF File for details of the improved PDF rendering service, including considerations and limitations for rendering PDF files.
The Visualforce PDF rendering service expands the range of fonts available, and includes a multibyte-capable font. The default font is serif, which is a change from the default sans-serif used by Blob.toPDF(). See Fonts Available When Using Visualforce PDF Rendering.
Casts the Blob into a String.
public String toString()
Type: String
Casts the specified String to a Blob.
public static Blob valueOf(String stringToBlob)
-
stringToBlob:
Type: String
Type: Blob