fschwartzer commited on
Commit
be500fb
·
verified ·
1 Parent(s): e3d76aa

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +15 -15
src/app.py CHANGED
@@ -170,40 +170,40 @@ def create_pdf_report(user_data):
170
  def create_docx_report(user_data):
171
  doc = Document()
172
 
173
- # --- Inserir Logos no topo, lado a lado se existirem ---
174
- # Cria uma tabela com 1 linha, 2 colunas para os logos, para alinhá-los
175
- table = doc.add_table(rows=1, cols=2)
176
  table.autofit = False
177
- widths = [Inches(2), Inches(2)] # ajuste largura das colunas
178
-
179
  for i, width in enumerate(widths):
180
  table.columns[i].width = width
181
 
182
- # Logo 1: 'src/logo_pref.png'
183
  if os.path.exists('src/logo_pref.png'):
184
- cell_logo_pref = table.cell(0,0)
185
  paragraph = cell_logo_pref.paragraphs[0]
186
  run = paragraph.add_run()
187
  run.add_picture('src/logo_pref.png', width=Inches(2))
188
  paragraph.alignment = WD_ALIGN_PARAGRAPH.LEFT
189
 
190
- # Logo 2: 'src/logo_receita.png'
191
  if os.path.exists('src/logo_receita.png'):
192
- cell_logo_receita = table.cell(0,1)
193
  paragraph = cell_logo_receita.paragraphs[0]
194
  run = paragraph.add_run()
195
  run.add_picture('src/logo_receita.png', width=Inches(1.75))
196
  paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
197
 
198
- doc.add_paragraph() # espaço depois dos logos
199
-
200
- # --- Cabeçalho texto à direita (igual PDF) ---
201
- p = doc.add_paragraph()
202
- p.alignment = WD_ALIGN_PARAGRAPH.RIGHT
203
- run = p.add_run("DAI-ESJL\nDivisão de Avaliação de Imóveis\nEquipe de Suporte, Judiciais e Locações")
204
  font = run.font
205
  font.size = Pt(8)
206
  font.bold = True
 
 
 
 
207
 
208
  # Número do processo (abaixo do cabeçalho)
209
  p_proc = doc.add_paragraph(f"PROCESSO {user_data.get('processo_numero','')}")
 
170
  def create_docx_report(user_data):
171
  doc = Document()
172
 
173
+ # --- Criar uma tabela de 1 linha e 3 colunas para o cabeçalho ---
174
+ table = doc.add_table(rows=1, cols=3)
 
175
  table.autofit = False
176
+ widths = [Inches(2), Inches(2), Inches(4)] # Ajustar larguras das colunas
 
177
  for i, width in enumerate(widths):
178
  table.columns[i].width = width
179
 
180
+ # --- Logo 1: 'src/logo_pref.png' à esquerda ---
181
  if os.path.exists('src/logo_pref.png'):
182
+ cell_logo_pref = table.cell(0, 0)
183
  paragraph = cell_logo_pref.paragraphs[0]
184
  run = paragraph.add_run()
185
  run.add_picture('src/logo_pref.png', width=Inches(2))
186
  paragraph.alignment = WD_ALIGN_PARAGRAPH.LEFT
187
 
188
+ # --- Logo 2: 'src/logo_receita.png' ao centro ---
189
  if os.path.exists('src/logo_receita.png'):
190
+ cell_logo_receita = table.cell(0, 1)
191
  paragraph = cell_logo_receita.paragraphs[0]
192
  run = paragraph.add_run()
193
  run.add_picture('src/logo_receita.png', width=Inches(1.75))
194
  paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
195
 
196
+ # --- Texto à direita (cabeçalho) ---
197
+ cell_text = table.cell(0, 2)
198
+ paragraph = cell_text.paragraphs[0]
199
+ run = paragraph.add_run("DAI-ESJL\nDivisão de Avaliação de Imóveis\nEquipe de Suporte, Judiciais e Locações")
 
 
200
  font = run.font
201
  font.size = Pt(8)
202
  font.bold = True
203
+ paragraph.alignment = WD_ALIGN_PARAGRAPH.RIGHT
204
+
205
+ # --- Adicionar um parágrafo vazio para dar espaço após os logos e o cabeçalho ---
206
+ doc.add_paragraph()
207
 
208
  # Número do processo (abaixo do cabeçalho)
209
  p_proc = doc.add_paragraph(f"PROCESSO {user_data.get('processo_numero','')}")