jszip

Conversion image links to base64 and adding them to zip file using JSZip

谁说我不能喝 提交于 2019-12-06 10:25:18
So basically I want to add few images to zip file and be able to download it. I have two variables holding sources of images - pic1, pic2 and a global variable basePic for holding base64 string. I have a function to convert image to base64 : var pic; //http://www.somesite.com/i/picture.jpg var pic2; //http://www.somesite.com/i/picture2.jpg var basePic;// base64 string of an image function getBase64FromImageUrl(url) { var img = new Image(); img.setAttribute('crossOrigin', 'anonymous'); img.onload = function () { var canvas = document.createElement("canvas"); canvas.width =this.width; canvas

Put generated PNG image into JSZip

强颜欢笑 提交于 2019-12-05 14:47:45
I am using JSZip to make a program that generates the image data from a canvas element and puts the image into a zip file. Right now, it is turning the canvas image into an DataURL. Then, I get rid of the part of the resulting string that says data:image/png;base64, . Now, there is nothing left but the base64 data. I then use atob to change it to ascii. It seems like putting the remaining string into an image file should work, but the generated ascii text is not correct. Many parts of it are correct, but something is not right. Here is my code: //screen is the name of the canvas. var imgData =

How to create a download button for multiple files using Liferay and JavaScript?

天大地大妈咪最大 提交于 2019-11-29 12:36:12
I am trying to make a button when clicking, it downloads the files in a zip file. I tried to load the files into the Zip from given url. I am using Liferay 6.1 . Is the script declaration in the JSP file correct? I have already specified jszip.js in liferay-portlet.xml. <footer-portlet-javascript>/js/jszip.js</footer-portlet-javascript> Do I have to use the Liferay AUI Taglib tag or a simple javaScript tag should do the work? <aui:script></aui:script> or <script type="text/javascript"></script> or liferay-portlet.xml Is my script to download multi-files correct? <c:if test="<%= multi_files

Import JSZip in Angular 2 project

六月ゝ 毕业季﹏ 提交于 2019-11-27 03:24:19
问题 I am having troubles while importing the JSZip library in my Angular 2 project. I followed the following steps in order to change the project configuration: 1 - Install JSZip using NPM npm install jszip --save 2 - Change systemjs.config.js as follows var map = { ... 'jszip': 'node_modules/jszip/dist/jszip.min.js' }; 3 - Import the dependency within the component that requires it import JSZip from 'jszip'; Then, I tried using the main JSZip constructor to attach some files, but I am getting a

Multiple download links to one zip file before download javascript

≡放荡痞女 提交于 2019-11-26 19:03:12
Is it possible, in javascript, to have multiple download urls sent into one zip file and that zip file can be downloaded. So pretty much, on my web page, there is one button, that when clicked downloads a zip file of all the files from the download urls compressed into the zip? I believe I'd need to use jszip or some tool like that. Is this at all possible and is there any advice on where to start? You can use JSZip.js , XMLHttpRequest() , Array.prototype.map() , Promise.all() to create .zip file when all requests for files have completed; use <a> element with download attribute set to