Parcourir la source

second fix

master
malickf il y a 9 ans
Parent
révision
2b78c4cbcf
2 fichiers modifiés avec 14 ajouts et 16 suppressions
  1. 13
    15
      DocX/DocX.cs
  2. 1
    1
      UnitTests/DocXUnitTests.cs

+ 13
- 15
DocX/DocX.cs Voir le fichier

/// </example> /// </example>
/// <seealso cref="AddImage(Stream, string)"/> /// <seealso cref="AddImage(Stream, string)"/>
/// <seealso cref="Paragraph.InsertPicture"/> /// <seealso cref="Paragraph.InsertPicture"/>
public Image AddImage(string filename, string contentType = "image/jpeg")
public Image AddImage(string filename)
{ {
if (string.IsNullOrEmpty(contentType))
string contentType = "";
// The extension this file has will be taken to be its format.
switch (Path.GetExtension(filename))
{ {
// The extension this file has will be taken to be its format.
switch (Path.GetExtension(filename))
{
case ".tiff": contentType = "image/tif"; break;
case ".tif": contentType = "image/tif"; break;
case ".png": contentType = "image/png"; break;
case ".bmp": contentType = "image/png"; break;
case ".gif": contentType = "image/gif"; break;
case ".jpg": contentType = "image/jpg"; break;
case ".jpeg": contentType = "image/jpeg"; break;
default: contentType = "image/jpg"; break;
}
case ".tiff": contentType = "image/tif"; break;
case ".tif": contentType = "image/tif"; break;
case ".png": contentType = "image/png"; break;
case ".bmp": contentType = "image/png"; break;
case ".gif": contentType = "image/gif"; break;
case ".jpg": contentType = "image/jpg"; break;
case ".jpeg": contentType = "image/jpeg"; break;
default: contentType = "image/jpg"; break;
} }
return AddImage(filename as object, contentType); return AddImage(filename as object, contentType);
} }
/// <summary> /// <summary>
/// Add an Image into this document from a Stream. /// Add an Image into this document from a Stream.
/// </summary> /// </summary>

+ 1
- 1
UnitTests/DocXUnitTests.cs Voir le fichier

// Check file size // Check file size
FileInfo f = new FileInfo( temporaryFilePath ); FileInfo f = new FileInfo( temporaryFilePath );
Assert.IsTrue( f.Length == 9659 );
Assert.IsTrue( f.Length == 9658 );
} }
// Delete the tempory file. // Delete the tempory file.

Chargement…
Annuler
Enregistrer