cpdf_info.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ///
  2. /// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
  3. ///
  4. /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  5. /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  6. /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  7. /// This notice may not be removed from this file.
  8. class CPDFInfo {
  9. String fileName = '';
  10. int fileSize = 0;
  11. String title = '';
  12. String author = '';
  13. String subject = '';
  14. String creator = '';
  15. String producer = '';
  16. int creationDate = 0;
  17. int modificationDate = 0;
  18. String keywords = '';
  19. int pageCount = 0;
  20. int? majorVersion;
  21. CPDFInfo(
  22. this.fileName,
  23. this.fileSize,
  24. this.title,
  25. this.author,
  26. this.subject,
  27. this.creator,
  28. this.producer,
  29. this.creationDate,
  30. this.modificationDate,
  31. this.keywords,
  32. this.pageCount,
  33. this.majorVersion);
  34. CPDFInfo.formJson(Map<String, dynamic> json) {
  35. fileName = json['fileName'];
  36. fileSize = json['fileSize'];
  37. title = json['title'];
  38. author = json['author'];
  39. subject = json['subject'];
  40. creator = json['creator'];
  41. producer = json['producer'];
  42. creationDate = json['creationDate'];
  43. modificationDate = json['modificationDate'];
  44. keywords = json['keywords'];
  45. pageCount = json['pageCount'];
  46. majorVersion = json['majorVersion'];
  47. }
  48. String fileSizeStr() {
  49. int MB = 1024 * 1024;
  50. int KB = 1024;
  51. num size;
  52. String unit = " M";
  53. if (fileSize > MB) {
  54. size = (fileSize / (1024 * 1024));
  55. } else if (fileSize > KB) {
  56. size = (fileSize / 1024);
  57. unit = " KB";
  58. } else {
  59. size = fileSize;
  60. unit = " B";
  61. }
  62. return '${size.toStringAsFixed(2)}$unit';
  63. }
  64. }