© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
11 replies
jooeyvh

Problem storing iText7 pdf in a memoryStream

Hey,

I am having a problem that I hope someone can help me sort out. I'm working on a project in C#, my solution will create a pdf file and I'm using iText7 for that purpose. It works fine storing the pdf locally but the next step is to store it in a memoryStream instead of a local file for later upload to Azure. However, something is weird and I just can't figure it out.

Hopefully someone here will be able to help me or can give me a hint in right direction.

These errors occur in the "memoryStream.Position" part:
ReadTimeout = 'memoryStream.ReadTimeout' threw an exception of type 'System.InvalidOperationException'
WriteTimeout = 'memoryStream.WriteTimeout' threw an exception of type 'System.InvalidOperationException'

My code:

MemoryStream memoryStream = new MemoryStream();
PdfWriter writer = new PdfWriter(filePath);
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
{

// Code for constructing and mapping information to pdf

}
memoryStream.Position = 0;
Utilities.UploadToBlobStorage(memoryStream, connectionString, containerName, blobName);
memoryStream.Dispose();
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ MemoryStream question
C#CC# / help
15mo ago
Put a pdf in a form
C#CC# / help
2y ago
❔ How to upload a MemoryStream as form file in a web request?
C#CC# / help
4y ago