Skip to content

SaveToBase64

Saves the document as Base64.

1
myWriter.SaveToBase64(type: ( ( "pdf" | "docx" | "html" | "rtf" | "xml" | "txt" | ".pdf" | ".docx" | ".html" | ".rtf" | ".xml" | ".txt" ) | SaveOptions )):string

Parameters

( ( "pdf" | "docx" | "html" | "rtf" | "xml" | "txt" | ".pdf" | ".docx" | ".html" | ".rtf" | ".xml" | ".txt" ) | SaveOptions ) type
    The file type, such as '.pdf', or save options with the file type.

Returns

The document content as a Base64 string.

Remarks

Supported formats are PDF, HTML, DOCX, TXT, RTF, and XML, with or without a leading dot. An unsupported type throws. Passing an options object applies its writable options to the selected GemBox save format.

Examples

Save a document as a PDF file

1
2
3
4
5
var writer = new Writer();
writer.LoadText('<h1>Order ' + $Xml.Evaluate('Id') + '</h1>', 'html');

var file = $Files.AddBase64(writer.SaveToBase64('.pdf'), 'Order.pdf', 'application/pdf');
$Xml.SetValue('OrderDocument', file.Id);