krayzpipes / pdfparser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PDF Parser

PDF Parser is a command line tool and go library for decoding PDFs

Installation

First, Install Go

Then install/update the PDF Parser

go get -u github.com/KarmaPenny/pdfparser

To uninstall the PDF parser run:

go clean -i github.com/KarmaPenny/pdfparser && rm -rf $(go env GOPATH)/src/github.com/KarmaPenny/pdfparser

Usage

Command Line

$(go env GOPATH)/bin/pdfparser input.pdf > output.pdf

Library

package main

import (
	"fmt"
	"github.com/KarmaPenny/pdfparser/pdf"
	"os"
)

func main() {
	// open the pdf
	PDF, err := pdf.Open("test.pdf", "password")
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	defer PDF.Close()

	// print all indirect objects in xref
	for n, entry := range PDF.Xref {
		if entry.Type == pdf.XrefTypeIndirectObject {
			fmt.Println(PDF.ReadObject(n))
		}
	}
}

Unit Testing

go test github.com/KarmaPenny/pdfparser

About


Languages

Language:Go 100.0%