Hướng dẫn decode docx file python
I am trying to encode docx file and decode/pass it on frontend/UI in streamlit. As of now i knew how to encode/decode strings using base64 but not with docx file. Show
If any of you guys have any code on how to achieve it. Please do share here.
I used the above code but not getting the desired result. Instead I got collection of .xml file. As shown in the below screenshot The supposed decoded document should look like this.. If you guys need the docx file that i am trying to encode/decode, here is the link https://docs.google.com/document/d/10zkg1HLDHhZNh83i2tbJqBVMfIsdqW-3/edit asked Aug 3 at 8:09
You need to add
answered Aug 3 at 8:23
AnhPC03AnhPC03 5773 silver badges13 bronze badges 8 This is just encoding You Have to Decode
open the file using open('Your Data file', 'rb'). Note how we passed the 'rb' argument along with the file path - this tells Python that we are reading a binary file. Without using 'rb', Python would assume we are reading a text file. use the read() method to get all the data in the file into the binary_file_data variable. Similar to how we treated strings, we Base64 encoded the bytes with base64.b64encode and then used the decode('utf-8') on base64_encoded_data to get the Base64 encoded data using human-readable characters. Executing the code will produce similar output to:
answered Aug 3 at 9:10
1 Aspose.Total Product FamilyEnable your applications to manipulate more than 100 file formats. Includes all of our 67 individual products. Aspose.Words Product FamilyCreate, edit, convert or print Word documents in your application. Includes 8 individual products for various platforms. Aspose.PDF Product FamilyCreate, edit or convert PDF documents in your application. Includes 7 individual products for various platforms. Aspose.Cells Product FamilyCreate, edit or convert Excel spreadsheets in your application. Includes 10 individual products for various platforms. Aspose.Email Product FamilyManipulate Outlook files and email protocols in your application. Includes 6 individual products for various platforms. Aspose.Slides Product FamilyCreate, edit or convert PowerPoint presentations in your application. Includes 9 individual products for various platforms. Aspose.Imaging Product FamilyCreate, process and convert images in your application. Includes 4 individual products for various platforms. Aspose.BarCode Product FamilyGenerate and Recognize 1D, 2D and postal barcodes in your application. Includes 10 individual products for various platforms. Aspose.Diagram Product FamilyCreate, edit, convert and print Microsoft Visio documents in your applications. Includes 4 individual products for various platforms. Aspose.Tasks Product FamilyCreate, edit, convert and print Microsoft Project documents in your applications. Includes 3 individual products for various platforms. Aspose.OCR Product FamilyPerform OCR for English, French, Spanish and Portuguese languages in your applications. Includes 3 individual products for various platforms. Aspose.Note Product FamilyCreate, edit and convert Microsoft OneNote documents in your applications. Includes 2 individual products for .NET and Java platforms. Aspose.CAD Product FamilyConvert AutoCAD DWG and DXF files to PDF and raster images in your applications. Includes 3 individual products for .NET, Java & JasperReports. Aspose.3D Product FamilyCreate, edit and convert 3D documents in your own applications. Includes 3 individual products for .NET and Java platforms. Aspose.HTML Product FamilyManipulate HTML files including CSS or render to PDF and raster image formats within your applications. Includes 2 individual products for .NET and Java platforms. Aspose.GIS Product FamilyCreate, edit and convert GIS file formats in your application. Currently available for .NET platform only. Aspose.ZIP Product FamilyCompress archives and files into zip format as well as extract zip files to its respective folders and documents. Currently available for .NET platform only. Aspose.Page Product FamilyCreate or manipulate XPS files and convert XPS, PS and EPS files to PDF and image formats in your application. Currently available for the following platforms. Aspose.PSD Product FamilyLoad, create or edit Photoshop PSD and PSB files in your application. Currently available for .NET and Java platforms only. Aspose.OMR Product FamilyRecognize optical marks from OMR digitized sheet images in a variety of image formats like BMP, JPG, TIF and more. Aspose.PUB Product FamilyCreate, Parse and Convert Publisher PUB format to PDF documents. Currently available for .NET and C++ platforms. Aspose.SVG Product FamilyLoad, Parse and Render SVG file to multiple formats including PDF, XPS, and images. Currently available for .NET platform only. Aspose.Finance Product FamilyCreate and read finance-related formats such as XBRL, iXBRL, OFX formats for business reporting solutions containing financial statements, financial and non-financial information, regulatory filings, and much more. Aspose.Drawing Product Family2D graphics rendering API identical to GDI+ capabilities to render vector graphics such as arcs, curves, ellipses, lines, and more as well as multi-style text. Currently available for .NET platform only. Aspose.Font Product FamilyLoad, draw and save multiple font formats including CFF, TTF, TrueType, OpenType and Type1 fonts. Currently available for .NET, Java and C++ platforms. Aspose.TeX Product FamilyTypeset TeX files. Currently available for .NET, Java and C++ platforms. |