2014-10-27 56 views
1

有哪些不同的方法来从Java服务器发送PDF到Android设备 和哪一个最好的办法从Java服务器发送PDF到Android设备

  • 我们可以发送大尺寸的PDF(> 25 MB)在JSON到Android设备
  • 是否有任何其他的方式发送PDF格式的设备(即其他然后在JSON)

(大多采用Spring集成)

回答

2

你可以试试这个,使用Jax RS的一种方式, 它不使用JSON。它让文件下载到设备上。

@GET 
@Path("/{fileName}/excel") 
//Your Proper URL,using the fileName let you the download the specific pdf 
@Produces("application/pdf") 
public Response getFileInPDFFormat(@PathParam("fileName") String fileName) 
{ 
    String filePath="";// Your File Path 

    //Put some validations here such as invalid file name or missing file name 
    if(fileName == null || fileName.isEmpty()) 
    { 
     ResponseBuilder response = Response.status(Status.BAD_REQUEST); 
     return response.build(); 
    } 

    File file = new File(filePath); 

    ResponseBuilder response = Response.ok((Object) file); 
    response.header("Content-Disposition", "attachment; filename='"+fileName+"'"); 


    return response.build(); 
} 
0

发送(从服务器端发起下载到Android)它需要与谷歌云消息GCM安装Android应用程序和服务器端的推送通知消息到Android =从部分路段和未来的Android应用开始下载将开始下载(可以通过Web服务访问pdf,可以使用/不使用安全性,如JaxRS,Apache www root dir,但不安全或使用某些ftp)

相关问题