Closed cristiandaulisio closed 2 years ago
Could you provide an example? It is hard to say without seeing some code.
Hello,
i use this to write the pdf string to file
await FileSystem.writeFile(path, pdfstring)
the pdf string is about this: (i truncate now to not flood the post)
%PDF-1.7 %���� 1 0 obj << /Type /Catalog /Pages 2 0 R /PageMode /UseNone /ViewerPreferences << /FitWindow true /PageLayout /SinglePage /NonFullScreenPageMode /UseNone
endobj 5 0 obj << /Length 2404 /Filter [ /FlateDecode ]
stream x��XYs��~ǯ@H\s(Y�E뢽�%�v6�<ɛ����v��R�U�RI������1C�~�jN��g3m��~����":��W��f"�t+��~��F��h���Z ��>l��#k�MD?G�*?y���;;a����R��ى�`��&]��юƞ$=/?ET53�ܟ3#C�r��ɍ��;2 r?F�\j-5��^ ����V
in the final file i have this string ending here x��XYs��~ǯ
all the other content is truncate. I suppose there is some weird character that stop the function?
RN sometimes has trouble passing strings containing binary data between js-side and native-side. Try base 64 encoding it (something like https://www.npmjs.com/package/base-64 can help), then specifying encoding while writing: FileSystem.writeFile(path, pdfstring, 'base64')
.
If you have performance issues, you could try using FileSystem.fetch()
to download the pdf directly to disk (instead of loading in memory js side, encoding, then passing to native to write to disk).
Thanks for tip. at this momenti am using your fetch function and work fine, but for my flow was better using axios. well, i will try with base64 but think it will work.
thanks.
Assuming resolved. Please open a new issue if not.
Hello, i'm using your module to write a pdf on file. I use axios to call API and your module to write the file. The problem is the final file is incomplete.. it is only 67byte instead the 87kb. If i open the pdf with a text editor i see that only few rows are written.
is there a fix or i wrong something?