我正在使用PDFMake来创建具有预定义文档定义的pdf.在我的旧离子1项目中,我将编码的字符串传递给print函数,该函数工作正常.这是旧离子1的代码
var dd = $scope.createDocumentDefinition();
$timeout(function () {
var pdf = pdfMake.createPdf(dd);
pdf.getBase64(function (encodedString) {
console.log(encodedString);
$ionicLoading.hide();
window.plugins.PrintPDF.print({
data: encodedString,
type: 'Data',
title: 'Print Document',
success: function () {
console.log('success');
},
error: function (data) {
data = JSON.parse(data);
console.log('failed: ' + data.error);
}
});
});
}, 1000);
Run Code Online (Sandbox Code Playgroud)
现在我正在将我的项目升级到Ionic 3,所以我尝试了相同的东西,但输出不同,这是我的新离子3代码.打印机打开但不是根据我的文档定义打印它只打印编码的字符串.
let printer_ = this.printer;
var dd = this.createDocumentDefinition();
var pdf = pdfMake.createPdf(dd);
pdf.getBase64(function (_encodedString) {
let options: PrintOptions = {
name: 'MyDocument'
};
console.log(JSON.stringify(pdf));
printer_.print(_encodedString, options).then((msg)=>{
console.log("Success",msg);
},(error) => {
console.log("Error", …Run Code Online (Sandbox Code Playgroud) I am stuck in one RegExp where I need to validate app version for app store and play-store. I have tried several RegExp but none of them is useful for me. Here are the example that pass the test
App version up-to 2-3 decimal point
1.0 // pass
1.0.0 // pass
1.0.0.0 // fail
a.0 // fail
1 // pass
Run Code Online (Sandbox Code Playgroud)
I found one RegExp [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ but this will only be valid when I have enter 4 decimal points. I don't …