पढ़ें पीडीएफ लाइन से लाइन का उपयोग कर iText7 और भरने पर बक्सें Winforms

0

सवाल

मैं पर काम कर रहा हूँ एक WinForms आवेदन है । मैं का उपयोग पीडीएफ फाइल में पासवर्ड रीसेट करने के लिए और मूल्यों पर पीडीएफ के रूप में संग्रहीत हैं महत्वपूर्ण मूल्य जोड़े(ईमेल: [email protected], दर्रा: 11111).

क्या मैं क्या करना चाहते हैं:

पढ़ें पीडीएफ फाइल में लाइन से लाइन और भरने के लिए उपयुक्त बक्सें.

मैं क्या किया है:

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 स्वागत भी कर रहे हैं.

c# pdf winforms
2021-11-22 11:36:14
1

सबसे अच्छा जवाब

0

यह है क्या मैं के साथ आया था,

var pdfDocument = new PdfDocument(new PdfReader("G:\\Encryption_File.pdf"));
        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);                
        }
        text.Split('\n');
        string line = "";                        
        line = text + "&";            
        string[] newLines = line.Split('&'); 
        textBox1.Text = newLines[0].Split(':')[1].ToString(); 
        textBox2.Text = newLines[0].Split(':')[2].ToString();
2021-11-23 02:40:57

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

इस श्रेणी में लोकप्रिय

लोकप्रिय सवाल इस श्रेणी में