Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -480,32 +480,39 @@ theme = gr.themes.Base(
|
|
| 480 |
|
| 481 |
with gr.Blocks(theme=theme, title="The PDF Alchemist") as demo:
|
| 482 |
gr.Markdown("# โจ The PDF Alchemist โจ")
|
| 483 |
-
gr.Markdown("
|
| 484 |
|
| 485 |
with gr.Row(equal_height=False):
|
|
|
|
| 486 |
with gr.Column(scale=2):
|
| 487 |
-
with gr.
|
| 488 |
-
with gr.
|
| 489 |
-
gr.Markdown("### ๐ค
|
| 490 |
-
ai_prompt = gr.Textbox(label="
|
| 491 |
generate_ai_btn = gr.Button("๐ง Animate Golem!")
|
| 492 |
-
ai_content_output = gr.Textbox(label="Golem's Manuscript (Editable)", lines=
|
| 493 |
-
|
| 494 |
-
gr.Markdown("
|
|
|
|
|
|
|
| 495 |
uploaded_files = gr.File(label="Upload Files (Images, PDFs, TXT)", file_count="multiple", file_types=['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.tiff', '.pdf', '.txt'])
|
| 496 |
-
gr.Markdown("*<p style='font-size:0.8rem; color: #9ca3af;'>
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
|
|
|
| 500 |
selected_layouts = gr.CheckboxGroup(choices=list(LAYOUTS.keys()), label="Page Layouts", value=["A4 Portrait"])
|
| 501 |
num_columns_slider = gr.Slider(label="Number of Text Columns", minimum=1, maximum=4, step=1, value=1)
|
| 502 |
|
| 503 |
-
gr.Markdown("
|
|
|
|
|
|
|
| 504 |
gr.Markdown("<p style='font-size:0.8rem; color: #9ca3af;'>Use `[Page #]` and `[Title]`. `[Total Pages]` works best in the footer.</p>")
|
| 505 |
header_input = gr.Textbox(label="Header Inscription", value="[Title]", placeholder="e.g., Arcane Folio - [Page #]")
|
| 506 |
footer_input = gr.Textbox(label="Footer Inscription", value="Page [Page #] of [Total Pages]", placeholder="e.g., Top Secret - Page [Page #]")
|
| 507 |
-
|
| 508 |
-
|
|
|
|
| 509 |
gr.Markdown("### ๐ค Master the Glyphs")
|
| 510 |
selected_fonts = gr.CheckboxGroup(choices=AVAILABLE_FONTS, label="Fonts", value=[AVAILABLE_FONTS[0]] if AVAILABLE_FONTS else [])
|
| 511 |
font_size_body_slider = gr.Slider(label="Body Text Size (pt)", minimum=8, maximum=16, step=1, value=10)
|
|
@@ -513,6 +520,8 @@ with gr.Blocks(theme=theme, title="The PDF Alchemist") as demo:
|
|
| 513 |
font_size_h1_slider = gr.Slider(label="H1 Size", minimum=16, maximum=32, step=1, value=24)
|
| 514 |
font_size_h2_slider = gr.Slider(label="H2 Size", minimum=14, maximum=28, step=1, value=18)
|
| 515 |
font_size_h3_slider = gr.Slider(label="H3 Size", minimum=12, maximum=24, step=1, value=14)
|
|
|
|
|
|
|
| 516 |
|
| 517 |
gr.Markdown("### ๐ Set Your Boundaries (inches)")
|
| 518 |
with gr.Row():
|
|
@@ -522,8 +531,10 @@ with gr.Blocks(theme=theme, title="The PDF Alchemist") as demo:
|
|
| 522 |
margin_left_slider = gr.Slider(label="Left", minimum=0.25, maximum=1.5, step=0.05, value=0.75)
|
| 523 |
margin_right_slider = gr.Slider(label="Right", minimum=0.25, maximum=1.5, step=0.05, value=0.75)
|
| 524 |
|
|
|
|
| 525 |
generate_pdfs_btn = gr.Button("๐ฎ Alchemize PDF!", variant="primary", size="lg")
|
| 526 |
|
|
|
|
| 527 |
with gr.Column(scale=3):
|
| 528 |
gr.Markdown("### ๐ผ๏ธ The Scrying Pool (Previews)")
|
| 529 |
gallery_output = gr.Gallery(label="Generated PDF Previews", show_label=False, elem_id="gallery", columns=2, height=700, object_fit="contain")
|
|
|
|
| 480 |
|
| 481 |
with gr.Blocks(theme=theme, title="The PDF Alchemist") as demo:
|
| 482 |
gr.Markdown("# โจ The PDF Alchemist โจ")
|
| 483 |
+
gr.Markdown("A single-page grimoire to turn your ideas into beautifully crafted PDF scrolls. Use the power of AI or upload your own treasures.")
|
| 484 |
|
| 485 |
with gr.Row(equal_height=False):
|
| 486 |
+
# --- LEFT COLUMN: INPUTS & CONTROLS ---
|
| 487 |
with gr.Column(scale=2):
|
| 488 |
+
with gr.Group():
|
| 489 |
+
with gr.Accordion("๐ Content Crucible (Your Ingredients)", open=True):
|
| 490 |
+
gr.Markdown("### ๐ค Command Your Idea Golem")
|
| 491 |
+
ai_prompt = gr.Textbox(label="Incantation (Prompt)", placeholder="e.g., 'A recipe for a dragon's breath chili...'")
|
| 492 |
generate_ai_btn = gr.Button("๐ง Animate Golem!")
|
| 493 |
+
ai_content_output = gr.Textbox(label="Golem's Manuscript (Editable)", lines=10, interactive=True, value="# The Golem awaits your command!\n\n")
|
| 494 |
+
|
| 495 |
+
gr.Markdown("<hr style='border-color: #374151; margin-top: 20px; margin-bottom: 20px;'>")
|
| 496 |
+
|
| 497 |
+
gr.Markdown("### ๐ค Add Your Physical Treasures")
|
| 498 |
uploaded_files = gr.File(label="Upload Files (Images, PDFs, TXT)", file_count="multiple", file_types=['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.tiff', '.pdf', '.txt'])
|
| 499 |
+
gr.Markdown("*<p style='font-size:0.8rem; color: #9ca3af;'>The Golem's manuscript and .txt files are combined. Images and PDF pages are appended after the text.</p>*")
|
| 500 |
+
|
| 501 |
+
with gr.Group():
|
| 502 |
+
with gr.Accordion("๐ Arcane Blueprints (Layout & Structure)", open=True):
|
| 503 |
+
gr.Markdown("### Page & Column Spells")
|
| 504 |
selected_layouts = gr.CheckboxGroup(choices=list(LAYOUTS.keys()), label="Page Layouts", value=["A4 Portrait"])
|
| 505 |
num_columns_slider = gr.Slider(label="Number of Text Columns", minimum=1, maximum=4, step=1, value=1)
|
| 506 |
|
| 507 |
+
gr.Markdown("<hr style='border-color: #374151; margin-top: 20px; margin-bottom: 20px;'>")
|
| 508 |
+
|
| 509 |
+
gr.Markdown("### Header & Footer Runes")
|
| 510 |
gr.Markdown("<p style='font-size:0.8rem; color: #9ca3af;'>Use `[Page #]` and `[Title]`. `[Total Pages]` works best in the footer.</p>")
|
| 511 |
header_input = gr.Textbox(label="Header Inscription", value="[Title]", placeholder="e.g., Arcane Folio - [Page #]")
|
| 512 |
footer_input = gr.Textbox(label="Footer Inscription", value="Page [Page #] of [Total Pages]", placeholder="e.g., Top Secret - Page [Page #]")
|
| 513 |
+
|
| 514 |
+
with gr.Group():
|
| 515 |
+
with gr.Accordion("๐
Stylist's Sanctum (Fonts & Margins)", open=True):
|
| 516 |
gr.Markdown("### ๐ค Master the Glyphs")
|
| 517 |
selected_fonts = gr.CheckboxGroup(choices=AVAILABLE_FONTS, label="Fonts", value=[AVAILABLE_FONTS[0]] if AVAILABLE_FONTS else [])
|
| 518 |
font_size_body_slider = gr.Slider(label="Body Text Size (pt)", minimum=8, maximum=16, step=1, value=10)
|
|
|
|
| 520 |
font_size_h1_slider = gr.Slider(label="H1 Size", minimum=16, maximum=32, step=1, value=24)
|
| 521 |
font_size_h2_slider = gr.Slider(label="H2 Size", minimum=14, maximum=28, step=1, value=18)
|
| 522 |
font_size_h3_slider = gr.Slider(label="H3 Size", minimum=12, maximum=24, step=1, value=14)
|
| 523 |
+
|
| 524 |
+
gr.Markdown("<hr style='border-color: #374151; margin-top: 20px; margin-bottom: 20px;'>")
|
| 525 |
|
| 526 |
gr.Markdown("### ๐ Set Your Boundaries (inches)")
|
| 527 |
with gr.Row():
|
|
|
|
| 531 |
margin_left_slider = gr.Slider(label="Left", minimum=0.25, maximum=1.5, step=0.05, value=0.75)
|
| 532 |
margin_right_slider = gr.Slider(label="Right", minimum=0.25, maximum=1.5, step=0.05, value=0.75)
|
| 533 |
|
| 534 |
+
# --- Main Generate Button ---
|
| 535 |
generate_pdfs_btn = gr.Button("๐ฎ Alchemize PDF!", variant="primary", size="lg")
|
| 536 |
|
| 537 |
+
# --- RIGHT COLUMN: OUTPUTS ---
|
| 538 |
with gr.Column(scale=3):
|
| 539 |
gr.Markdown("### ๐ผ๏ธ The Scrying Pool (Previews)")
|
| 540 |
gallery_output = gr.Gallery(label="Generated PDF Previews", show_label=False, elem_id="gallery", columns=2, height=700, object_fit="contain")
|