我需要使用int number1, number2, number3, number4;
if (Int32.TryParse(textBox1.Text, out number1) && Int32.TryParse(textBox2.Text, out number2) &&
Int32.TryParse(textBox3.Text, out number3) && Int32.TryParse(textBox4.Text, out number4))
{
if(number1 + number2 + number3 + number4 == 100)
MessageBox.Show("Activated");
else
MessageBox.Show("License key is not valid.", "License key is not valid.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else
MessageBox.Show("No letters allowed in the textboxes.", "No letters allowed in the textboxes", MessageBoxButtons.OK, MessageBoxIcon.Stop);
创建pdf,并且已经遵循this blog。但这是行不通的。你能告诉我为什么吗?
注意:错误在此行blob
上发出。这是在const fileEntry = await
上。在浏览器上,它运行正常(即android device
)。
this.pdfObj.download();
这是错误:
constructor(
private file: File,
private platform: Platform,
private fileOpener: FileOpener,
) {
}
downloadReport() {
this.createPdf();
if (this.platform.is('cordova')) {
try {
this.pdfObj.getBuffer(async (buffer) => {
var utf8=new Uint8Array(buffer);
var binaryArray=utf8.buffer;
var blob = new Blob([binaryArray], { type: 'application/pdf' });
const fileEntry = await this.file.writeFile(this.file.dataDirectory, 'myletter.pdf', blob, { replace: true });
this.fileOpener.open(this.file.dataDirectory + 'myletter.pdf', 'application/pdf');
});
}
catch (err) {
console.log(err);
}
} else {
// On a browser simply use download!
this.pdfObj.download();
}
}
createPdf() {
var docDefinition = {
content: [
{ text: 'REMINDER', style: 'header' },
{ text: new Date().toTimeString(), alignment: 'right' },
{ text: 'From', style: 'subheader' }, { text: 'from' },
{ text: 'To', style: 'subheader' }, 'To',
{ text: 'Sam lokuge', style: 'story', margin: [0, 20, 0, 20] },
{
ul: [
'Bacon',
'Rips',
'BBQ',
]
}
],
styles: {
header: {
fontSize: 18,
bold: true,
},
subheader: {
fontSize: 14,
bold: true,
margin: [0, 15, 0, 0]
},
story: {
italic: true,
alignment: 'center',
width: '50%',
}
}
}
this.pdfObj = pdfMake.createPdf(docDefinition);
}
答案 0 :(得分:1)
我在这里找到了问题。这是由于此路径this.file.dataDirectory
。但是错误消息并未明确提及。因此,花了很多时间来确定问题。最后,我更改了路径,然后没有问题。我使用了此路径this.file.externalApplicationStorageDirectory
,现在可以正常使用了。