HTML to PDF / DOCX / RTF Java converter library Forums PD4ML v3 Archived Forums (Read Only) General questions / FAQ .NET Generating PDF into MemoryStream instead of the file

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #26453

    I’m trying to generate PDF file in memory using MemoryStream. But MemoryStream is closed and unaviable for reading after render method is completed.

    I have seen an example on how to do it in Java using ByteArrayOutputStream but no example was provided in .NET.

    Thank you

    MemoryStream msPDF = new MemoryStream();
    pd4ml.render(msHTML,msPDF, new System.Uri(“http://localhost/cf”));
    byte[] baPDF = new byte[msPDF.Length];//this line produces an exception
    msPDF.Read(baPDF,0,(int) msPDF.Length);


    Exactly the same thing happens to me


    This is a common problem with MemoryStream usage in code ported from java.

    Try this workaround (it works fine for me):
    Basically decorate the underlying memory stream (the argument to StreamWriter) as:
    streamWriter(new NonDisposingStreamDecorator(memoryStream))


Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘General questions / FAQ’ is closed to new topics and replies.