window.onload = function() {
//DsPdfViewer.LicenseKey = "***key***";
const viewer = new DsPdfViewer("#viewer", {
supportApi: getSupportApiSettings(),
saveSettings: { format: "SVG" },
saveAsOptions: { availableFormats: [ "PNG", "SVG" ] }
});
const viewerLayout = viewer.toolbarLayout.viewer;
viewerLayout.mobile = viewerLayout.default = ["open", "save-as", "$split", "zoom"];
viewer.toggleSidebar(false);
var pdfUrlToOpen = "/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/how-to-choose-js-framework.pdf";
viewer.open(pdfUrlToOpen).then(function() {
viewer.mouseMode = 1; // MouseMode.Move
});
document.querySelector(".export-to-svg-action").addEventListener("click", function() {
viewer.save("exportToSvgSample.zip", { format: "SVG" });
});
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Export PDF docuemts as SVG images.</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./src/styles.css">
<script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.js"></script>
<script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/wasmSupportApi.js"></script>
<script src="/document-solutions/javascript-pdf-viewer/demos/resource/js/init.js"></script>
<script src="./src/app.js"></script>
</head>
<body>
<div class="page-actions">
<button type="button" class="gc-btn gc-rounded export-to-svg-action" title="Export as SVG">
Export as SVG Programmatically
</button>
</div>
<div id="viewer"></div>
</body>
</html>
#viewer {
height: calc(100% - 50px);
}
.page-actions {
height: 50px;
background-color: #385dab;
border-bottom: 1px solid #385dab;
text-align: left;
}
.page-actions .export-to-svg-action {
padding: 0px 10px 0px 10px;
margin: 5px 0px 2px 5px;
cursor: pointer;
background-color: #ffffff;
}
.page-actions .export-to-svg-action:hover {
background-color: #ffffff !important;
}