PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Does MigraDoc render BMP files in RTF?
http://forum.pdfsharp.de/viewtopic.php?f=2&t=1403
Page 1 of 1

Author:  crypto_rsa [ Wed Nov 03, 2010 10:10 am ]
Post subject:  Does MigraDoc render BMP files in RTF?

I was trying to add some images to a MigraDoc document and then export it to PDF and RTF. While the PDF export works correctly, there was an exception thrown while exporting to RTF. It turned out that it is due to a *.bmp file being added to the document. I investigated the code and came across this method in file MigraDoc\code\MigraDoc.RtfRendering\MigraDoc.RtfRendering\ImageRenderer.cs:

Code:
    private void RenderSourceType()
    {
      string extension = Path.GetExtension(this.filePath);
      if (extension == null)
      {
        this.imageFile = null;
        Trace.WriteLine("No Image type given.", "warning");
        return;
      }
     
      switch (extension.ToLower())
      {
        case ".jpeg":
        case ".jpg":
          this.rtfWriter.WriteControl("jpegblip");
          break;

        case ".png":
          this.rtfWriter.WriteControl("pngblip");
          break;

        case ".gif":
          this.rtfWriter.WriteControl("pngblip");
          break;

        case ".pdf":
          // Show a PDF logo in RTF document
          this.imageFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("MigraDoc.RtfRendering.Resources.PDF.png");
          this.rtfWriter.WriteControl("pngblip");
          break;

       default:
          Trace.WriteLine(Messages.ImageTypeNotSupported(this.image.Name), "warning");
          this.imageFile = null;
          break;
      }
    }


Does it mean that files with a *.bmp extension can't be rendered in RTF?

Author:  Thomas Hoevel [ Wed Nov 03, 2010 1:30 pm ]
Post subject:  Re: Does MigraDoc render BMP files in RTF?

crypto_rsa wrote:
Does it mean that files with a *.bmp extension can't be rendered in RTF?

Good point.

A quick research on the Internet revealed that "pngblip" can also handle GIF, TIF and BMP (I didn't test that though).

So below
Code:
case ".png":
you should add
Code:
case ".bmp":
case ".tif":
case ".tiff":


Thanks for your feedback, I'll fix it with the next release.

Author:  crypto_rsa [ Wed Nov 03, 2010 1:43 pm ]
Post subject:  Re: Does MigraDoc render BMP files in RTF?

Thomas Hoevel wrote:
Thanks for your feedback, I'll fix it with the next release.

Thanks for your reply. My next question is, inevitably, when we can expect the next release? :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/