Skip to content

Commit

Permalink
fix: PDF title
Browse files Browse the repository at this point in the history
  • Loading branch information
colinramsay committed Feb 1, 2024
1 parent 7a36a2a commit 7053eeb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@ func ConvertPDFText(path string) (BodyResult, MetaResult, error) {
// Parse meta output
for _, line := range strings.Split(string(metaStr), "\n") {
if parts := strings.SplitN(line, ":", 2); len(parts) > 1 {
metaResult.meta[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])
metaResult.meta[strings.ToLower(strings.TrimSpace(parts[0]))] = strings.TrimSpace(parts[1])
}
}

// Convert parsed meta

if x, ok := metaResult.meta["ModDate"]; ok {
if t, ok := pdfTimeLayouts.Parse(x); ok {
metaResult.meta["ModifiedDate"] = fmt.Sprintf("%d", t.Unix())
metaResult.meta["modifiedDate"] = fmt.Sprintf("%d", t.Unix())
}
}
if x, ok := metaResult.meta["CreationDate"]; ok {
if t, ok := pdfTimeLayouts.Parse(x); ok {
metaResult.meta["CreatedDate"] = fmt.Sprintf("%d", t.Unix())
metaResult.meta["createdDate"] = fmt.Sprintf("%d", t.Unix())
}
}

Expand Down

0 comments on commit 7053eeb

Please sign in to comment.