KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have to retrieve text from PDF file. But using the following code I only get empty text file. for (int i = 0; i < n; i++) { pagenumber = i + 1; filename = pagenumber.ToString(); while (filename.Length < digits) filename = "0" + filename; filename = "_" + filename; filename = splitFile + name + filename; // step 1: creation of a document-object document = new Document(reader.GetPageSizeWithRotation(pagenumber)); // step 2: we create a writer that listens to the document PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filename + ".pdf", FileMode.Create)); // step 3: we open the document document.Open(); PdfContentByte cb = writer.DirectContent; PdfImportedPage page = writer.GetImportedPage(reader, pagenumber); int rotation = reader.GetPageRotation(pagenumber); if (rotation == 90 || rotation == 270) { cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(pagenumber).Height); } else { cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0); } // step 5: we close the document document.Close(); PDFParser parser = new PDFParser(); parser.ExtractText(filename + ".pdf", filename + ".txt"); } What am I doing wrong and how should I extract text from PDF?
Tags (comma-separated)
Save Edits
Cancel