{"id":2131,"date":"2016-02-04T05:48:28","date_gmt":"2016-02-04T05:48:28","guid":{"rendered":"http:\/\/www.ericwhite.com\/home2\/bm8qcmjy\/public_html\/blog\/?page_id=2131"},"modified":"2016-02-04T05:48:59","modified_gmt":"2016-02-04T05:48:59","slug":"openxmlpart-deleterelationship","status":"publish","type":"page","link":"https:\/\/www.ericwhite.com\/blog\/openxmlpart-deleterelationship\/","title":{"rendered":"OpenXmlPart.deleteRelationship(relationshipId)"},"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>Removes the specified relationship from the part. Note that you must separately remove target parts.<\/p>\n<h1>Syntax<\/h1>\n<pre>\r\n    part.deleteRelationship(relationshipId)\r\n<\/pre>\n<h1>Arguments<\/h1>\n<pre>\r\n    relationshipId: An string that contains the relationship ID of the relationship to delete.\r\n<\/pre>\n<h1>Usage<\/h1>\n<pre>\r\n    var rel = doc.mainDocumentPart().getRelationshipsByRelationshipType(\r\n        openXml.relationshipTypes.wordprocessingComments);\r\n    if (rel.length > 0) {\r\n        doc.mainDocumentPart().deleteRelationship(rel[0].relationshipId);\r\n    }\r\n<\/pre>\n<h1>Example<\/h1>\n<pre>\r\n\/\/ Open a document that is stored as Flat Opc XML.\r\n\/\/ The document contains some comments.\r\nvar doc = new openXml.OpenXmlPackage(withComments_flatOpc);\r\n\/\/ Remove all references to comments.\r\nvar mainPart = doc.mainDocumentPart();\r\nvar mainPartXDoc = mainPart.getXDocument();\r\nnew XEnumerable(mainPartXDoc.descendants(W.commentRangeStart)).remove();\r\nnew XEnumerable(mainPartXDoc.descendants(W.commentRangeEnd)).remove();\r\nnew XEnumerable(mainPartXDoc.descendants(W.commentReference)).remove();\r\n\/\/ Remove the comments part.\r\nvar commentsPart = mainPart.wordprocessingCommentsPart();\r\nif (commentsPart !== null) {\r\n    doc.deletePart(commentsPart);\r\n}\r\n\/\/ Remove the relationship to the comments part.\r\nvar rel = doc.mainDocumentPart().getRelationshipsByRelationshipType(\r\n    openXml.relationshipTypes.wordprocessingComments);\r\nif (rel.length > 0) {\r\n    doc.mainDocumentPart().deleteRelationship(rel[0].relationshipId);\r\n}\r\nreturn {\r\n    returnedDocument: doc.saveToBase64(),\r\n    defaultDocumentName: \"DocumentWithoutComments.docx\",\r\n    output: [\"This example removed the comments from the document.\",\r\n        \"Click the 'Save' button to save the modified document 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 CenterRemoves the specified relationship from the part. Note that you must separately remove target parts. Syntax part.deleteRelationship(relationshipId) Arguments relationshipId: An string that contains the relationship ID of the relationship to delete. Usage var rel = doc.mainDocumentPart().getRelationshipsByRelationshipType( openXml.relationshipTypes.wordprocessingComments); if (rel.length > 0) { doc.mainDocumentPart().deleteRelationship(rel[0].relationshipId); } Example \/\/ Open a [&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-2131","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2131","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=2131"}],"version-history":[{"count":2,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2131\/revisions"}],"predecessor-version":[{"id":2133,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2131\/revisions\/2133"}],"wp:attachment":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/media?parent=2131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}