PDF CRLF
by LaAsCE
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.input.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.filter.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.pdf.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.pdf.min.js"></script>
<div class="container">
<h1>
Export PDF dynamic font + Word Wrap (5.20203.748)
</h1>
<button id="btnCreateDoc" class="btn btn-default">
Export PDF
</button>
<div id="theGrid"></div>
</div>
CSS
@font-face {
font-family: ipaexg;
src: url('https://demo.grapecity.com/wijmo/sample/fonts/ipaexg.ttf');
}
.custom-word-wrap {
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
.wj-flexgrid .wj-cell{
line-height: normal;
}
.wj-cell {
font-family: ipaexg;
}
JavaScript
onload = function () {
// create some random data
var countries = '123456748,1.あい\r\n2.おあ\r\n3.いう\r\n4.うえ\r\n5.うえ\r\n6.えお\r\n7.あい,123456'.split(',');
var data = [];
for (var i = 0; i < 10; i++) {
data.push({
id: i,
country: countries[i % countries.length],
sales: Math.random() * 10000,
expenses: Math.random() * 5000
});
}
// show the data in a grid
var theGrid = new wijmo.grid.FlexGrid('#theGrid', {
autoGenerateColumns: false,
autoRowHeights: true,
columns: [
{ multiLine:true, binding: 'id', header: 'ID', width: 60, wordWrap: true, cssClass: 'custom-word-wrap' },
{ multiLine:true, binding: 'country', header: 'Country', width: 150, wordWrap: true, cssClass: 'custom-word-wrap' }
],
itemsSource: data
});
// set row height
/* theGrid.rows.defaultSize = 345; */
// add a filter to show that it works while exporting
var f = new wijmo.grid.filter.FlexGridFilter(theGrid);
var exportSettings =
{
maxPages: 10,
scaleMode: wijmo.grid.pdf.ScaleMode.PageWidth,
customCellContent: true,
documentOptions: {
compress: true,
header: { declarative: { text: '\t&[Page] of &[Pages]' } },
footer: { declarative: { text: '\t&[Page] of &[Pages]' } },
info: { author: 'C1', title: 'Learn Wijmo' }
},
embeddedFonts: [
{
source: 'https://demo.grapecity.com/wijmo/sample/fonts/ipaexg.ttf',
name: 'ipaexg',
style: 'normal',
weight: 'normal',
sansSerif: true
}
],
styles: {
cellStyle: {
backgroundColor: '#ffffff',
borderColor: '#c6c6c6',
font: {
family: 'ipaexg'
}
},
altCellStyle: {
...