Huge refactoring to use new compiler and deprecate all other Packers
Add new PdfPacker
This commit is contained in:
519
My Document.pdf
Normal file
519
My Document.pdf
Normal file
@ -0,0 +1,519 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head><title>
|
||||
Convert DOC to PDF Online | Convert DOCX to PDF Online | Convert Word to PDF Online | Free online converter
|
||||
</title><link rel="shortcut icon" href="convertonlinefree.ico" /><meta name="TITLE" content="Free online Word to PDF converter" /><meta charset="UTF-8" /><meta name="VW96.OBJECT TYPE" content="Document" /><meta name="RATING" content="General" /><meta name="ROBOTS" content="index,follow" /><meta name="REVISIT-AFTER" content="2 weeks" /><meta name="description" content="Free online Word to PDF converter converts Microsoft Word to Adobe Acrobat PDF" /><meta name="keywords" content="100%,free,online,file,convert,converter,conversion,word,pdf,doc,docx,document,zip,.pdf,.doc,.docx,.zip" /><meta name="viewport" content="width=device-width, initial-scale=1" /><link href="Styles/Site.css" rel="stylesheet" type="text/css" />
|
||||
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="#" onsubmit="javascript:return WebForm_OnSubmit();" id="ctl01" enctype="multipart/form-data">
|
||||
<div class="aspNetHidden">
|
||||
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
|
||||
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
|
||||
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEzNDgzNTIwMDFkZOpKwflZ3FVZ1KECjyY5WIndMnOYHoI55wJPd+cbmQyy" />
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var theForm = document.forms['ctl01'];
|
||||
if (!theForm) {
|
||||
theForm = document.ctl01;
|
||||
}
|
||||
function __doPostBack(eventTarget, eventArgument) {
|
||||
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
|
||||
theForm.__EVENTTARGET.value = eventTarget;
|
||||
theForm.__EVENTARGUMENT.value = eventArgument;
|
||||
theForm.submit();
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
|
||||
<script src="/WebResource.axd?d=8e-d2wJT2J_Z5k1byoWKKaBzEFDk6xBdDIdzXfJP8ofCiXaK3WIjWGNToC4IPcKvt8k6Gv1c1pT_oYwvXC5dwo9XSVwOEc0mcESva-VdUQY1&t=636354979360000000" type="text/javascript"></script>
|
||||
|
||||
|
||||
<script src="/WebResource.axd?d=GSgE3uBWUzJOifh6ekseBmbH2m7CGoz6p_j0QAM0IRfcFbXNhAcaJsodLi4BCcbGFL2xL7RUVKGA1tH_r_g7Qav9EK3M2n3l0ITj3nEgVwPQnhnojMf2-Q-o2V8Z8PY00&t=636354979360000000" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function WebForm_OnSubmit() {
|
||||
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
|
||||
return true;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<div class="aspNetHidden">
|
||||
|
||||
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="21B7279E" />
|
||||
</div>
|
||||
<div class="pageheader">
|
||||
<table class="headermenu">
|
||||
<tr class="valignBottom">
|
||||
<td>
|
||||
<div class="activepagecell">
|
||||
<h5>
|
||||
Word to PDF</h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aDocumentsToPDFMenu" title="Convert file(s) in other formats to PDF" href="DocumentToPDFEN.aspx">
|
||||
Other documents to PDF</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aImagesToPDFMenu" title="Convert image to PDF" href="ImageToPDFEN.aspx">Image
|
||||
to PDF</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aPDFToTXTMenu" title="Convert PDF to TXT" href="PDFToTXTEN.aspx">PDF to TXT</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aOCRMenu" title="Recognize text in PDF and images" href="OCREN.aspx">OCR</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aPDFToWORDMenu" title="Convert PDF to WORD" href="PDFToWORDEN.aspx">PDF to WORD</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aPDFToJPGMenu" title="Convert PDF to JPG" href="PDFToJPGEN.aspx">PDF to JPG</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aDJVUToPDFMenu" title="Convert DJVU to PDF" href="DJVUToPDFEN.aspx">DJVU to PDF</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aProcessPDFMenu" title="Process PDF (Merge several PDF files into one PDF file, Split PDF file into several PDF files)"
|
||||
href="ProcessPDFEN.aspx">Process PDF</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aDocumentsToFB2Menu" title="Convert to DB2" href="DocumentToFB2EN.aspx">To FB2</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aOtherFormatsMenu" title="Convert document to other formats" href="OtherFormatEN.aspx">
|
||||
Other formats</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aConvertImageMenu" title="Convert image to another format" href="ConvertImageEN.aspx">
|
||||
Image</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aConvertZIPMenu" title="Convert file to ZIP" href="ConvertZIPEN.aspx">ZIP</a></h5>
|
||||
</div>
|
||||
<div class="pagecell">
|
||||
<h5>
|
||||
<a id="aHelpMenu" title="Frequently asked questions" href="HelpEN.aspx">FAQ</a></h5>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="langMenu">
|
||||
<a href="/">
|
||||
<img alt="EN" title="English" src="Images/en.png" /></a> <a href="WordToPDFRU.aspx"><img
|
||||
alt="RU" title="Русский" src="Images/ru.png" /></a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="page">
|
||||
<div class="main">
|
||||
|
||||
<table class="baseTable width100">
|
||||
<tr>
|
||||
<td class="leftColumn">
|
||||
<div id="adLeft" class="adsgoogle">
|
||||
<div class="advertisement">
|
||||
Advertisements</div>
|
||||
<ins class="adsbygoogle adsVertical" data-ad-client="ca-pub-2140724451412153" data-ad-slot="9910226602">
|
||||
</ins>
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
</script>
|
||||
</div>
|
||||
</td>
|
||||
<td class="valignTop">
|
||||
<div class="left">
|
||||
<table class="headerarea">
|
||||
<tr>
|
||||
<td class="width80px">
|
||||
</td>
|
||||
<td>
|
||||
<h1>
|
||||
WELCOME TO 100% FREE WORD TO PDF ONLINE CONVERTER</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="width80px">
|
||||
</td>
|
||||
<td>
|
||||
<h2>
|
||||
You can convert DOC to PDF and DOCX to PDF for free</h2>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div>
|
||||
<table class="baseTable advantagesTable">
|
||||
<tr class="vtop">
|
||||
<td class="advantagesLeftColumn">
|
||||
<div class="advantages">
|
||||
<div class="advantagesHeader">
|
||||
<b>Advantages of our free service</b>
|
||||
</div>
|
||||
<div class="left">
|
||||
<ol>
|
||||
<li>Absolutely 100% free service</li>
|
||||
<li>No need to have MS Word on your PC (your file is converted on our servers)</li>
|
||||
<li>Produced PDF 100% matches your MS Word document</li>
|
||||
<li>High quality PDF</li>
|
||||
<li>Pictures are not lost</li>
|
||||
<li>MS Word documents in all languages are supported</li>
|
||||
<li>No personal information is required (file is returned to your Internet browser)</li>
|
||||
<li>Conversion of ZIP archives</li>
|
||||
<li>Immediate conversion</li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="advantagesRightColumn">
|
||||
<div class="adsCenterTop">
|
||||
<ins class="adsbygoogle adsSquare200x200" data-ad-client="ca-pub-2697679518515886"
|
||||
data-ad-slot="3736642311"></ins>
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
</script>
|
||||
<div class="advertisement right">
|
||||
Advertisements</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="mainarea">
|
||||
<div class="modearea">
|
||||
<a id="option1Button" title="Convert one file online. To convert ZIP archive, please, use Convert zipped files tab."
|
||||
href="#" class="activeroundedbutton" onclick="selectOption('1');">Convert file</a>
|
||||
<a id="option2Button" title="Convert batch of files (MS Word files in ZIP) online"
|
||||
href="#" class="roundedbutton" onclick="selectOption('2');">Convert zipped files</a>
|
||||
</div>
|
||||
<div class="processarea">
|
||||
<div class="option1">
|
||||
<div>
|
||||
<h4>
|
||||
Convert one file online: <a rel="nofollow" href="#" onclick="$('#option1Help').is(':visible') ? $('#option1Help').hide() : $('#option1Help').show(); return false;">
|
||||
<img alt="How it works" title="How it works" src="Images/help.png" /></a></h4>
|
||||
</div>
|
||||
<div id="option1Help" class="helparea" style="display: none;">
|
||||
Note: You don't have to have MS Word installed on your PC.<br />
|
||||
1. Select an MS Word document to be converted.<br />
|
||||
2. Click the <i>Convert</i> button.<br />
|
||||
3. The file is sent to our server and the conversion starts immediately.<br />
|
||||
4. The conversion takes time which depends on the file size, your Internet connection
|
||||
speed and available resources on our servers.<br />
|
||||
5. When the file is converted it's returned to the same browser window (don't close
|
||||
your browser).<br />
|
||||
6. If the file cannot be converted the reason of the fail is shown in red.<br />
|
||||
7. Enjoy
|
||||
</div>
|
||||
</div>
|
||||
<div class="option2" style="display: none;">
|
||||
<div>
|
||||
<h4>
|
||||
Convert batch of files (MS Word files in ZIP) online: <a rel="nofollow" href="#"
|
||||
onclick="$('#option2Help').is(':visible') ? $('#option2Help').hide() : $('#option2Help').show(); return false;">
|
||||
<img alt="How it works" title="How it works" src="Images/help.png" /></a></h4>
|
||||
</div>
|
||||
<div id="option2Help" class="helparea" style="display: none;">
|
||||
Note: You don't have to have MS Word installed on your PC.<br />
|
||||
1. Select a ZIP file containing MS Word documents to be converted. Only 20 files
|
||||
can be converted at once.<br />
|
||||
2. Click the <i>Convert</i> button.<br />
|
||||
3. The file is sent to our server and the conversion starts immediately.<br />
|
||||
4. The conversion takes time which depends on the file size, your Internet connection
|
||||
speed and available resources on our servers.<br />
|
||||
5. When the file is converted it's returned to the same browser window (don't close
|
||||
your browser).<br />
|
||||
6. If the file cannot be converted the reason of the fail is shown in red.<br />
|
||||
7. Enjoy
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<br />
|
||||
<div class="adsgooglebannercontainer">
|
||||
<div id="adBanner" class="adsgooglebanner">
|
||||
<div class="advertisement">
|
||||
Advertisements</div>
|
||||
<ins class="adsbygoogle adsHorizontal" data-ad-client="ca-pub-2697679518515886" data-ad-slot="4258435911/5315885631">
|
||||
</ins>
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
<div class="option1">
|
||||
<div>
|
||||
<span id="rfv" style="color:Green;display:none;">Please, select a file to be converted</span>
|
||||
<span id="cfv" style="color:Green;display:none;">Only DOC/DOCX files are supported</span></div>
|
||||
<input type="file" name="ctl00$MainContent$fu" id="MainContent_fu" class="button border1" size="50" style="border-color:Purple;border-style:Outset;" />
|
||||
<input type="submit" name="ctl00$MainContent$btnConvert" value="Convert" onclick="if ($(this).prev('[type=\'file\']').val() !== '' && SupportedFormatsFileValid && !inprogress) { ShowProgress('progress'); } else return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$btnConvert", "", true, "File", "", false, false))" id="MainContent_btnConvert" title="Convert document and return output PDF to your browser" class="button border1" style="border-color:Purple;border-style:Outset;" /> <input type="submit" name="ctl00$MainContent$btnPreview" value="Preview" onclick="if ($(this).prev('[type=\'file\']').val() !== '' && SupportedFormatsFileValid && !inprogress) { ShowProgress('progress'); } else return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$btnPreview", "", true, "File", "", false, false))" id="MainContent_btnPreview" title="Convert document and preview output PDF in your browser with possibility of saving" class="button border1" style="border-color:Purple;border-style:Outset;" />
|
||||
<div id="progress" style="display: none;" class="center">
|
||||
<br />
|
||||
<br />
|
||||
<img alt="Your file is being processed" title="Your file is being processed" src="Images/uploadprogress.gif" /><br />
|
||||
<br />
|
||||
<div id="status">
|
||||
Converting</div>
|
||||
<br />
|
||||
It may take several minutes<br />
|
||||
<br />
|
||||
</div>
|
||||
<div>
|
||||
<span id="MainContent_lblError" class="red">Document is not an MS Word document inside it just has .DOC/.DOCX extension or damaged</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<br />
|
||||
<div>
|
||||
On this page you can only convert <strong>DOC</strong> <strong>DOCX</strong> to
|
||||
<strong>PDF</strong>.</div>
|
||||
<ul>
|
||||
<li>To convert several files, please, use tab <a id="option2ButtonLink" title="Convert batch of files (MS Word files in ZIP) online"
|
||||
href="#" onclick="selectOption('2');">Convert zipped files</a>.</li><li>To convert RTF
|
||||
ODT MHT HTM HTML TXT FB2 DOT DOTX XLS XLSX XLSB ODS XLT XLTX PPT PPTX PPS PPSX ODP
|
||||
POT POTX to PDF, please, use the following link <a id="aDocumentsToPDF" title="Convert file(s) in other formats to PDF"
|
||||
href="DocumentToPDF.aspx">Other documents to PDF</a>.</li><li>To convert JPG JPEG PNG
|
||||
BMP GIF TIF TIFF to PDF, please, use the following link <a id="aImagesToPDF" title="Convert image to PDF"
|
||||
href="ImageToPDF.aspx">Image to PDF</a>. </li>
|
||||
<li>To extract text from PDF, please, use the following link <a id="aPDFToTXT" title="Convert PDF to text"
|
||||
href="PDFToTXT.aspx">PDF to TXT</a>.</li><li>To convert DOC DOCX RTF ODT MHT HTM HTML
|
||||
TXT FB2 DOT DOTX to DOC DOCX DOT ODT RTF TXT or XLS XLSX XLSB XLT XLTX ODS to XLS
|
||||
XLSX or PPT PPTX PPS PPSX ODP POT POTX to PPT PPTX PPS PPSX JPG TIF PNG GIF BMP,
|
||||
please, use the following link <a id="aOtherFormat" title="Convert to other formats"
|
||||
href="OtherFormat.aspx">Other formats</a>.</li><li>To convert DOC DOCX DOT DOTX RTF
|
||||
ODT MHT HTM HTML TXT to FB2, please, use the following link <a id="aDocumentsToFB2"
|
||||
title="Convert to FB2" href="DocumentToFB2EN.aspx">Documents to FB2</a>.</li><li>To
|
||||
convert JPG JPEG JFIF PNG BMP GIF TIF ICO to other image formats, please, use the
|
||||
following link <a id="aConvertImage" title="Convert image" href="ConvertImageEN.aspx">
|
||||
Convert Image</a>. </li>
|
||||
<li>To convert PDF to MS Word (DOC, DOCX), please, use the following link <a id="aPDFToWord"
|
||||
title="Convert PDF to Word" href="PDFToWordEN.aspx">Convert PDF to Word</a>.
|
||||
</li>
|
||||
<li>To convert PDF to JPG, please, use the following link <a id="aPDFToJPG" title="Convert PDF to JPG"
|
||||
href="PDFToJPGEN.aspx">Convert PDF to JPG</a>. </li>
|
||||
<li>To convert DJVU to PDF, please, use the following link <a id="aDJVUToPDF" title="Convert DJVU to PDF"
|
||||
href="DJVUToPDFEN.aspx">Convert DJVU to PDF</a>. </li>
|
||||
<li>To recognize text in a PDF or in an image, please, use the following link <a
|
||||
id="aOCR" title="Recognize text in a PDF and in an image" href="OCREN.aspx">Recognize
|
||||
text in PDF or in image</a>. </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option2" style="display: none;">
|
||||
<div>
|
||||
<span id="rfvZip" style="color:Green;display:none;">Please, select a ZIP archive to be converted</span><span id="cfvZip" style="color:Green;display:none;">Only ZIP files are supported</span></div>
|
||||
<input type="file" name="ctl00$MainContent$fuZip" id="MainContent_fuZip" class="button border1" size="60" style="border-color:Purple;border-style:Outset;" />
|
||||
<input type="submit" name="ctl00$MainContent$btnConvertZip" value="Convert" onclick="if ($(this).prev('[type=\'file\']').val() !== '' && SupportedFormatsZipValid) { ShowProgress('progressZip'); };WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$btnConvertZip", "", true, "Zip", "", false, false))" id="MainContent_btnConvertZip" title="Convert ZIP archive with documents and return output archive with PDF files to your browser" class="button border1" style="border-color:Purple;border-style:Outset;" />
|
||||
<div id="progressZip" style="display: none;" class="center">
|
||||
<br />
|
||||
<br />
|
||||
<img alt="Your file is being processed" title="Your file is being processed" src="Images/uploadprogress.gif" /><br />
|
||||
<br />
|
||||
<div id="statusZip">
|
||||
Converting</div>
|
||||
<br />
|
||||
It may take several minutes<br />
|
||||
<br />
|
||||
</div>
|
||||
<div>
|
||||
<span id="MainContent_lblErrorZip" class="red"></span></div>
|
||||
<div class="info">
|
||||
<ul>
|
||||
<li>Batch conversion of several files packed in <strong>ZIP</strong> archive</li>
|
||||
<li>Only <strong>ZIP</strong> archives are supported</li>
|
||||
<li>Internal archives are not supported</li>
|
||||
<li>Only <strong>MS Word</strong> (<strong>DOC</strong> <strong>DOCX</strong>) internal
|
||||
files are converted from <strong>ZIP</strong> archive</li>
|
||||
<li>Only 20 <strong>MS Word</strong> (<strong>DOC</strong> <strong>DOCX</strong>) files
|
||||
from <strong>ZIP</strong> archive will be converted</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="adsgooglebannercontainer">
|
||||
<div id="adBanner1" class="adsgooglebanner">
|
||||
<div class="advertisement">
|
||||
Advertisements</div>
|
||||
<ins class="adsbygoogle adsHorizontal" data-ad-client="ca-pub-2697679518515886" data-ad-slot="4258435911/7211851671">
|
||||
</ins>
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
</div>
|
||||
<div class="adsgooglemobile">
|
||||
<ins class="adsbygoogle adsMobileSquare" data-ad-client="ca-pub-2697679518515886"
|
||||
data-ad-slot="4258435911/2222717151"></ins>
|
||||
<script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
|
||||
</div>
|
||||
<br />
|
||||
<div class="social">
|
||||
<div class="addthis_sharing_toolbox">
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<a id="aContact" href="mailto:info@convertonlinefree.com">Contacts</a></div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="termsofservicearea">
|
||||
<div class="center">
|
||||
<a href="#" onclick="$('#termsofservice').is(':visible') ? $('#termsofservice').hide() : $('#termsofservice').show(); return false;">
|
||||
<b>TERMS OF SERVICE</b></a><div>
|
||||
<br />
|
||||
<div id="termsofservice" style="display: none;" class="left">
|
||||
1. YOU UNDERSTAND AND AGREE THAT YOUR USE OF THE SERVICES IS AT YOUR OWN RISK AND
|
||||
THAT THE SERVICES ARE PROVIDED "AS IS" AND "AS AVAILABLE".<br />
|
||||
2. FREE USAGE OF THE SERVICES DOES NOT REPRESENT OR WARRANT TO YOU THAT:<br />
|
||||
(A) YOUR USE OF THE SERVICES WILL MEET YOUR REQUIREMENTS,<br />
|
||||
(B) YOUR USE OF THE SERVICES WILL BE UNINTERRUPTED, TIMELY,
|
||||
SECURE OR FREE FROM ERROR,<br />
|
||||
(C) ANY INFORMATION OBTAINED BY YOU AS A RESULT OF YOUR
|
||||
USE OF THE SERVICES WILL BE ACCURATE OR RELIABLE, AND<br />
|
||||
(D) THAT DEFECTS IN THE OPERATION OR FUNCTIONALITY OF ANY
|
||||
SOFTWARE PROVIDED TO YOU AS PART OF THE SERVICES WILL BE CORRECTED.<br />
|
||||
3. ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE SERVICES
|
||||
IS DONE AT YOUR OWN DISCRETION AND RISK AND THAT YOU WILL BE SOLELY RESPONSIBLE
|
||||
FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS
|
||||
FROM THE DOWNLOAD OF ANY SUCH MATERIAL.<br />
|
||||
4. WE DO NOT STORE YOUR FILES ON OUR SERVERS.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="rightColumn">
|
||||
<div id="adRight" class="adsgoogle">
|
||||
<div class="advertisement">
|
||||
Advertisements</div>
|
||||
<ins class="adsbygoogle adsVertical" data-ad-client="ca-pub-2697679518515886" data-ad-slot="4258435911/9746009271">
|
||||
</ins>
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({});
|
||||
</script>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var Page_Validators = new Array(document.getElementById("rfv"), document.getElementById("cfv"), document.getElementById("rfvZip"), document.getElementById("cfvZip"));
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var rfv = document.all ? document.all["rfv"] : document.getElementById("rfv");
|
||||
rfv.controltovalidate = "MainContent_fu";
|
||||
rfv.errormessage = "Please, select a file to be converted";
|
||||
rfv.display = "Dynamic";
|
||||
rfv.validationGroup = "File";
|
||||
rfv.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
|
||||
rfv.initialvalue = "";
|
||||
var cfv = document.all ? document.all["cfv"] : document.getElementById("cfv");
|
||||
cfv.controltovalidate = "MainContent_fu";
|
||||
cfv.errormessage = "Only DOC/DOCX files are supported";
|
||||
cfv.display = "Dynamic";
|
||||
cfv.validationGroup = "File";
|
||||
cfv.evaluationfunction = "CustomValidatorEvaluateIsValid";
|
||||
cfv.clientvalidationfunction = "CheckSupportedFormatsFile";
|
||||
var rfvZip = document.all ? document.all["rfvZip"] : document.getElementById("rfvZip");
|
||||
rfvZip.controltovalidate = "MainContent_fuZip";
|
||||
rfvZip.errormessage = "Please, select a ZIP archive to be converted";
|
||||
rfvZip.display = "Dynamic";
|
||||
rfvZip.validationGroup = "Zip";
|
||||
rfvZip.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
|
||||
rfvZip.initialvalue = "";
|
||||
var cfvZip = document.all ? document.all["cfvZip"] : document.getElementById("cfvZip");
|
||||
cfvZip.controltovalidate = "MainContent_fuZip";
|
||||
cfvZip.errormessage = "Only ZIP files are supported";
|
||||
cfvZip.display = "Dynamic";
|
||||
cfvZip.validationGroup = "Zip";
|
||||
cfvZip.evaluationfunction = "CustomValidatorEvaluateIsValid";
|
||||
cfvZip.clientvalidationfunction = "CheckSupportedFormatsZip";
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
||||
var Page_ValidationActive = false;
|
||||
if (typeof(ValidatorOnLoad) == "function") {
|
||||
ValidatorOnLoad();
|
||||
}
|
||||
|
||||
function ValidatorOnSubmit() {
|
||||
if (Page_ValidationActive) {
|
||||
return ValidatorCommonOnSubmit();
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
</form>
|
||||
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
|
||||
<script src="Scripts/AcceptCookie.js" type="text/javascript"></script>
|
||||
<script src="Scripts/ConvertProgressControl.js" type="text/javascript"></script>
|
||||
<script src="Scripts/Tabs.js" type="text/javascript"></script>
|
||||
<script src="Scripts/WordToPDF.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var host = 'mirror1.convertonlinefree.com';
|
||||
if ("localhost" != host) {
|
||||
(function (i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date(); a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-21971671-2', 'auto');
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
</script>
|
||||
<!-- Yandex.Metrika counter -->
|
||||
<script type="text/javascript"> (function (d, w, c) { (w[c] = w[c] || []).push(function () { try { w.yaCounter5643403 = new Ya.Metrika({ id: 5643403, enableAll: true, ut: "noindex", webvisor: false }); } catch (e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script>
|
||||
<noscript>
|
||||
<div>
|
||||
<img src="//mc.yandex.ru/watch/5643403?ut=noindex" style="position: absolute; left: -9999px;"
|
||||
alt="" />
|
||||
</div>
|
||||
</noscript>
|
||||
<!-- /Yandex.Metrika counter -->
|
||||
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5677a924f66963bc"
|
||||
async="async"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,4 +1,5 @@
|
||||
const docx = require('../build');
|
||||
const fs = require('fs');
|
||||
|
||||
var doc = new docx.Document();
|
||||
|
||||
@ -10,7 +11,10 @@ paragraph.addRun(dateText);
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
var exporter = new docx.LocalPacker(doc);
|
||||
exporter.pack('My Document');
|
||||
var packer = new docx.Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync('My Document.docx', buffer);
|
||||
});
|
||||
|
||||
console.log('Document created successfully at project root!');
|
||||
|
21
demo/demo26.js
Normal file
21
demo/demo26.js
Normal file
@ -0,0 +1,21 @@
|
||||
const docx = require('../build');
|
||||
const fs = require('fs');
|
||||
|
||||
var doc = new docx.Document();
|
||||
|
||||
var paragraph = new docx.Paragraph("Hello World");
|
||||
var institutionText = new docx.TextRun("University College London").bold();
|
||||
var dateText = new docx.TextRun("5th Dec 2015").tab().bold();
|
||||
paragraph.addRun(institutionText);
|
||||
paragraph.addRun(dateText);
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
var packer = new docx.PdfPacker();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
console.log(buffer);
|
||||
fs.writeFileSync('My Document.pdf', buffer);
|
||||
});
|
||||
|
||||
console.log('Document created successfully at project root!');
|
@ -1,5 +1,2 @@
|
||||
export * from "./packer/local";
|
||||
export * from "./packer/express";
|
||||
export * from "./packer/packer";
|
||||
export * from "./packer/stream";
|
||||
export * from "./packer/buffer";
|
||||
export * from "./packer/pdf-packer";
|
||||
|
@ -1,17 +0,0 @@
|
||||
import { Compiler } from "./next-compiler";
|
||||
import { IPacker } from "./packer";
|
||||
|
||||
declare var saveAs;
|
||||
|
||||
export class BrowserPacker implements IPacker {
|
||||
private readonly packer: Compiler;
|
||||
|
||||
public async pack(filePath: string): Promise<void> {
|
||||
filePath = filePath.replace(/.docx$/, "");
|
||||
|
||||
const zip = await this.packer.compile();
|
||||
const zipBlob = await zip.generateAsync({ type: "blob" });
|
||||
|
||||
saveAs(zipBlob, `${filePath}.docx`);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import { Writable } from "stream";
|
||||
|
||||
export class BufferStream extends Writable {
|
||||
private readonly data: Buffer[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.data = [];
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-any
|
||||
public _write(chunk: any, _: string, next: (err?: Error) => void): void {
|
||||
this.data.push(Buffer.from(chunk));
|
||||
next();
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:ban-types
|
||||
public end(cb?: Function): void {
|
||||
super.end(cb);
|
||||
|
||||
this.emit("close");
|
||||
}
|
||||
|
||||
public get Buffer(): Buffer {
|
||||
return Buffer.concat(this.data);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
import { File } from "../../file";
|
||||
import { BufferStream } from "./buffer-stream";
|
||||
import { Compiler } from "./compiler";
|
||||
import { IPacker } from "./packer";
|
||||
|
||||
export class BufferPacker implements IPacker {
|
||||
private readonly packer: Compiler;
|
||||
|
||||
constructor(file: File) {
|
||||
this.packer = new Compiler(file);
|
||||
}
|
||||
|
||||
public async pack(): Promise<Buffer> {
|
||||
const stream = new BufferStream();
|
||||
|
||||
await this.packer.compile(stream);
|
||||
|
||||
return stream.Buffer;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
// tslint:disable:typedef space-before-function-paren
|
||||
// tslint:disable:no-empty
|
||||
// tslint:disable:no-any
|
||||
import { assert } from "chai";
|
||||
import { stub } from "sinon";
|
||||
|
||||
import { ExpressPacker } from "../../export/packer/express";
|
||||
import { File, Paragraph } from "../../file";
|
||||
|
||||
describe("LocalPacker", () => {
|
||||
let packer: ExpressPacker;
|
||||
|
||||
beforeEach(() => {
|
||||
const file = new File({
|
||||
creator: "Dolan Miu",
|
||||
revision: "1",
|
||||
lastModifiedBy: "Dolan Miu",
|
||||
});
|
||||
const paragraph = new Paragraph("test text");
|
||||
const heading = new Paragraph("Hello world").heading1();
|
||||
file.addParagraph(new Paragraph("title").title());
|
||||
file.addParagraph(heading);
|
||||
file.addParagraph(new Paragraph("heading 2").heading2());
|
||||
file.addParagraph(paragraph);
|
||||
|
||||
const expressResMock = {
|
||||
on: () => {},
|
||||
attachment: () => {},
|
||||
};
|
||||
|
||||
packer = new ExpressPacker(file, expressResMock as any);
|
||||
});
|
||||
|
||||
describe("#pack()", () => {
|
||||
it("should handle exception if it throws any", () => {
|
||||
const compiler = stub((packer as any).packer, "compile");
|
||||
compiler.throwsException();
|
||||
return packer.pack("build/tests/test").catch((error) => {
|
||||
assert.isDefined(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,32 +0,0 @@
|
||||
import * as express from "express";
|
||||
|
||||
import { File } from "file";
|
||||
import { Compiler } from "./compiler";
|
||||
import { IPacker } from "./packer";
|
||||
|
||||
/**
|
||||
* @deprecated ExpressPacker is now deprecated. Please use the StreamPacker instead and pipe that to `express`' `res` object
|
||||
*/
|
||||
export class ExpressPacker implements IPacker {
|
||||
private readonly packer: Compiler;
|
||||
|
||||
constructor(file: File, private readonly res: express.Response) {
|
||||
this.packer = new Compiler(file);
|
||||
|
||||
this.res = res;
|
||||
|
||||
this.res.on("close", () => {
|
||||
return res
|
||||
.status(200)
|
||||
.send("OK")
|
||||
.end();
|
||||
});
|
||||
}
|
||||
|
||||
public async pack(name: string): Promise<void> {
|
||||
name = name.replace(/.docx$/, "");
|
||||
|
||||
this.res.attachment(`${name}.docx`);
|
||||
await this.packer.compile(this.res);
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/* tslint:disable:typedef space-before-function-paren */
|
||||
import { assert } from "chai";
|
||||
import * as fs from "fs";
|
||||
import { stub } from "sinon";
|
||||
|
||||
import { LocalPacker } from "../../export/packer/local";
|
||||
import { File, Paragraph } from "../../file";
|
||||
|
||||
describe("LocalPacker", () => {
|
||||
let packer: LocalPacker;
|
||||
|
||||
beforeEach(() => {
|
||||
const file = new File({
|
||||
creator: "Dolan Miu",
|
||||
revision: "1",
|
||||
lastModifiedBy: "Dolan Miu",
|
||||
});
|
||||
const paragraph = new Paragraph("test text");
|
||||
const heading = new Paragraph("Hello world").heading1();
|
||||
file.addParagraph(new Paragraph("title").title());
|
||||
file.addParagraph(heading);
|
||||
file.addParagraph(new Paragraph("heading 2").heading2());
|
||||
file.addParagraph(paragraph);
|
||||
|
||||
packer = new LocalPacker(file);
|
||||
});
|
||||
|
||||
describe("#pack()", () => {
|
||||
it("should create a standard docx file", async function() {
|
||||
this.timeout(99999999);
|
||||
await packer.pack("build/tests/test");
|
||||
fs.statSync("build/tests/test.docx");
|
||||
});
|
||||
|
||||
it("should handle exception if it throws any", () => {
|
||||
// tslint:disable-next-line:no-any
|
||||
const compiler = stub((packer as any).packer, "compile");
|
||||
compiler.throwsException();
|
||||
return packer.pack("build/tests/test").catch((error) => {
|
||||
assert.isDefined(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#packPdf", () => {
|
||||
it("should create a standard PDF file", async function() {
|
||||
this.timeout(99999999);
|
||||
|
||||
// tslint:disable-next-line:no-any
|
||||
const pdfConverterConvert = stub((packer as any).pdfConverter, "convert");
|
||||
pdfConverterConvert.returns("Test PDF Contents");
|
||||
|
||||
await packer.packPdf("build/tests/pdf-test");
|
||||
fs.statSync("build/tests/pdf-test.pdf");
|
||||
});
|
||||
|
||||
it("should handle exception if it throws any", () => {
|
||||
// tslint:disable-next-line:no-any
|
||||
const compiler = stub((packer as any).packer, "compile");
|
||||
compiler.throwsException();
|
||||
return packer.packPdf("build/tests/pdf-test").catch((error) => {
|
||||
assert.isDefined(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,57 +0,0 @@
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
|
||||
import { File } from "../../file";
|
||||
import { Compiler } from "./next-compiler";
|
||||
import { IPacker } from "./packer";
|
||||
import { PdfConvertWrapper } from "./pdf-convert-wrapper";
|
||||
|
||||
export class LocalPacker implements IPacker {
|
||||
private readonly pdfConverter: PdfConvertWrapper;
|
||||
private readonly packer: Compiler;
|
||||
|
||||
constructor(file: File) {
|
||||
this.pdfConverter = new PdfConvertWrapper();
|
||||
this.packer = new Compiler(file);
|
||||
}
|
||||
|
||||
public async pack(filePath: string): Promise<void> {
|
||||
filePath = filePath.replace(/.docx$/, "");
|
||||
|
||||
const zip = await this.packer.compile();
|
||||
const zipData = (await zip.generateAsync({ type: "base64" })) as string;
|
||||
|
||||
await this.writeToFile(`${filePath}.docx`, zipData);
|
||||
}
|
||||
|
||||
public async packPdf(filePath: string): Promise<void> {
|
||||
filePath = filePath.replace(/.pdf$/, "");
|
||||
|
||||
const fileName = path.basename(filePath, path.extname(filePath));
|
||||
const tempPath = path.join(os.tmpdir(), `${fileName}.docx`);
|
||||
|
||||
const zip = await this.packer.compile();
|
||||
const zipData = (await zip.generateAsync({ type: "base64" })) as string;
|
||||
await this.writeToFile(tempPath, zipData);
|
||||
|
||||
const text = await this.pdfConverter.convert(tempPath);
|
||||
// const writeFile = util.promisify(fs.writeFile); --use this in future, in 3 years time. Only in node 8
|
||||
// return writeFile(`${filePath}.pdf`, text);
|
||||
|
||||
await this.writeToFile(`${filePath}.pdf`, text);
|
||||
}
|
||||
|
||||
private writeToFile(filePath: string, data: string): Promise<void> {
|
||||
const file = fs.createWriteStream(filePath);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
file.write(data, "base64");
|
||||
file.end();
|
||||
file.on("finish", () => {
|
||||
resolve();
|
||||
});
|
||||
file.on("error", reject);
|
||||
});
|
||||
}
|
||||
}
|
66
src/export/packer/next-compiler.spec.ts
Normal file
66
src/export/packer/next-compiler.spec.ts
Normal file
@ -0,0 +1,66 @@
|
||||
/* tslint:disable:typedef space-before-function-paren */
|
||||
import { expect } from "chai";
|
||||
import { File } from "../../file";
|
||||
import { Compiler } from "./next-compiler";
|
||||
|
||||
describe("Compiler", () => {
|
||||
let compiler: Compiler;
|
||||
let file: File;
|
||||
|
||||
beforeEach(() => {
|
||||
file = new File();
|
||||
compiler = new Compiler();
|
||||
});
|
||||
|
||||
describe("#compile()", () => {
|
||||
it("should pack all the content", async function() {
|
||||
this.timeout(99999999);
|
||||
const zipFile = await compiler.compile(file);
|
||||
const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name);
|
||||
|
||||
expect(fileNames).is.an.instanceof(Array);
|
||||
expect(fileNames).has.length(17);
|
||||
expect(fileNames).to.include("word/document.xml");
|
||||
expect(fileNames).to.include("word/styles.xml");
|
||||
expect(fileNames).to.include("docProps/core.xml");
|
||||
expect(fileNames).to.include("docProps/app.xml");
|
||||
expect(fileNames).to.include("word/numbering.xml");
|
||||
expect(fileNames).to.include("word/header1.xml");
|
||||
expect(fileNames).to.include("word/_rels/header1.xml.rels");
|
||||
expect(fileNames).to.include("word/footer1.xml");
|
||||
expect(fileNames).to.include("word/footnotes.xml");
|
||||
expect(fileNames).to.include("word/_rels/footer1.xml.rels");
|
||||
expect(fileNames).to.include("word/_rels/document.xml.rels");
|
||||
expect(fileNames).to.include("[Content_Types].xml");
|
||||
expect(fileNames).to.include("_rels/.rels");
|
||||
});
|
||||
|
||||
it("should pack all additional headers and footers", async function() {
|
||||
file.createFooter();
|
||||
file.createFooter();
|
||||
file.createHeader();
|
||||
file.createHeader();
|
||||
|
||||
this.timeout(99999999);
|
||||
|
||||
const zipFile = await compiler.compile(file);
|
||||
const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name);
|
||||
|
||||
expect(fileNames).is.an.instanceof(Array);
|
||||
expect(fileNames).has.length(25);
|
||||
|
||||
expect(fileNames).to.include("word/header1.xml");
|
||||
expect(fileNames).to.include("word/_rels/header1.xml.rels");
|
||||
expect(fileNames).to.include("word/header2.xml");
|
||||
expect(fileNames).to.include("word/_rels/header2.xml.rels");
|
||||
expect(fileNames).to.include("word/header3.xml");
|
||||
expect(fileNames).to.include("word/_rels/header3.xml.rels");
|
||||
expect(fileNames).to.include("word/footer1.xml");
|
||||
expect(fileNames).to.include("word/_rels/footer1.xml.rels");
|
||||
expect(fileNames).to.include("word/footer2.xml");
|
||||
expect(fileNames).to.include("word/_rels/footer2.xml.rels");
|
||||
expect(fileNames).to.include("word/footer3.xml");
|
||||
expect(fileNames).to.include("word/_rels/footer3.xml.rels");
|
||||
});
|
||||
});
|
||||
});
|
@ -16,37 +16,44 @@ interface IXmlifyedFileMapping {
|
||||
Numbering: IXmlifyedFile;
|
||||
Relationships: IXmlifyedFile;
|
||||
FileRelationships: IXmlifyedFile;
|
||||
Header: IXmlifyedFile;
|
||||
Footer: IXmlifyedFile;
|
||||
HeaderRelationships: IXmlifyedFile;
|
||||
FooterRelationships: IXmlifyedFile;
|
||||
Headers: IXmlifyedFile[];
|
||||
Footers: IXmlifyedFile[];
|
||||
HeaderRelationships: IXmlifyedFile[];
|
||||
FooterRelationships: IXmlifyedFile[];
|
||||
ContentTypes: IXmlifyedFile;
|
||||
AppProperties: IXmlifyedFile;
|
||||
FootNotes: IXmlifyedFile;
|
||||
}
|
||||
|
||||
export class Compiler {
|
||||
private readonly formatter: Formatter;
|
||||
|
||||
constructor(private readonly file: File) {
|
||||
constructor() {
|
||||
this.formatter = new Formatter();
|
||||
}
|
||||
|
||||
public async compile(): Promise<JSZip> {
|
||||
public async compile(file: File): Promise<JSZip> {
|
||||
const zip = new JSZip();
|
||||
|
||||
const xmlifiedFileMapping = this.xmlifyFile(this.file);
|
||||
const xmlifiedFileMapping = this.xmlifyFile(file);
|
||||
|
||||
for (const key in xmlifiedFileMapping) {
|
||||
if (!xmlifiedFileMapping[key]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const xmlifiedFile = xmlifiedFileMapping[key];
|
||||
const obj = xmlifiedFileMapping[key] as IXmlifyedFile | IXmlifyedFile[];
|
||||
|
||||
zip.file(xmlifiedFile.path, xmlifiedFile.data);
|
||||
if (Array.isArray(obj)) {
|
||||
for (const subFile of obj) {
|
||||
zip.file(subFile.path, subFile.data);
|
||||
}
|
||||
} else {
|
||||
zip.file(obj.path, obj.data);
|
||||
}
|
||||
}
|
||||
|
||||
for (const data of this.file.Media.Array) {
|
||||
for (const data of file.Media.Array) {
|
||||
const mediaData = data.stream;
|
||||
zip.file(`word/media/${data.fileName}`, mediaData);
|
||||
}
|
||||
@ -85,22 +92,22 @@ export class Compiler {
|
||||
data: xml(this.formatter.format(file.FileRelationships)),
|
||||
path: "_rels/.rels",
|
||||
},
|
||||
Header: {
|
||||
data: xml(this.formatter.format(file.Header.Header)),
|
||||
path: "word/header1.xml",
|
||||
},
|
||||
Footer: {
|
||||
data: xml(this.formatter.format(file.Footer.Footer)),
|
||||
path: "word/footer1.xml",
|
||||
},
|
||||
HeaderRelationships: {
|
||||
data: xml(this.formatter.format(file.Header.Relationships)),
|
||||
path: "word/_rels/header1.xml.rels",
|
||||
},
|
||||
FooterRelationships: {
|
||||
data: xml(this.formatter.format(file.Footer.Relationships)),
|
||||
path: "word/_rels/footer1.xml.rels",
|
||||
},
|
||||
Headers: file.Headers.map((headerWrapper, index) => ({
|
||||
data: xml(this.formatter.format(headerWrapper.Header)),
|
||||
path: `word/header${index + 1}.xml`,
|
||||
})),
|
||||
Footers: file.Footers.map((footerWrapper, index) => ({
|
||||
data: xml(this.formatter.format(footerWrapper.Footer)),
|
||||
path: `word/footer${index + 1}.xml`,
|
||||
})),
|
||||
HeaderRelationships: file.Headers.map((headerWrapper, index) => ({
|
||||
data: xml(this.formatter.format(headerWrapper.Relationships)),
|
||||
path: `word/_rels/header${index + 1}.xml.rels`,
|
||||
})),
|
||||
FooterRelationships: file.Footers.map((footerWrapper, index) => ({
|
||||
data: xml(this.formatter.format(footerWrapper.Relationships)),
|
||||
path: `word/_rels/footer${index + 1}.xml.rels`,
|
||||
})),
|
||||
ContentTypes: {
|
||||
data: xml(this.formatter.format(file.ContentTypes)),
|
||||
path: "[Content_Types].xml",
|
||||
@ -109,6 +116,10 @@ export class Compiler {
|
||||
data: xml(this.formatter.format(file.AppProperties)),
|
||||
path: "docProps/app.xml",
|
||||
},
|
||||
FootNotes: {
|
||||
data: xml(this.formatter.format(file.FootNotes)),
|
||||
path: "word/footnotes.xml",
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -2,41 +2,45 @@
|
||||
import { assert } from "chai";
|
||||
import { stub } from "sinon";
|
||||
|
||||
import { BufferPacker } from "../../export/packer/buffer";
|
||||
import { File, Paragraph } from "../../file";
|
||||
import { Packer } from "./packer";
|
||||
|
||||
describe("BufferPacker", () => {
|
||||
let packer: BufferPacker;
|
||||
describe("Packer", () => {
|
||||
let packer: Packer;
|
||||
let file: File;
|
||||
|
||||
beforeEach(() => {
|
||||
const file = new File({
|
||||
file = new File({
|
||||
creator: "Dolan Miu",
|
||||
revision: "1",
|
||||
lastModifiedBy: "Dolan Miu",
|
||||
});
|
||||
const paragraph = new Paragraph("test text");
|
||||
const heading = new Paragraph("Hello world").heading1();
|
||||
|
||||
file.addParagraph(new Paragraph("title").title());
|
||||
file.addParagraph(heading);
|
||||
file.addParagraph(new Paragraph("heading 2").heading2());
|
||||
file.addParagraph(paragraph);
|
||||
|
||||
packer = new BufferPacker(file);
|
||||
packer = new Packer();
|
||||
});
|
||||
|
||||
describe("#pack()", () => {
|
||||
describe("#toBuffer()", () => {
|
||||
it("should create a standard docx file", async function() {
|
||||
this.timeout(99999999);
|
||||
const buffer = await packer.pack();
|
||||
const buffer = await packer.toBuffer(file);
|
||||
|
||||
assert.isDefined(buffer);
|
||||
assert.isTrue(buffer.byteLength > 0);
|
||||
});
|
||||
|
||||
it("should handle exception if it throws any", () => {
|
||||
// tslint:disable-next-line:no-any
|
||||
const compiler = stub((packer as any).packer, "compile");
|
||||
const compiler = stub((packer as any).compiler, "compile");
|
||||
|
||||
compiler.throwsException();
|
||||
return packer.pack().catch((error) => {
|
||||
return packer.toBuffer(file).catch((error) => {
|
||||
assert.isDefined(error);
|
||||
});
|
||||
});
|
@ -1,9 +1,31 @@
|
||||
export interface IPacker {
|
||||
pack(path: string): void;
|
||||
import { File } from "file";
|
||||
import { Compiler } from "./next-compiler";
|
||||
|
||||
export class Packer {
|
||||
private readonly compiler: Compiler;
|
||||
|
||||
constructor() {
|
||||
this.compiler = new Compiler();
|
||||
}
|
||||
|
||||
// Needed because of: https://github.com/s-panferov/awesome-typescript-loader/issues/432
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
export const WORKAROUND = "";
|
||||
public async toBuffer(file: File): Promise<Buffer> {
|
||||
const zip = await this.compiler.compile(file);
|
||||
const zipData = (await zip.generateAsync({ type: "nodebuffer" })) as Buffer;
|
||||
|
||||
return zipData;
|
||||
}
|
||||
|
||||
public async toBase64String(file: File): Promise<string> {
|
||||
const zip = await this.compiler.compile(file);
|
||||
const zipData = (await zip.generateAsync({ type: "base64" })) as string;
|
||||
|
||||
return zipData;
|
||||
}
|
||||
|
||||
public async toBlob(file: File): Promise<Blob> {
|
||||
const zip = await this.compiler.compile(file);
|
||||
const zipData = (await zip.generateAsync({ type: "blob" })) as Blob;
|
||||
|
||||
return zipData;
|
||||
}
|
||||
}
|
||||
|
48
src/export/packer/pdf-packer.spec.ts
Normal file
48
src/export/packer/pdf-packer.spec.ts
Normal file
@ -0,0 +1,48 @@
|
||||
/* tslint:disable:typedef space-before-function-paren */
|
||||
import { assert, expect } from "chai";
|
||||
import { stub } from "sinon";
|
||||
|
||||
import { File, Paragraph } from "../../file";
|
||||
import { PdfPacker } from "./pdf-packer";
|
||||
|
||||
describe("PdfPacker", () => {
|
||||
let packer: PdfPacker;
|
||||
let file: File;
|
||||
|
||||
beforeEach(() => {
|
||||
file = new File({
|
||||
creator: "Dolan Miu",
|
||||
revision: "1",
|
||||
lastModifiedBy: "Dolan Miu",
|
||||
});
|
||||
const paragraph = new Paragraph("test text");
|
||||
const heading = new Paragraph("Hello world").heading1();
|
||||
|
||||
file.addParagraph(new Paragraph("title").title());
|
||||
file.addParagraph(heading);
|
||||
file.addParagraph(new Paragraph("heading 2").heading2());
|
||||
file.addParagraph(paragraph);
|
||||
|
||||
packer = new PdfPacker();
|
||||
});
|
||||
|
||||
describe("#packPdf", () => {
|
||||
it("should create a standard PDF file", async function() {
|
||||
this.timeout(99999999);
|
||||
// tslint:disable-next-line:no-any
|
||||
const pdfConverterConvert = stub((packer as any).pdfConverter, "convert");
|
||||
pdfConverterConvert.returns(new Buffer(""));
|
||||
const buffer = await packer.toBuffer(file);
|
||||
expect(buffer).is.an.instanceof(Buffer);
|
||||
});
|
||||
|
||||
it("should handle exception if it throws any", () => {
|
||||
// tslint:disable-next-line:no-any
|
||||
const compiler = stub((packer as any).packer, "toBuffer");
|
||||
compiler.throwsException();
|
||||
return packer.toBuffer(file).catch((error) => {
|
||||
assert.isDefined(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,12 +1,23 @@
|
||||
import * as fs from "fs";
|
||||
import * as request from "request-promise";
|
||||
|
||||
export interface IConvertOutput {
|
||||
data: string;
|
||||
import { File } from "file";
|
||||
import { Packer } from "./packer";
|
||||
|
||||
export class PdfPacker {
|
||||
private readonly packer: Packer;
|
||||
|
||||
constructor() {
|
||||
this.packer = new Packer();
|
||||
}
|
||||
|
||||
export class PdfConvertWrapper {
|
||||
public convert(filePath: string): request.RequestPromise {
|
||||
public async toBuffer(file: File): Promise<Buffer> {
|
||||
const buffer = await this.packer.toBuffer(file);
|
||||
const text = await this.convert(buffer);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private convert(buffer: Buffer): request.RequestPromise {
|
||||
return request.post({
|
||||
url: "http://mirror1.convertonlinefree.com",
|
||||
// tslint:disable-next-line:no-null-keyword
|
||||
@ -20,7 +31,7 @@ export class PdfConvertWrapper {
|
||||
__EVENTARGUMENT: "",
|
||||
__VIEWSTATE: "",
|
||||
ctl00$MainContent$fu: {
|
||||
value: fs.readFileSync(filePath),
|
||||
value: buffer,
|
||||
options: {
|
||||
filename: "output.docx",
|
||||
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
@ -1,25 +0,0 @@
|
||||
import { Readable, Transform } from "stream";
|
||||
import { File } from "../../file";
|
||||
import { Compiler } from "./compiler";
|
||||
import { IPacker } from "./packer";
|
||||
|
||||
class Pipe extends Transform {
|
||||
public _transform(chunk: Buffer | string, encoding: string, callback: () => void): void {
|
||||
this.push(chunk, encoding);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
export class StreamPacker implements IPacker {
|
||||
private readonly compiler: Compiler;
|
||||
|
||||
constructor(file: File) {
|
||||
this.compiler = new Compiler(file);
|
||||
}
|
||||
|
||||
public pack(): Readable {
|
||||
const pipe = new Pipe();
|
||||
this.compiler.compile(pipe);
|
||||
return pipe;
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ function createDrawing(drawingOptions?: IDrawingOptions): Drawing {
|
||||
{
|
||||
fileName: "test.jpg",
|
||||
referenceId: 1,
|
||||
stream: fs.createReadStream(path),
|
||||
stream: fs.readFileSync(path),
|
||||
path: path,
|
||||
dimensions: {
|
||||
pixels: {
|
||||
|
Reference in New Issue
Block a user