adding .txt and .rtf files support (#20)

This commit is contained in:
Julien Neuhart
2018-12-12 16:34:34 +01:00
committed by GitHub
parent 5291d2d129
commit e5636a2afa
7 changed files with 2208 additions and 1 deletions

View File

@@ -11,7 +11,7 @@ At TheCodingMachine, we build a lot of web applications (intranets, extranets an
## Features
* HTML and Markdown conversions using Google Chrome headless
* Office conversions (.docx, .doc, .odt, .pptx, .ppt, .odp and so on) using [unoconv](https://github.com/dagwieers/unoconv)
* Office conversions (.txt, .rtf, .docx, .doc, .odt, .pptx, .ppt, .odp and so on) using [unoconv](https://github.com/dagwieers/unoconv)
* Performance :zap:: Google Chrome and Libreoffice (unoconv) started once in the background thanks to PM2
* Failure prevention :broken_heart:: PM2 automatically restarts previous processes if they fail
* Assets :package:: send your header, footer, images, fonts, stylesheets and so on for converting your HTML and Markdown to beaufitul PDFs!

View File

@@ -10,6 +10,8 @@ It accepts `POST` requests with a `multipart/form-data` Content-Type.
You may send one or more Office documents. Following file extensions are accepted:
* `.txt`
* `.rtf`
* `.doc`
* `.docx`
* `.odt`

View File

@@ -557,6 +557,8 @@ in the file <code>index.html</code>. This function will convert a given markdown
<p>You may send one or more Office documents. Following file extensions are accepted:</p>
<ul>
<li><code>.txt</code></li>
<li><code>.rtf</code></li>
<li><code>.doc</code></li>
<li><code>.docx</code></li>
<li><code>.odt</code></li>

View File

@@ -8,6 +8,8 @@ import (
)
var officeExts = []string{
".txt",
".rtf",
".doc",
".docx",
".odt",

View File

@@ -20,6 +20,8 @@ func TestOffice(t *testing.T) {
Context: ctx,
FilePaths: []string{
fmt.Sprintf("%s/%s", dirPath, "document.docx"),
fmt.Sprintf("%s/%s", dirPath, "document.txt"),
fmt.Sprintf("%s/%s", dirPath, "document.rtf"),
},
}
dst := fmt.Sprintf("%s/%s", dirPath, "foo.pdf")

2196
test/testdata/office/document.rtf vendored Normal file

File diff suppressed because it is too large Load Diff

3
test/testdata/office/document.txt vendored Normal file
View File

@@ -0,0 +1,3 @@
Gutenberg
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.