Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imageBase64 initWithContentsOfURL:options:maxLength:error #29

Closed
ahaikal opened this issue Oct 26, 2021 · 4 comments
Closed

imageBase64 initWithContentsOfURL:options:maxLength:error #29

ahaikal opened this issue Oct 26, 2021 · 4 comments

Comments

@ahaikal
Copy link

ahaikal commented Oct 26, 2021

Hi,
For large strings
imageBase64 works fine on Android
On IOS, i'm getting

2021-10-25 12:24:37.345579-0400 [30648:11504014] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSPlaceholderData initWithContentsOfURL:options:maxLength:error:]: nil URL argument'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff203fbbb4 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff2019ebe7 objc_exception_throw + 48
	2   Foundation                          0x00007fff207315f0 -[NSData(NSData) initWithContentsOfURL:options:maxLength:error:] + 581
	3   Foundation                          0x00007fff20730fb6 +[NSData(NSData) dataWithContentsOfURL:options:error:] + 49
	4   FreshSUQPOS                         0x00000001103cb064 -[EscPosPrinter handleCommand:params:] + 1476
	5   FreshSUQPOS                         0x00000001103cb641 -[EscPosPrinter printFromBuffer:onSuccess:onError:] + 449
	6   FreshSUQPOS                         0x00000001103c9084 __55-[EscPosPrinter printBuffer:withResolver:withRejecter:]_block_invoke + 244
	7   Foundation                          0x00007fff207df16b __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
	8   Foundation                          0x00007fff207df063 -[NSBlockOperation main] + 98
	9   Foundation                          0x00007fff207e2073 __NSOPERATION_IS_INVOKING_MAIN__ + 17
	10  Foundation                          0x00007fff207de2b0 -[NSOperation start] + 785
	11  Foundation                          0x00007fff207e29c7 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 17
	12  Foundation                          0x00007fff207e250c __NSOQSchedule_f + 182
	13  libdispatch.dylib                   0x00000001119f0bf7 _dispatch_block_async_invoke2 + 83
	14  libdispatch.dylib                   0x00000001119e1c0c _dispatch_client_callout + 8
	15  libdispatch.dylib                   0x00000001119e4595 _dispatch_continuation_pop + 594
	16  libdispatch.dylib                   0x00000001119e3964 _dispatch_async_redirect_invoke + 778
	17  libdispatch.dylib                   0x00000001119f3b44 _dispatch_root_queue_drain + 403
	18  libdispatch.dylib                   0x00000001119f45ec _dispatch_worker_thread2 + 196
	19  libsystem_pthread.dylib             0x00007fff6bfeb417 _pthread_wqthread + 244
	20  libsystem_pthread.dylib             0x00007fff6bfea42f start_wqthread + 15

@tr3v3r
Copy link
Owner

tr3v3r commented Oct 26, 2021

Hi! Could you please share the image? I’ll try to figure out what’s the problem.
( put in file please. do not paste all base64 here )

@ahaikal
Copy link
Author

ahaikal commented Oct 26, 2021

Thank you @tr3v3r , IMG

@tr3v3r
Copy link
Owner

tr3v3r commented Oct 28, 2021

@ahaikal just tested your image - everything works well.
Have you started your base64 data with data:image/png;base64, ?

Here is the ts file with base64 encoded string:
testBase64.ts.zip

import { testBase64 } from './testBase64';

...
  .imageBase64(testBase64, 500)
...

@tr3v3r
Copy link
Owner

tr3v3r commented Oct 29, 2021

@ahaikal hi!
Just released a new version (1.4.0) with support printing remote images and from a local sources.
Check the docs here

printing.initialize()
    .image(require('./store.png'), {
        width: 75,
        halftone: 'EPOS2_HALFTONE_THRESHOLD',
      })
    .image({ uri: base64Image }, { width: 75 })
    .image(
      {
        uri:
          'https://raw.githubusercontent.com/tr3v3r/react-native-esc-pos-printer/main/ios/store.png',
      },
      { width: 75 }
    )
    .cut()
    .send();

@tr3v3r tr3v3r closed this as completed Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants