Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_printDocumentPickerPDFAsync = async () => {
const { selectedPrinter } = this.state;
try {
const document = await DocumentPicker.getDocumentAsync({
type: 'application/pdf',
});
if (document.type !== 'success') {
throw new Error('User did not select a document');
}
await Print.printAsync({
uri: document.uri,
printerUrl: selectedPrinter ? selectedPrinter.url : undefined,
});
} catch (e) {
Alert.alert('Something went wrong: ', e.message);
}
};
_printDocumentPickerPDFAsync = async () => {
const { selectedPrinter } = this.state;
try {
const document = await DocumentPicker.getDocumentAsync({
type: 'application/pdf',
});
if (document.type !== 'success') {
throw new Error('User did not select a document');
}
await Print.printAsync({
uri: document.uri,
printerUrl: selectedPrinter ? selectedPrinter.url : undefined,
});
} catch (e) {
Alert.alert('Something went wrong: ', e.message);
}
}