karthikmn commited on
Commit
d2124d2
·
verified ·
1 Parent(s): 2dd2de3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -36,7 +36,7 @@ def convert_pdf_to_svg(input_pdf, output_svg, width, height):
36
  return False
37
 
38
  # Gradio interface function
39
- def process_pdf(uploaded_file, brightness, text_scale, line_scale, width, height):
40
  try:
41
  # Save uploaded file
42
  input_pdf = os.path.join(INPUT_FOLDER, "uploaded_file.pdf")
@@ -45,15 +45,10 @@ def process_pdf(uploaded_file, brightness, text_scale, line_scale, width, height
45
 
46
  # Step 1: Convert PDF to SVG
47
  if convert_pdf_to_svg(input_pdf, SVG_OUTPUT, width, height):
48
- # Step 2: Apply transformations to the SVG (this can be customized)
49
- # Assuming `apply_transformations` function exists for SVG processing
50
-
51
- apply_transformations(SVG_OUTPUT, brightness, text_scale, line_scale)
52
-
53
- # Step 3: Convert SVG to PDF (assuming `convert_svg_to_pdf` exists)
54
  convert_svg_to_pdf(SVG_OUTPUT, PDF_OUTPUT)
55
 
56
- # Step 4: Log the process
57
  log_conversion("Success", input_pdf, SVG_OUTPUT, PDF_OUTPUT)
58
 
59
  # Return output files for download
@@ -65,14 +60,11 @@ def process_pdf(uploaded_file, brightness, text_scale, line_scale, width, height
65
  log_conversion("Failed", input_pdf, SVG_OUTPUT, PDF_OUTPUT)
66
  return str(e)
67
 
68
- # Gradio interface setup
69
  inputs = [
70
  gr.File(label="Upload your PDF file", type="filepath"),
71
- gr.Slider(minimum=0.5, maximum=5.0, step=0.5, value=1.0, label="Brightness (0.5 to 5.0)"), # Updated here
72
- gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.0, label="Text Size Scale (0.5 to 2.0)"), # Updated here
73
- gr.Slider(minimum=0.5, maximum=5.0, step=0.5, value=1.0, label="Line Thickness Scale (0.5 to 5.0)"), # Updated here
74
- gr.Number(value=8.0, label="Width (in inches)", precision=1), # Updated here: precision set to 1
75
- gr.Number(value=11.0, label="Height (in inches)", precision=1) # Updated here: precision set to 1
76
  ]
77
 
78
  outputs = [
 
36
  return False
37
 
38
  # Gradio interface function
39
+ def process_pdf(uploaded_file, width, height):
40
  try:
41
  # Save uploaded file
42
  input_pdf = os.path.join(INPUT_FOLDER, "uploaded_file.pdf")
 
45
 
46
  # Step 1: Convert PDF to SVG
47
  if convert_pdf_to_svg(input_pdf, SVG_OUTPUT, width, height):
48
+ # Step 2: Convert SVG to PDF (assuming `convert_svg_to_pdf` exists)
 
 
 
 
 
49
  convert_svg_to_pdf(SVG_OUTPUT, PDF_OUTPUT)
50
 
51
+ # Step 3: Log the process
52
  log_conversion("Success", input_pdf, SVG_OUTPUT, PDF_OUTPUT)
53
 
54
  # Return output files for download
 
60
  log_conversion("Failed", input_pdf, SVG_OUTPUT, PDF_OUTPUT)
61
  return str(e)
62
 
63
+ # Gradio interface setup (only Width and Height)
64
  inputs = [
65
  gr.File(label="Upload your PDF file", type="filepath"),
66
+ gr.Number(value=8.0, label="Width (in inches)", precision=1), # Width input in inches
67
+ gr.Number(value=11.0, label="Height (in inches)", precision=1) # Height input in inches
 
 
 
68
  ]
69
 
70
  outputs = [