Estoy trabajando en una aplicación de WinForms. Yo uso el archivo pdf para restablecer la contraseña y los valores en pdf se almacenan como pares clave-valor(correo electrónico: [email protected], pass: 11111).
Lo que quiero hacer:
Leer el archivo PDF línea por línea y llenar los cuadros de texto apropiado.
Lo que he hecho:
public bool CreatePDF(string location, string email, string key)
{
if(location != "" && email != "" && key != "")
{
PdfWriter pdfwriter = new PdfWriter(location);
PdfDocument pdf = new PdfDocument(pdfwriter);
Document document = new Document(pdf);
Paragraph fields = new Paragraph("Email: "+email + "\n" + "Secret Key: "+key);
document.Add(fields);
document.Close();
return true;
}
else
{
return false;
}
}
public string ReadPDF(string location)
{
var pdfDocument = new PdfDocument(new PdfReader(location));
StringBuilder processed = new StringBuilder();
var strategy = new LocationTextExtractionStrategy();
string text = "";
for (int i = 1; i <= pdfDocument.GetNumberOfPages(); ++i)
{
var page = pdfDocument.GetPage(i);
text += PdfTextExtractor.GetTextFromPage(page, strategy);
processed.Append(text);
}
return text;
}
}
Gracias de antemano Chicos!. Cualquier sugerencia sobre la CreatePDF también son bienvenidos.