0

I'm having fun with pdfbox but still can't find usefull info about downloading this.

So, I've got button, when I click it - pdf is saved on my computer locally.

Controller:

@RequestMapping("/pdf")
public class DocumentCreateController {

@Autowired
private DocumentCreate DCpdf;

@RequestMapping(method=RequestMethod.GET)
public void getPDF() throws IOException{
    DCpdf.getPDF();
}
}

Service:

package pl.asseco.portalhr.obiegdokum;

import java.io.IOException;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.springframework.stereotype.Service;

@Service
public class DocumentCreate {

public void getPDF() throws IOException{
    PDDocument document = new PDDocument();
    document.save("C:/myfolder/test.pdf");      
    document.close();
    return;
}       
}

Please help, what about I have to learn? What I need to use?

Rob
  • 14,746
  • 28
  • 47
  • 65
Kondziowsky
  • 173
  • 1
  • 14
  • You say you want to download a pdf. You say the pdf downloads. Then you ask for help. Help for what? – Rob Nov 07 '17 at 14:06
  • "can't find usefull info about downloading this" - downloading what? – Tilman Hausherr Nov 07 '17 at 14:13
  • Your current code produces a PDF with no pages. – Tilman Hausherr Nov 07 '17 at 14:13
  • Yes, pdf downloads locally on my computer. But i want to click on button "PDF" and download this file where i want(popup window). Same for all users. Yes, its empty pdf, its not important at the moment. – Kondziowsky Nov 07 '17 at 14:18
  • 1
    I can't help you but these answers may: https://stackoverflow.com/questions/16670754/angularjs-simple-file-download https://stackoverflow.com/questions/28872607/download-a-file-with-angularjs https://stackoverflow.com/questions/16514509/how-do-you-serve-a-file-for-download-with-angularjs-or-javascript – Tilman Hausherr Nov 07 '17 at 18:54

0 Answers0