Exception happens when I'm trying to open generated pdf using iTextSharp library
Closed this issue · 4 comments
Hi,
After pdf generation by ghostscript method (GhostScript64.CallAPI(ghostScriptArguments)
I'm trying to open pdf using iTextSharp library to read as text but exception is occurring which is caught under catch (IOException ioEx).
Below is my sample code snippet
GhostScript64.CallAPI(ghostScriptArguments);
DisplayPdf(outputFilename);
String pdfContent = ReadPDF(outputFilename);
...
static String ReadPDF(String outputFilename)
{
StringBuilder text = new StringBuilder();
using (PdfReader reader = new PdfReader(outputFilename))
{
for (int i = 1; i <= reader.NumberOfPages; i++)
{
text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
}
reader.Close();
}
return text.ToString();
}
Please assist
I am not the author, or a maintainer of the itextpdf product.
I am not the author, or a maintainer of the itextpdf product.
Hi stchan,
I understand and completely agree with you that you are not the author of itextpdf product but I'm not able to understand why opening pdf is resulting in exception(Could not create the output file. is in use)
I've tried itextpdf library in another project and it works completely fine.
Also I have used below library but still the same issue.
https://www.sautinsoft.com/products/pdf-focus/how-to-extract-text-from-pdf-in-dotnet-aspnet-csharp-vb.php
Hi stchan,
Actually I want to open the pdf file programmatically after its generation to read the content as text for processing.
If I open the pdf file using filestream and read as byte stream then I'm getting postscript file.