2013-04-19 2 views
2

내 안드로이드 응용 프로그램 내에서 PDF를 인쇄하려고합니다. 이 사람이 지금 내가 제대로 내 PDF로 변환 할 수 있는가하는 방법을 ...Android에서 PDF 인쇄

[email protected] 

내가 내 PDF 파일이 올바른 방법으로 표현되지 않는 것을 가정하지만, 매번 난 내 인쇄 된 페이지가 같은 이상한 데이터를 포함하는 인쇄하려고 내 outputstream?

은 이미이 질문에 (Printing pdf in android)의 코드를 시도,하지만 난 내 인쇄 된 페이지에 출력을 다음 얻을 :

Filter/FlateDecode/Length 69 >>stream 

아무도 나를 도와 드릴까요? :)

내 코드입니다 :

Socket socket = new Socket(); 
    String sIP = "192.168.0.250"; 
    String sPort = "9100"; 

    InetSocketAddress socketAddress = new InetSocketAddress(sIP, Integer.parseInt(sPort)); 
    DataOutputStream outputStream; 

    try{ 
     //file init 
     File pdfFile = new File(file); 
     byte[] byteArray=null; 
     InputStream inputStream = new FileInputStream(pdfFile); 
     String inputStreamToString = inputStream.toString(); 
     byteArray = inputStreamToString.getBytes(); 
     inputStream.close(); 

     //Socket init 
     socket.connect(socketAddress, 3000); 
     outputStream = new DataOutputStream(socket.getOutputStream()); 
     outputStream.write(byteArray); 
     outputStream.close(); 
     socket.close(); 
    }catch(Exception e){ 
     e.printStackTrace(); 
    } 

답변

0

당신은 BYTEARRAY 얻기 위해 이런 식으로 뭔가를 시도 할 수 있습니다 : 나는이 시도하는 경우

//file init 
File pdfFile = new File(file); 
byte[] byteArray = new byte[(int) pdfFile.length()]; 
FileInputStream fis = new FileInputStream(pdfFile); 
fis.read(byteArray); 
fis.close(); 
+0

것은, 내 프린터가 인쇄 할하지 않습니다하지만, 나는 또한 오류 또는 뭔가를 얻지 않는다 ... –