Merge XPS files | Aspose.Page for JavaScript
You can check the quality of Aspose.Page XPS merging and view the results via free online XPS Merger
Aspose.Page JavaScript via C++ XPS merger allows merging XPS files into XPS document on Windows and Linux.
It is necessary to do several steps to perform XPS merge:
- Create file reader ‘const file_reader = new FileReader();’ and read file ‘file_reader.readAsArrayBuffer(e.target.files[0]);’.
- Load the needed files by using AsposePagePrepare.
- After the loading of the last file, call AsposeXPSMergeToPdf and pass the array of source file names and the result file name.
- The result JSON contains the file name in fileNameResult.
- You can download files by using the DownloadFile function: ‘DownloadFile(JSON.fileNameResult, “image/pdf”);’
The following code snippet shows how to merge XPS files in JavaScript:
1 var fXps2Xps = function (e) {
2 const file_reader = new FileReader();
3 function readFile(index) {
4 if (index >= e.target.files.length) {
5 const fileNames = Array.from(e.target.files).map((x) => x.name).toString();
6 const JSON = XPSMergeToXps(fileNames, "ResultMerge.xps");
7 if (JSON.errorCode == 0) {
8 DownloadFile(JSON.fileNameResult, "image/xps");
9 }
10 else
11 document.getElementById('output').textContent = JSON.errorText;
12 return;
13 }
14 const file = e.target.files[index];
15 file_reader.onload = function (event) {
16 AsposePagePrepare(event.target.result, file.name);
17 readFile(index + 1)
18 }
19 file_reader.readAsArrayBuffer(file);
20 }
21 readFile(0);
22 }
Aspose.Page JavaScript via C++ XPS merger also allows merging XPS files into a PDF document on Windows and Linux.
It is necessary to do several steps in order to perform XPS to PDF merge:
- It’s as XPS to XPS, just call AsposeXPSMergeToPdf and pass the array of source file names and the result file name.
The following code snippet shows how to merge XPS files to PDF document in JavaScript:
1 var fXps2Pdf = function (e) {
2 startOutput;
3 const file_reader = new FileReader();
4 function readFile(index) {
5 if (index >= e.target.files.length) {
6 const fileNames = Array.from(e.target.files).map((x) => x.name).toString();
7 const JSON = XPSMergeToPdf(fileNames, "ResultMerge.pdf");
8 if (JSON.errorCode == 0) {
9 DownloadFile(JSON.fileNameResult, "image/pdf");
10 }
11 else
12 document.getElementById('output').textContent = JSON.errorText;
13 return;
14 }
15 const file = e.target.files[index];
16 file_reader.onload = function (event) {
17 AsposePagePrepare(event.target.result, file.name);
18 readFile(index + 1)
19 }
20 file_reader.readAsArrayBuffer(file);
21 }
22 readFile(0);
23 }
Evaluate XPS merging online on our XPS Merger.
You can download examples and data files from GitHub.