Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCX-PDF Conversion #40

Merged
merged 14 commits into from
Mar 22, 2024
Merged

DOCX-PDF Conversion #40

merged 14 commits into from
Mar 22, 2024

Conversation

danvergara
Copy link
Owner

@danvergara danvergara commented Mar 9, 2024

DOCX-PDF

Description

This PR introduces the DOCX-PDF conversion and that means that is possible to convert PDF files to DOCX and the otherwise is also true.
This one was though, because there's no easy way to do this by just using Go or OSS, the best solution out there was using UniDOC but it's proprietary software.

So looking around, I found out that how other projects worked around this limitation, it's basically calling libreoffice. Go's standard library provides a package called os/exec which allows us to runs external commands and that's what I needed to work with libreoffice.

DOCX -> PDF

libreoffice --headless --convert-to pdf:writer_pdf_Export --outdir <out_dir> <foo.docx>

PDF -> DOCX

libreoffice --headless --infilter='writer_pdf_import' --convert-to docx:"MS Word 2007 XML" --outdir <out_dir> <foo.pdf>

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

QA'd this change locally with multiple files and I added more tests.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

@danvergara danvergara self-assigned this Mar 9, 2024
@danvergara danvergara requested review from rdleon and Arturomtz8 March 12, 2024 03:27
@danvergara danvergara added enhancement New feature or request file:document Feature or bugfix that has to do with documents labels Mar 12, 2024
@danvergara danvergara marked this pull request as ready for review March 12, 2024 03:43
Copy link
Collaborator

@rdleon rdleon left a comment

Choose a reason for hiding this comment

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

Did a visual check of the code, looks good. Not so good that you have to add libreoffice just to support this.

@danvergara
Copy link
Owner Author

Did a visual check of the code, looks good. Not so good that you have to add libreoffice just to support this.

Libreoffice was the only Open Source option available. The other one was unidoc which is not Open Source.

@danvergara danvergara merged commit 24d6ac1 into main Mar 22, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request file:document Feature or bugfix that has to do with documents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants