Afegir chequeig extensio .pdf

This commit is contained in:
2021-01-04 11:43:49 +01:00
parent 3625eada74
commit 670fe977c2
2 changed files with 23 additions and 7 deletions

View File

@@ -23,7 +23,7 @@
<TabItem Header="Merge PDF">
<Grid>
<StackPanel>
<Button x:Name="AfegirPdf" Content="Afegir Fitxers" Margin="0,10,0,10" Height="30" Width="180" HorizontalAlignment="Center" Click="SelectOpenFile_Button_Click"/>
<Button x:Name="AfegirPdf" Content="Afegir Fitxers" Margin="0,20,0,10" Height="30" Width="180" HorizontalAlignment="Center" Click="SelectOpenFile_Button_Click"/>
<ListView x:Name="MyListView" Height="190" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<!-- OnMouseOver and IsSeleected hidden effects-->
<ListView.ItemContainerStyle>

View File

@@ -104,6 +104,10 @@ namespace UtilitatPdf
}
else
{
if (Path.GetExtension(FinalPdfFile) != ".pdf")
{
FinalPdfFile += ".pdf";
}
FileInfo currentFile = new FileInfo(FinalPdfFile);
if (currentFile.Exists) File.Delete(FinalPdfFile);
if(list.Count == 1)
@@ -145,11 +149,22 @@ namespace UtilitatPdf
}
else
{
if (ManipulatePdf(InSignFile.Text, OutSignFile.Text))
if (File.Exists(InSignFile.Text))
{
InSignFile.Text = string.Empty;
OutSignFile.Text = string.Empty;
MessageBox.Show("S'ha ocultat el Cif/Nif de les signatures del document.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
if(Path.GetExtension(OutSignFile.Text) != ".pdf")
{
OutSignFile.Text += ".pdf";
}
if (ManipulatePdf(InSignFile.Text, OutSignFile.Text))
{
InSignFile.Text = string.Empty;
OutSignFile.Text = string.Empty;
MessageBox.Show("S'ha ocultat el Cif/Nif de les signatures del document.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
else
{
MessageBox.Show("L'arxiu: "+ InSignFile.Text + " No Existiex.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
@@ -240,7 +255,7 @@ namespace UtilitatPdf
PdfFormXObject form = new PdfFormXObject(new Rectangle(annotationRect.ToRectangle()));
Canvas canvas = new Canvas(form, pdfDocument);
canvas.Add(CreateNewCell(cleanRegex.Replace("\n", "").Replace("\r", "")).SetFontSize(7));
canvas.Add(CreateNewCell(cleanRegex));
pdfWidgetAnnotation.SetNormalAppearance(form.GetPdfObject());
}
@@ -261,7 +276,8 @@ namespace UtilitatPdf
private static Cell CreateNewCell(string texto)
{
Cell celda = new Cell();
Paragraph p = new Paragraph(texto);
texto = texto.Replace("\n", "").Replace("\r", "");
Paragraph p = new Paragraph(texto).SetFontSize(7);
celda.Add(p);
return celda;
}