Open feras-merwas opened 2 years ago
try this code const printIt = async () => { const imageUrl = 'http://park24.co.in/public/assets/uploads/16947003915787.png';
// Fetch the image data and convert it to base64 const response = await fetch(imageUrl); const blob = await response.blob(); const reader = new FileReader(); reader.onload = async () => { const base64ImageData = reader.result.split(',')[1]; // Extract the base64 data console.log('base64ImageData', base64ImageData);
// Initialize the printer
try {
await BluetoothEscposPrinter.printerInit();
await BluetoothEscposPrinter.printerAlign(
BluetoothEscposPrinter.ALIGN.CENTER,
);
// Print the image
await BluetoothEscposPrinter.printPic(base64ImageData, {
width: 200,
left: 100,
});
console.log('Image printed successfully');
} catch (e) {
console.error('Error printing image:', e);
}
}; reader.readAsDataURL(blob); };
useEffect(() => {
printIt()
});
its working for me
on top component var FileSystem = require('react-native-fs');
hello this is my code when printPic i got weird characters
import { BluetoothManager, BluetoothEscposPrinter, } from 'react-native-bluetooth-escpos-printer'; version '0.0.5'
can you help me please i am stuck here