{"id":2121,"date":"2016-02-04T05:33:34","date_gmt":"2016-02-04T05:33:34","guid":{"rendered":"http:\/\/www.ericwhite.com\/home2\/bm8qcmjy\/public_html\/blog\/?page_id=2121"},"modified":"2016-02-04T05:34:00","modified_gmt":"2016-02-04T05:34:00","slug":"openxmlpackage-savetobase64","status":"publish","type":"page","link":"https:\/\/www.ericwhite.com\/blog\/openxmlpackage-savetobase64\/","title":{"rendered":"OpenXmlPackage.saveToBase64()"},"content":{"rendered":"<p><span class=\"Back\"><a class=\"Back\" href=\"https:\/\/www.ericwhite.com\/blog\/open-xml-sdk-for-javascript\/\">Return to the<br \/>Open XML SDK for JavaScript<br \/>Developer Center<\/a><\/span>Creates a zipped package of all parts of the document, and then serializes the zip file to a base64 string.<\/p>\n<h1>Syntax<\/h1>\n<pre>\r\n    openXmlDoc.saveToBase64();\r\n<\/pre>\n<h1>Return Value<\/h1>\n<pre>\r\n    Returns a string that contains a base64 encoded zip file that you can, for example, save to a local drive.\r\n<\/pre>\n<h1>Usage<\/h1>\n<pre>\r\n    var doc = new openXml.OpenXmlPackage(flatOpc);\r\n    var b64string = doc.saveToBase64();\r\n<\/pre>\n<h1>Example<\/h1>\n<pre>\r\n\/\/ This example converts a Flat OPC document to a DOCX.\r\n\/\/ Open the document from Flat OPC XML.\r\nvar doc = new openXml.OpenXmlPackage(withComments_flatOpc);\r\n\/\/ Save the document to base64 encoded ascii.\r\nvar base64doc = doc.saveToBase64();\r\nreturn {\r\n    returnedDocument: base64doc,\r\n    defaultDocumentName: \"WithComments.docx\",\r\n    output: \"Click the 'Save' button to save the DOCX to a local drive.  If you do not see a 'Save' button, you do not have Flash available, and can't save the document.\"\r\n};\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Return to theOpen XML SDK for JavaScriptDeveloper CenterCreates a zipped package of all parts of the document, and then serializes the zip file to a base64 string. Syntax openXmlDoc.saveToBase64(); Return Value Returns a string that contains a base64 encoded zip file that you can, for example, save to a local drive. Usage var doc = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_s2mail":"","footnotes":""},"class_list":["post-2121","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/comments?post=2121"}],"version-history":[{"count":1,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2121\/revisions"}],"predecessor-version":[{"id":2122,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2121\/revisions\/2122"}],"wp:attachment":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/media?parent=2121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}