Search code examples
c#asp.netpdfodt

Convert ODT to PDF file in C# ASP.NET (and adding content)


I was wondering what the best way is to convert an ODT file to a PDF while also adding content to that file.

I don't know what routes are possible (library-wise) to make this work:

  1. ODT > edit > PDF
  2. ODT > PDF > edit
  3. ODT > HTML > edit > PDF
  4. ODT > DOC(X) > edit > PDF

The API I'm building is using C# ASP.NET, version 3.1. I have been looking for multiple hours what the best way is to get started on this but I'm really struggling to find the right library. I never really used too many libraries before so I don't know where to look and what I exactly need. I tried looking on NuGet packages in Visual Studio 2019 but none seem to work with ODT but DOCX or HTML. Anyone that has experience with this and could tell me on what I should do?


Solution

  • The solution I found is:

    • Convert my .odt files to .html files using cloudconvert. This can also be done in batches. However, you might have to do this manually.
    • Use Html Agility Pack to edit the .html files before making them .pdf files.
    • Use iText7 with the pdfHTML extension to generate my PDF files from the .html files.