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?