Xportability / css-to-pdf

Convert any HTML page or region to PDF - supports CSS, SVG, embedded XML objects, and more..
http://www.cloudformatter.com/CSS2Pdf
206 stars 78 forks source link

PDF downloads no matter what 'render' is set to #49

Closed spaceghostu closed 7 years ago

spaceghostu commented 7 years ago

js:

function htmlToPdf() {
    xepOnline.Formatter.Format('html-to-pdf', {
        render: 'embed',
        pageWidth:'297mm',
        pageHeight:'210mm',
        pageMargin: '0mm'
    });
}    

html:

<button ng-click="$ctrl.htmlToPdf()">pdf</button>
<div id="html-to-pdf">
    <div class="page">
        <div class="cover-page-title text-center">
            <h1>{{$ctrl.Factsheet.name}}</h1>
        </div>
    </div>
</div>

css:

#html-to-pdf .page {
  width: 1403px;
  height: 992px;
  background-color: white;
}
#html-to-pdf .cover-page-title {
  width: 100%;
  padding-top: 350px;
}
kbrown01 commented 7 years ago

What browser? There is a browser sniffing mechanism that switches to download for browsers that do not support embedding (like IE, Edge and Android).

kbrown01 commented 7 years ago

Closing with this comment: embedding is only supported on certain browsers. If the browser does not support embedding, then it switches to download mode.