android - Print PDF as byte array in JAVA -
i need print pdf file printer. code have converted pdf bytearray, stuck , not know how send printer. can me?
file file = new file("java.pdf"); fileinputstream fis = new fileinputstream(file); bytearrayoutputstream bos = new bytearrayoutputstream(); byte[] buf = new byte[1024]; try { (int readnum; (readnum = fis.read(buf)) != -1;) { bos.write(buf, 0, readnum); //no doubt here 0 //writes len bytes specified byte array starting @ offset off byte array output stream. system.out.println("read " + readnum + " bytes,"); } } catch (ioexception ex) { system.out.println("error!"); } byte[] bytes = bos.tobytearray();
thank in advance.
another approach send pdf file using intent , here example
sample code :
intent prnintent = new intent(intent.action_send); prnintent.putextra(intent.extra_stream, uri); prnintent.settype("application/pdf"); startactivity(intent.createchooser(prnintent , "send pdf using:"));
with approach there no need use buffers send pdf file directly printer!
Comments
Post a Comment