1234567891011121314151617181920212223242526 |
- package controllers
- import (
- "bytes"
- "fmt"
- "os/exec"
- )
- type PdfToImgCommonController struct {
- BaseCommonController
- }
- // @router /convert [get]
- func (this *PdfToImgCommonController) PdfToImgConvert() {
- pdfName := "./static/Elasticsearch1.pdf"
- imageName := "./static/imgs/test.jpg"
- s:=`convert -resize 1000x -density 100 -quality 100 `+pdfName+` `+imageName
- cmd := exec.Command("/bin/bash", "-c", s)
- var out bytes.Buffer
- cmd.Stdout = &out
- err := cmd.Run()
- if err!=nil {
- fmt.Println("cmd.Run Err:",err.Error())
- }
- }
|