pdf_to_img.go 531 B

1234567891011121314151617181920212223242526
  1. package controllers
  2. import (
  3. "bytes"
  4. "fmt"
  5. "os/exec"
  6. )
  7. type PdfToImgCommonController struct {
  8. BaseCommonController
  9. }
  10. // @router /convert [get]
  11. func (this *PdfToImgCommonController) PdfToImgConvert() {
  12. pdfName := "./static/Elasticsearch1.pdf"
  13. imageName := "./static/imgs/test.jpg"
  14. s:=`convert -resize 1000x -density 100 -quality 100 `+pdfName+` `+imageName
  15. cmd := exec.Command("/bin/bash", "-c", s)
  16. var out bytes.Buffer
  17. cmd.Stdout = &out
  18. err := cmd.Run()
  19. if err!=nil {
  20. fmt.Println("cmd.Run Err:",err.Error())
  21. }
  22. }