Update app.py via AI Editor
Browse files
app.py
CHANGED
|
@@ -130,7 +130,6 @@ def intelligent_pdf_split(input_path, session_dir, max_mb=5, min_split_mb=4):
|
|
| 130 |
for idx, (start, end) in enumerate(splits):
|
| 131 |
writer = PdfWriter()
|
| 132 |
for p in range(start, end):
|
| 133 |
-
# Add only the required page references; this avoids resource bloat
|
| 134 |
writer.add_page(reader.pages[p])
|
| 135 |
out_path = os.path.join(session_dir, f'split_part_{idx+1}.pdf')
|
| 136 |
with open(out_path, 'wb') as f:
|
|
@@ -219,13 +218,27 @@ app.layout = dbc.Container(
|
|
| 219 |
accept='.pdf'
|
| 220 |
),
|
| 221 |
html.Div(id='file-info', className='mb-4'),
|
| 222 |
-
dbc.
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
dcc.Loading(
|
| 230 |
id="loading", type="default",
|
| 231 |
children=[html.Div(id='split-results', children=get_split_results_placeholder())]
|
|
|
|
| 130 |
for idx, (start, end) in enumerate(splits):
|
| 131 |
writer = PdfWriter()
|
| 132 |
for p in range(start, end):
|
|
|
|
| 133 |
writer.add_page(reader.pages[p])
|
| 134 |
out_path = os.path.join(session_dir, f'split_part_{idx+1}.pdf')
|
| 135 |
with open(out_path, 'wb') as f:
|
|
|
|
| 218 |
accept='.pdf'
|
| 219 |
),
|
| 220 |
html.Div(id='file-info', className='mb-4'),
|
| 221 |
+
dbc.Row([
|
| 222 |
+
dbc.Col(
|
| 223 |
+
dbc.Button(
|
| 224 |
+
"Split PDF", id='split-btn',
|
| 225 |
+
color='primary',
|
| 226 |
+
style={'width': '180px', 'fontWeight': 'bold'},
|
| 227 |
+
n_clicks=0,
|
| 228 |
+
disabled=True
|
| 229 |
+
),
|
| 230 |
+
width="auto"
|
| 231 |
+
),
|
| 232 |
+
dbc.Col(
|
| 233 |
+
dbc.Button(
|
| 234 |
+
"Clear Session", id='clear-session',
|
| 235 |
+
color='secondary',
|
| 236 |
+
n_clicks=0,
|
| 237 |
+
className='ms-3'
|
| 238 |
+
),
|
| 239 |
+
width="auto"
|
| 240 |
+
),
|
| 241 |
+
], className='mb-3 mt-2', align='center', justify='start'),
|
| 242 |
dcc.Loading(
|
| 243 |
id="loading", type="default",
|
| 244 |
children=[html.Div(id='split-results', children=get_split_results_placeholder())]
|