Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Adding GetPlainText methods, fixing charmap #21

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

rikvanmechelen
Copy link

based on #17
but includes the fix mentioned by @martoche

Peter Longyear and others added 2 commits March 26, 2018 14:54
Copy link

@chenenze chenenze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have some commit @ledongthuc @rikvanmechelen

}

var buf bytes.Buffer
buf.ReadFrom(r.GetPlainText())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:

func readPdf(path string) (string, error) {
	r, err := pdf.Open(path)
	if err != nil {
		return "", err
	}

	i, err := r.GetPlainText()
	if err != nil {
		return "", err
	}

	var buf bytes.Buffer
	buf.ReadFrom(i)
	return buf.String(), nil
}

var lastTextStyle pdf.Text
texts := p.Content().Text
for _, text := range texts {
if isSameSentence(text, lastTextStyle) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example lost a function,maybe like this:

func isSameSentence(t1, t2 pdf.Text) bool {
	if t1.Font == t2.Font && t1.FontSize == t2.FontSize {
		return true
	}
	return false
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func isSameSentence(t1, t2 pdf.Text) bool {
       // if Y axis changes new line else same line
	if t1.Y != t2.Y {
		return false
	}
	return true
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants