# Having issues embedding powerpoint into my Dash app -- embedding powerpoint -- Please help!

**URL:** <https://community.plotly.com/t/having-issues-embedding-powerpoint-into-my-dash-app-embedding-powerpoint-please-help/73709>\
**Category:** Dash Python\
**Created:** [March 20, 2023, 2:06am UTC](https://community.plotly.com/t/having-issues-embedding-powerpoint-into-my-dash-app-embedding-powerpoint-please-help/73709 "2023-03-20T02:06:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marlainna456](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@marlainna456](https://community.plotly.com/u/marlainna456)\
**Post date:** [March 20, 2023, 2:06am UTC](https://community.plotly.com/t/having-issues-embedding-powerpoint-into-my-dash-app-embedding-powerpoint-please-help/73709/1 "2023-03-20T02:06:25Z")

</div>

```python
from dash import Dash , html , dcc , Input , Output , State , no_update
import pandas as pd
import base64
from PIL import Image
import dash_bootstrap_components as dbc
from pptx import Presentation
import io
 

date_data = pd.read_csv( "dates_data.csv" )

app = Dash( __name__ )
server = app.server

#############################
 
slides_item = html.Div(
    [
        html.Div(
            html.Div(
                [
                    html.Div( [
                            html.H5(
                            'Slides' ,
                            style={
                                'backgroundColor': 'white' ,
                                'fontFamily': 'verdana' ,
                                # 'textAlign':'center',
                                'gridArea': "slide_header"

                                }
                            ) ,
                        html.A("Download PPT",href="/download_ppt/") ,
                        # using the pillow image variable

                        ], id='excel' ) ,
                    html.Div( className="sidebar-wrapper" ) ,
                    ]
                ) ,
            className="sidebar" ,
            ) ,
        html.Div(
            html.Div(
                html.Div( className="container-fluid" ) ,
                className="navbar navbar-expand-lg navbar-transparent navbar-absolute fixed-top " ,
                ) ,
            className="main-panel" ,
            ) ,
        ] , id="slides_id"
    )
slides_item.style = {'gridArea': "slides_ga"}

 app.layout = html.Div( [
      dbc.Row ( [dbc.Col(slides_item, width=11)], justify="around"),

 #call;backs area
##############################

@app.server.route("/download_ppt/")
def download_ppt():
    #if path.exists( "Presentation1.pptx" ):
        with open(r'Presentation1.pptx') as f:
            source = f.read()
        prs=Presentation('Presentation1.pptx')
        f.close()
        filename = io.StringIO()
        prs.save(filename)
        filename.seek(0)
        return send_file(
            filename,
            mimetype='application/vnd.openxmlformats-officedocument.presentationml.presentation',
            attachment_filename="Presentation1.pptx",
            as_attachment=True,

            )

@app.callback(
    Output( "pred-graph" , "figure" ) ,
    Input( "pred-table-tabs" , "value" )
    )
def change_pred_graph(group):
    if group == "predsatisfied":
        return return_type_prediction_subplots( Pred_Satisfied_df , 4 )
    elif group == "predhigh_maint":
        return return_type_prediction_subplots( Pred_High_Maintenance_df , 0 )
    elif group == "preddissatisfied":
        return return_type_prediction_subplots( Pred_dissatisfied_df , 1 )
    elif group == "predloyalist":
        return return_type_prediction_subplots( Pred_Loyalist_df , 3 )
    else:
        return return_type_prediction_subplots( Pred_Potential_Loyalist_df , 2 )

```

```auto
ERROR:

# UnicodeDecodeError

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 640: character maps to <undefined>

## Traceback *(most recent call last)*

* #### File "C:\Users\Everydayuse\PycharmProjects\new_capstone_01\env\lib\site-packages\flask\app.py", line *1823*, in `full_dispatch_request`

rv = self.dispatch_request()

* #### File "C:\Users\Everydayuse\PycharmProjects\new_capstone_01\env\lib\site-packages\flask\app.py", line *1799*, in `dispatch_request`

return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)

* #### File "C:\Users\Everydayuse\PycharmProjects\mfrancis_capstone\src\app.py", line *1947*, in `download_ppt`

source = f.read()

* #### File "C:\Users\Everydayuse\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line *23*, in `decode`

return codecs.charmap_decode(input,self.errors,decoding_table)[0]

> UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 640: character maps to <undefined>

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

* `dump()` shows all variables in the frame
* `dump(obj)` dumps all that's known about the object

```

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [March 20, 2023, 11:58am UTC](https://community.plotly.com/t/having-issues-embedding-powerpoint-into-my-dash-app-embedding-powerpoint-please-help/73709/2 "2023-03-20T11:58:11Z")

</div>

HI @marlainna456 could you please format your code for better readability?

> [@mega How to provide your sample code in right format](https://community.plotly.com/t/how-to-provide-your-sample-code-in-right-format/27641):
>
> Hello Community, we found a lot of new posts with sample code are rendered in a pretty bad format: incorrect indent and punctuations in a different encoding, etc. there is no secret but a simple markdown trick your code should be included between two ```, the first one followed by language like python , without the ending comment #part ```python print("Hello Markdown") ``` # show the escaped ending

---

<div class="post-metadata">

**Author:** ![marlainna456](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@marlainna456](https://community.plotly.com/u/marlainna456)\
**Post date:** [March 20, 2023, 2:02pm UTC](https://community.plotly.com/t/having-issues-embedding-powerpoint-into-my-dash-app-embedding-powerpoint-please-help/73709/3 "2023-03-20T14:02:01Z")

</div>

I am so sorry about the format. I tried to format it but it still come out bad… so sorry
