This repository has been archived by the owner on Jul 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 335
Adding GetPlainText methods, fixing charmap #21
Open
rikvanmechelen
wants to merge
20
commits into
rsc:master
Choose a base branch
from
rikvanmechelen:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Based on pull request of rsc#8 but never merged. So I need it :(
Add GetPlainText to Reader. Fix Encoder method
p variable in undefined in the function readPdf
Update README.md
Recover from panics when getting plain text
chenenze
reviewed
Jun 21, 2018
There was a problem hiding this 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()) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
based on #17
but includes the fix mentioned by @martoche