diff --git a/README.md b/README.md index 7baddba..bc34587 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,4 @@ List of formats read: | RTF | X | text/rtf | | ODT | X | application/vnd.oasis.opendocument.text | | DOCX | X | application/vnd.openxmlformats-officedocument.wordprocessingml.document | +| PDF | X | application/pdf " diff --git a/opencrucible.go b/opencrucible.go index b4466c7..b41aa7b 100644 --- a/opencrucible.go +++ b/opencrucible.go @@ -129,4 +129,5 @@ func readPdf(path string) (string, error) { newBytes := []byte(" ") replacedBytes := bytes.Replace(buf.Bytes(), oldBytes, newBytes, -1) return strings.Trim(string(replacedBytes), " "), nil -} \ No newline at end of file +} + diff --git a/opencrucible_test.go b/opencrucible_test.go index 66606ce..e50ac10 100644 --- a/opencrucible_test.go +++ b/opencrucible_test.go @@ -129,3 +129,19 @@ func TestPDFFileParser(t *testing.T) { t.Errorf("got %q, wanted %q", got, want) } } + +func TestPDFDetect(t *testing.T) { + pdf, err := os.ReadFile(filepath.Join("test_file","test_file_pdf_1000.pdf")) + if err != nil { + t.Errorf("error loading file \n %s", err) + } + got, _, err := DetectFileTypeMIME(pdf) + if err != nil { + t.Errorf("unable to detect file \n %s", err) + } + want := "application/pdf" + t.Logf("Parsed: %s", got) + if got != want { + t.Errorf("got %q, wanted %q", got, want) + } +} \ No newline at end of file diff --git a/test_file/test_file_pdf_1000.pdf b/test_file/test_file_pdf_1000.pdf new file mode 100644 index 0000000..02bc01a Binary files /dev/null and b/test_file/test_file_pdf_1000.pdf differ