MetaData.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Xml;
  3. using System.IO;
  4. using System.Reflection;
  5. using System.Text;
  6. namespace FastReport.Export.Pdf
  7. {
  8. internal class PDFMetaData
  9. {
  10. private XmlDocument metadata;
  11. private string creator;
  12. private string description;
  13. private string title;
  14. private string producer;
  15. private string keywords;
  16. private string createdate;
  17. private string documentId;
  18. private string instanceId;
  19. private string part;
  20. private string conformance;
  21. private string zugferd;
  22. public string MetaDataString
  23. {
  24. get
  25. {
  26. return ExportUtils.StringFormat(metadata.InnerXml, Creator, Description, Title,
  27. CreateDate, Keywords, Producer, DocumentID, InstanceID, part, conformance, zugferd);
  28. }
  29. }
  30. public string Creator
  31. {
  32. get { return creator; }
  33. set { creator = value; }
  34. }
  35. public string Description
  36. {
  37. get { return description; }
  38. set { description = value; }
  39. }
  40. public string Title
  41. {
  42. get { return title; }
  43. set { title = value; }
  44. }
  45. public string Producer
  46. {
  47. get { return producer; }
  48. set { producer = value; }
  49. }
  50. public string Keywords
  51. {
  52. get { return keywords; }
  53. set { keywords = value; }
  54. }
  55. public string CreateDate
  56. {
  57. get { return createdate; }
  58. set { createdate = value; }
  59. }
  60. public string DocumentID
  61. {
  62. get { return documentId; }
  63. set { documentId = value; }
  64. }
  65. public string InstanceID
  66. {
  67. get { return instanceId; }
  68. set { instanceId = value; }
  69. }
  70. public string Part
  71. {
  72. get { return part; }
  73. set { part = value; }
  74. }
  75. public string Conformance
  76. {
  77. get { return conformance; }
  78. set { conformance = value; }
  79. }
  80. public string ZUGFeRD
  81. {
  82. get { return zugferd; }
  83. set { zugferd = value; }
  84. }
  85. public PDFMetaData()
  86. {
  87. metadata = new XmlDocument();
  88. // get a reference to the current assembly
  89. Assembly a = Assembly.GetExecutingAssembly();
  90. // get a list of resource names from the manifest
  91. using (Stream stream = a.GetManifestResourceStream("FastReport.Resources.Pdf.MetaData.xml"))
  92. using (XmlTextReader reader = new XmlTextReader(stream))
  93. metadata.Load(reader);
  94. }
  95. ///
  96. /// <param name="filename">File name without extentions, for example "MetaDataX"</param>
  97. public PDFMetaData(string filename)
  98. {
  99. metadata = new XmlDocument();
  100. // get a reference to the current assembly
  101. Assembly a = Assembly.GetExecutingAssembly();
  102. // get a list of resource names from the manifest
  103. using (Stream stream = a.GetManifestResourceStream(
  104. ExportUtils.StringFormat("FastReport.Resources.Pdf.{0}.xml", filename)))
  105. using (XmlTextReader reader = new XmlTextReader(stream))
  106. metadata.Load(reader);
  107. }
  108. }
  109. }