Comments (6)
I'm having the same issue, did you find any solution ?
from bluetooth_print.
I was having the same issue in Android. I noticed that the example app on pub.dev had the line to show the image commented out!
However, I discovered that the error is because the image size has not been set. For the image, you have to set an int value under width:200 for example. This then works. Have not tested in IOS but not setting the width caused a compile error. Once the width was set, error was removed and image printed.
printList.add(LineText(type: LineText.TYPE_IMAGE, width:200, content: base64Image, align: LineText.ALIGN_CENTER, linefeed: 1));
from bluetooth_print.
I am also facing the same issues, did anyone have the solution ?
I have set the width and height to 100. it work great in android, but in IOS it cannot print image, it show the error above
from bluetooth_print.
I have solved the problem but adding resizing code in IOS
You can go to ios/Classes/BluetoothPrintPlugin.m
Then look for function mapToEscCommand, within it have a part is else if([@"image" isEqualToString:type]){
replace the code below will solved the ios printer image cannot print problem
else if([@"image" isEqualToString:type]){
NSData *decodeData = [[NSData alloc] initWithBase64EncodedString:content options:0];
UIImage *image = [UIImage imageWithData:decodeData];
// Define the maximum width
CGFloat maxWidth = 100.0; // Adjust the maximum width as needed
// Calculate the target size while maintaining the original aspect ratio
CGSize originalSize = image.size;
CGFloat scaleFactor = maxWidth / originalSize.width;
CGSize targetSize = CGSizeMake(originalSize.width * scaleFactor, originalSize.height * scaleFactor);
// Create a renderer with the calculated target size
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:targetSize];
// Render the image and get a new data representation
NSData *renderedImageData = [renderer JPEGDataWithCompressionQuality:1 actions:^(UIGraphicsImageRendererContext * _Nonnull context) {
[image drawInRect:CGRectMake(0, 0, targetSize.width, targetSize.height)];
}];
UIImage *resizedImage = [UIImage imageWithData:renderedImageData];
[command addOriginrastBitImage:resizedImage];
}
from bluetooth_print.
@Niagawan-mave thanks a lot, finally it's working on ios now
did you create a new package on pub.dev? or just forked it to your github account?
from bluetooth_print.
@HamzaMihfad I just forked to my github account
from bluetooth_print.
Related Issues (20)
- Can not print in IOS
- In IOS package is not working HOT 1
- Features: Please remove the line spacing
- Connect success then disconnect immediately HOT 10
- Application is getting crashed when connecting to the printer using bluetooth_print 4.3.0 Dependency in IOS but Working fine in android HOT 1
- Connected device address. HOT 2
- Arabic Support
- slow printing in tsc label printer HOT 1
- Cannot print using printer with TSPL command
- no print in android HOT 1
- Arabic Text support
- when will the new version come out? HOT 2
- Getting error for iOS - duplicate symbols for architecture x86_64 HOT 2
- [iOS] Signature and Logo Print issue HOT 3
- how change the text size like fontSize?
- Can't print after selecting the printer HOT 8
- device not showing HOT 2
- Not able to align image in center of thermal paper bluetooth_print 4.3.0 HOT 2
- can't align image and text in the same row
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bluetooth_print.