ฉันทำงานอยู่บน WinForms รทำงานของโปรแกรม ผมจะขอใช้ห้องเอกสาร pdf แฟ้มที่จะตั้งค่ารหัสผ่านและค่าต่างๆในเอกสาร pdf จะถูกจัดเก็บไว้เป็นของกุญแจค่าคู่(อีเมล:[email protected] ส่ง:11111).
สิ่งที่ฉันต้องการที่จะทำอย่าง:
อ่านเอกสาร PDF แฟ้มเส้นโดยสายแล้วแทนที่เหมาะสม textboxes.
สิ่งที่ฉันต้องทำ:
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;
}
}
ขอบคุณล่วงหน้าพวกเธอ!. มีข้อเสนอแนะอะไรมั้ย CreatePDF เป็นยังยินดีต้อนรับ