public static string GetSelectOptionsString(this AcroFieldProperties acroFieldProps) { string selectOptions = acroFieldProps.SelectOptions.Any() ? "[ " + string.Join(" ", acroFieldProps.SelectOptions) + " ]" : string.Empty; return(selectOptions); }
private static PdfPTable CreateAcroFieldNameTable(AcroFieldProperties acroFieldProperties) { string nameWithOptions = acroFieldProperties.Name + " " + acroFieldProperties.GetSelectOptionsString(); PdfPTable table = CreateTable(200f); PdfPCell cell = CreateCell(nameWithOptions); table.AddCell(cell); return(table); }
public override void AddContent(ExcelWorksheet worksheet) { var acroFieldsFirstPdf = reportModel.AcroFieldsFirstPdf; var acroFieldsSecondPdf = reportModel.AcroFieldsSecondPdf; List <Tuple <string, int> > referentAcroFields = acroFieldsFirstPdf.Select(x => x.Key).Union(acroFieldsSecondPdf.Select(x => x.Key)).ToList(); int rowId = 1; rowId = CreateHeader(worksheet, rowId); foreach (Tuple <string, int> referentAcroField in referentAcroFields) { rowId++; int columnId = 1; AcroFieldProperties acroFieldPropsFirstPdf = acroFieldsFirstPdf.GetValueOrDefault(referentAcroField); AcroFieldProperties acroFieldPropsSecondPdf = acroFieldsSecondPdf.GetValueOrDefault(referentAcroField); if (acroFieldPropsFirstPdf != null && acroFieldPropsSecondPdf != null) { worksheet.Cells[rowId, columnId++].SetValue(acroFieldPropsFirstPdf.With(x => x.Name)); worksheet.Cells[rowId, columnId++].SetValue(acroFieldPropsFirstPdf.With(x => x.PageNumber)); worksheet.Cells[rowId, columnId++].SetValue(Constants.FieldOk); worksheet.Cells[rowId, columnId].SetValue(Constants.FieldOk); } else if (acroFieldPropsFirstPdf != null) { worksheet.Cells[rowId, columnId++].SetValue(acroFieldPropsFirstPdf.With(x => x.Name)); worksheet.Cells[rowId, columnId++].SetValue(acroFieldPropsFirstPdf.With(x => x.PageNumber)); worksheet.Cells[rowId, columnId].SetValue(Constants.FieldRemoved); ExcelRange excelRange = worksheet.Cells[rowId, 1, rowId, 4]; excelRange.SetColor(Color.OrangeRed); } else if (CheckHelper.IsFilled(acroFieldPropsSecondPdf)) { worksheet.Cells[rowId, columnId++].SetValue(acroFieldPropsSecondPdf.With(x => x.Name)); worksheet.Cells[rowId, columnId++].SetValue(acroFieldPropsSecondPdf.With(x => x.PageNumber)); worksheet.Cells[rowId, columnId + 1].SetValue(Constants.FieldAdded); ExcelRange excelRange = worksheet.Cells[rowId, 1, rowId, 4]; excelRange.SetColor(Color.LimeGreen); } else { throw new Exception("Unexpected acro field"); } } worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); }
public static Dictionary <Tuple <string, int>, AcroFieldProperties> GetAcroFields(string fileName, int pageNumber) { Dictionary <Tuple <string, int>, AcroFieldProperties> acroFields = new Dictionary <Tuple <string, int>, AcroFieldProperties>(); PdfReader pdfReader = new PdfReader(fileName); if (pageNumber > 0 && pageNumber <= pdfReader.NumberOfPages) { pdfReader.SelectPages(pageNumber.ToString()); AcroFields pdfForm = pdfReader.AcroFields; foreach (string acroFieldName in pdfForm.Fields.Keys) { AcroFieldProperties acroFieldProperties = GetAcroFieldProperties(pdfForm, acroFieldName, pageNumber); acroFields.Add(new Tuple <string, int>(acroFieldName, pageNumber), acroFieldProperties); } } pdfReader.Close(); return(acroFields); }
public static string GetAlignmentString(this AcroFieldProperties acroFieldProps) { string alignmentName = alignmentDict.GetValueOrDefault(acroFieldProps.Text.Alignment); return(alignmentName); }
public static string GetFieldTypeString(this AcroFieldProperties acroFieldProps) { string fieldTypeName = fieldTypeDict.GetValueOrDefault(acroFieldProps.Type); return(fieldTypeName); }
public static bool IsRadioButton(this AcroFieldProperties acroFieldProps) { return(acroFieldProps.Type == AcroFields.FIELD_TYPE_RADIOBUTTON); }
public static bool IsCheckBox(this AcroFieldProperties acroFieldProps) { return(acroFieldProps.Type == AcroFields.FIELD_TYPE_CHECKBOX); }