Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Xml.Linq;
  6. using System.IO.Packaging;
  7. namespace Novacode
  8. {
  9. /// <summary>
  10. /// Represents an Image embedded in a document.
  11. /// </summary>
  12. public class Image
  13. {
  14. /// <summary>
  15. /// A unique id which identifies this Image.
  16. /// </summary>
  17. private string id;
  18. private DocX document;
  19. /// <summary>
  20. /// Returns the id of this Image.
  21. /// </summary>
  22. public string Id
  23. {
  24. get {return id;}
  25. }
  26. internal Image(DocX document, PackageRelationship pr)
  27. {
  28. this.document = document;
  29. this.id = pr.Id;
  30. }
  31. /// <summary>
  32. /// Add an image to a document, create a custom view of that image (picture) and then insert it into a Paragraph using append.
  33. /// </summary>
  34. /// <returns></returns>
  35. /// <example>
  36. /// Add an image to a document, create a custom view of that image (picture) and then insert it into a Paragraph using append.
  37. /// <code>
  38. /// using (DocX document = DocX.Create("Test.docx"))
  39. /// {
  40. /// // Add an image to the document.
  41. /// Image i = document.AddImage(@"Image.jpg");
  42. ///
  43. /// // Create a picture i.e. (A custom view of an image)
  44. /// Picture p = i.CreatePicture();
  45. /// p.FlipHorizontal = true;
  46. /// p.Rotation = 10;
  47. ///
  48. /// // Create a new Paragraph.
  49. /// Paragraph par = document.InsertParagraph();
  50. ///
  51. /// // Append content to the Paragraph.
  52. /// par.Append("Here is a cool picture")
  53. /// .AppendPicture(p)
  54. /// .Append(" don't you think so?");
  55. ///
  56. /// // Save all changes made to this document.
  57. /// document.Save();
  58. /// }
  59. /// </code>
  60. /// </example>
  61. public Picture CreatePicture()
  62. {
  63. return Paragraph.CreatePicture(document, id, string.Empty, string.Empty);
  64. }
  65. }
  66. }