A comprehensive Go library for PDF manipulation, conversion, and more.
- Combiner: Merge multiple PDF files into one.
- Splitter: Split a PDF into individual pages.
- Compressor: Optimize PDF files to reduce size.
- Converter: Convert various formats (Text, Images, HTML) to PDF.
- Reverser: Convert PDF to Text, HTML, or Images.
- HTML Conversion & PDF to Image: Requires a Chrome or Chromium installation on the system as it uses
chromedp. - Platform Support: Works on Windows, macOS, and Linux.
go get github.com/hamzaelmarjani/pdf-utils-goimport "github.com/hamzaelmarjani/pdf-utils-go"
utils := pdf_utils.NewPDFUtils()paths := []string{"file1.pdf", "file2.pdf"}
output, err := utils.Combine(paths, "")
if err == nil {
fmt.Printf("Combined PDF saved at: %s\n", output)
}pages, err := utils.Split("large_file.pdf")
if err == nil {
for i, pagePath := range pages {
fmt.Printf("Page %d saved at: %s\n", i+1, pagePath)
}
}compressedPath, err := utils.Compress("original.pdf", 0.5)
if err == nil {
fmt.Printf("Compressed PDF saved at: %s\n", compressedPath)
}Supported formats: txt, png, jpg, jpeg, html.
pdfPath, err := utils.ConvertToPDF("image.jpeg")
if err == nil {
fmt.Printf("Generated PDF: %s\n", pdfPath)
}Supported formats: text, html, png, jpg, jpeg.
textPath, err := utils.ReverseFromPDF("document.pdf", "text")
if err == nil {
fmt.Printf("Extracted text saved at: %s\n", textPath)
}- Clone the repository and enter the project folder:
git clone https://github.com/hamzaelmarjani/pdf-utils-go.git pdf-utils-go && cd pdf-utils-go- Create a new
tests_datafolder in the project root, and set the source files there. - Run the tests:
go test- Check the results inside the
./distfolder.
MIT