77 "os/exec"
88 "path/filepath"
99 "strings"
10-
11- "github.com/BuddhiLW/AutoPDF/internal /config"
10+
11+ "github.com/BuddhiLW/AutoPDF/pkg /config"
1212)
1313
1414// Converter handles PDF to image conversion
@@ -53,18 +53,18 @@ func (c *Converter) ConvertPDFToImages(pdfFile string) ([]string, error) {
5353 // ImageMagick approach
5454 for _ , format := range formats {
5555 outputPath := filepath .Join (dir , fmt .Sprintf ("%s.%s" , baseName , format ))
56- cmd := exec .Command ("convert" ,
57- "-density" , "300" ,
58- pdfFile ,
56+ cmd := exec .Command ("convert" ,
57+ "-density" , "300" ,
58+ pdfFile ,
5959 outputPath )
60-
60+
6161 if err := cmd .Run (); err != nil {
6262 return outputFiles , fmt .Errorf ("image conversion failed for %s: %w" , format , err )
6363 }
64-
64+
6565 outputFiles = append (outputFiles , outputPath )
6666 }
67-
67+
6868 return outputFiles , nil
6969 }
7070
@@ -75,7 +75,7 @@ func (c *Converter) ConvertPDFToImages(pdfFile string) ([]string, error) {
7575 // pdftoppm has specific flags for different formats
7676 var outputPrefix string
7777 var args []string
78-
78+
7979 switch format {
8080 case "png" :
8181 outputPrefix = filepath .Join (dir , baseName )
@@ -86,20 +86,20 @@ func (c *Converter) ConvertPDFToImages(pdfFile string) ([]string, error) {
8686 default :
8787 continue // Skip unsupported formats
8888 }
89-
89+
9090 cmd := exec .Command ("pdftoppm" , args ... )
91-
91+
9292 if err := cmd .Run (); err != nil {
9393 return outputFiles , fmt .Errorf ("image conversion failed for %s: %w" , format , err )
9494 }
95-
95+
9696 // pdftoppm adds numeric suffixes to outputs for multi-page documents
9797 // For simplicity, we'll just note the base name
9898 outputFiles = append (outputFiles , fmt .Sprintf ("%s-*.%s" , outputPrefix , format ))
9999 }
100-
100+
101101 return outputFiles , nil
102102 }
103103
104104 return nil , errors .New ("no suitable conversion tool found (tried 'convert' and 'pdftoppm')" )
105- }
105+ }
0 commit comments