Read Word file without losing formatting

Asked

Viewed 890 times

1

How to read a Word file without losing formatting the same?

Status: Client wants to upload a Word file and we store all this within the database as text (for future searches and similar).

Note: Using PHP only.

  • Has two ways, can save the file on file system or as blob in database.

  • I never looked how Wordpress does it, but it has a function of paste from Word that can be interesting.

  • 1

    I don’t understand the question, especially given the situation you described. Want to know how to extract text from doc to save in the bank?

  • This however without losing formatting.

  • Ah, so it looks like you want to convert to HTML and save as HTML in the database. There are libraries for this, but it is impossible to ensure that no formatting is lost. A part ends up losing.

1 answer

1

To read without losing formatting, save the record in the database with a field containing the extracted content in plain text format and the original file in a specific location using the registry ID.

Use the field for content searches and if the user wants to recover the file via download you can read the original file by ID and send to it via PHP.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.