jussiniinikoski / wasm-pdf

Generate PDF files with JavaScript and WASM (WebAssembly)
Apache License 2.0
480 stars 52 forks source link

Are there any way to convert from DOC to JSON? #19

Open byteshiva opened 3 years ago

byteshiva commented 3 years ago

I have some Word DOC files from which I'd like to generate Pdf on the client side. Is it possible to generate the JSON as per the wasm-pdf structure?

jussiniinikoski commented 3 years ago

Hi there! Unfortunately wasm-pdf doesn't have that capability. Microsoft has this tool but it's written in Python.

byteshiva commented 3 years ago

Hi there! Unfortunately wasm-pdf doesn't have that capability. Microsoft has this tool but it's written in Python.

Thanks,

I converted a Docx file to JSON using simplify_docx, but it's not conforming to the JSON structure defined in wasm-pdf? Am I missing something here?

The conversion of Docx to JSON using simplify-docx gave the below structure.

Here is a partial JSON structure converted using simplify_docx

{
  "TYPE": "document",
  "VALUE": [
    {
      "TYPE": "body",
      "VALUE": [
        {
          "TYPE": "table",
          "VALUE": [
            {
              "TYPE": "table-row",
              "VALUE": [
                {
                  "TYPE": "table-cell",
                  "VALUE": [
                    {
                      "TYPE": "paragraph",
                      "VALUE": [
                        {
                          "TYPE": "text",
                          "VALUE": "sample text1"
                        }
                      ]
                    }
                  ]
                },
                {
                  "TYPE": "table-cell",
                  "VALUE": [
                    {
                      "TYPE": "paragraph",
                      "VALUE": [
                        {
                          "TYPE": "text",
                          "VALUE": "Mobile:"
                        }
                      ]
                    }
                  ]
                },
                {
                  "TYPE": "table-cell",
                  "VALUE": [
                    {
                      "TYPE": "paragraph",
                      "VALUE": [
                        {
                          "TYPE": "text",
                          "VALUE": " 1111111111"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
jussiniinikoski commented 3 years ago

Yes, you'll have to process this JSON data into a format that works with wasm-pdf. This you can do with JavaScript, take a look at the examples.

byteshiva commented 3 years ago

Yes, you'll have to process this JSON data into a format that works with wasm-pdf. This you can do with JavaScript, take a look at the examples.

Thanks, I'll try converting to format that works that with wasm-pdf.