locked
MemoryStream into an iTextSharp jpg image RRS feed

  • Question

  • User1316246260 posted

    I now am trying to use System.Drawing in iTextSharp PDF creator.

    I have successfully downloaded iTextSharp.dll from SourceForge, placed it in a folder in my ASP.net project and "Add Reference" browse to my solution.

    It works fine.

    I am having some trouble turning my MemoryStream, ms, into an iTextSharp jpg image as seen below:

    Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
    Dim output = New MemoryStream()
    Dim writer = PdfWriter.GetInstance(doc, output)
    doc.Open()
       Using xPanel As New Bitmap(500, 500)
            Using gphs As Graphics = Graphics.FromImage(xPanel)
                Dim ms As New MemoryStream()
                ...System.Drawing Code...
                xPanel.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
                Dim image As System.Drawing.Image = System.Drawing.Image.FromStream(ms)
                Dim PdfImage As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(image, System.Drawing.Imaging.ImageFormat.Jpeg)
                doc.Add(PdfImage)
            End Using
        End Using
    doc.Close
     ...

     

    Tuesday, July 19, 2016 10:33 PM

All replies

  • User-821857111 posted

    I am having some trouble turning my MemoryStream, ms, into an iTextSharp jpg image
    What kind of trouble? An error? If so, what is it?

    Wednesday, July 20, 2016 6:49 AM
  • User1316246260 posted

    Nothing happens.  The System.Drawing code that I entered was not executed. No error messages.

    Wednesday, July 20, 2016 10:49 AM