Is it possible to do this or do I really have to extract the file before then read it?
In my code I'm doing this:
string zipPath = @"C:\Users\Analistas\Desktop\ZipFile.zip";
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
var sample = archive.GetEntry("PdfFile.pdf");
string pdfContent = ReadPdfFile("PdfFile.pdf");
if (sample != null)
{
using (var zipEntryStream = sample.Open())
{
MessageBox.Show(pdfContent);
}
}
}
And the method to read PDF:
public string ReadPdfFile(string fileName)
{
StringBuilder text = new StringBuilder();
if (File.Exists(fileName))
{
PdfReader pdfReader = new PdfReader(fileName);
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
text.Append(currentText);
}
pdfReader.Close();
}
return text.ToString();
}
Nothing is displayed.