public void testThumbnails() { POIXMLProperties noThumbProps = sampleNoThumb.GetProperties(); Assert.IsNotNull(_props.ThumbnailPart); Assert.IsNull(noThumbProps.ThumbnailPart); Assert.IsNotNull(_props.ThumbnailFilename); Assert.IsNull(noThumbProps.ThumbnailFilename); Assert.IsNotNull(_props.ThumbnailImage); Assert.IsNull(noThumbProps.ThumbnailImage); Assert.AreEqual("thumbnail.jpeg", _props.ThumbnailFilename); // Adding / changing noThumbProps.SetThumbnail("Testing.png", new ByteArrayInputStream(new byte[1])); Assert.IsNotNull(noThumbProps.ThumbnailPart); Assert.AreEqual("Testing.png", noThumbProps.ThumbnailFilename); Assert.IsNotNull(noThumbProps.ThumbnailImage); //Assert.AreEqual(1, noThumbProps.ThumbnailImage.Available()); Assert.AreEqual(1, noThumbProps.ThumbnailImage.Length - noThumbProps.ThumbnailImage.Position); noThumbProps.SetThumbnail("Testing2.png", new ByteArrayInputStream(new byte[2])); Assert.IsNotNull(noThumbProps.ThumbnailPart); Assert.AreEqual("Testing.png", noThumbProps.ThumbnailFilename); Assert.IsNotNull(noThumbProps.ThumbnailImage); //Assert.AreEqual(2, noThumbProps.ThumbnailImage.Available()); Assert.AreEqual(2, noThumbProps.ThumbnailImage.Length - noThumbProps.ThumbnailImage.Position); }
public void SetUp() { XWPFDocument sampleDoc = XWPFTestDataSamples.OpenSampleDocument("documentProperties.docx"); _props = sampleDoc.GetProperties(); _coreProperties = _props.CoreProperties; Assert.IsNotNull(_props); }
/** * Get the document properties. This gives you access to the * core ooxml properties, and the extended ooxml properties. */ public POIXMLProperties GetProperties() { if (properties == null) { try { properties = new POIXMLProperties(pkg); } catch (Exception e) { throw new POIXMLException(e); } } return(properties); }
public POIXMLProperties GetProperties() { if (this.properties == null) { try { this.properties = new POIXMLProperties(this.pkg); } catch (Exception ex) { throw new POIXMLException(ex); } } return(this.properties); }
public void TestWorkbookExtendedProperties() { XSSFWorkbook workbook = new XSSFWorkbook(); POIXMLProperties props = workbook.GetProperties(); Assert.IsNotNull(props); ExtendedProperties properties = props.ExtendedProperties; CT_ExtendedProperties ctProps = properties.GetUnderlyingProperties(); String appVersion = "3.5 beta"; String application = "POI"; ctProps.Application = (application); ctProps.AppVersion = (appVersion); ctProps = null; properties = null; props = null; XSSFWorkbook newWorkbook = (XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(workbook); Assert.IsTrue(workbook != newWorkbook); POIXMLProperties newProps = newWorkbook.GetProperties(); Assert.IsNotNull(newProps); ExtendedProperties newProperties = newProps.ExtendedProperties; Assert.AreEqual(application, newProperties.Application); Assert.AreEqual(appVersion, newProperties.AppVersion); CT_ExtendedProperties newCtProps = newProperties.GetUnderlyingProperties(); Assert.AreEqual(application, newCtProps.Application); Assert.AreEqual(appVersion, newCtProps.AppVersion); }
/** * Get the document properties. This gives you access to the * core ooxml properties, and the extended ooxml properties. */ public POIXMLProperties GetProperties() { if (properties == null) { try { properties = new POIXMLProperties(pkg); } catch (Exception e) { throw new POIXMLException(e); } } return properties; }
public ToxyMetadata Parse() { if (!System.IO.File.Exists(Context.Path)) throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found"); ToxyMetadata metadata=new ToxyMetadata(); OPCPackage pack=null; try { pack = OPCPackage.Open(Context.Path, PackageAccess.READ); POIXMLProperties props = new POIXMLProperties(pack); if (props.CoreProperties != null) { if (props.CoreProperties.Title != null) { metadata.Add("Title", props.CoreProperties.Title); } else if (props.CoreProperties.Identifier != null) { metadata.Add("Identifier", props.CoreProperties.Identifier); } else if (props.CoreProperties.Keywords != null) { metadata.Add("Keywords", props.CoreProperties.Keywords); } else if (props.CoreProperties.Revision != null) { metadata.Add("Revision", props.CoreProperties.Revision); } else if (props.CoreProperties.Subject != null) { metadata.Add("Subject", props.CoreProperties.Subject); } else if (props.CoreProperties.Modified != null) { metadata.Add("Modified", props.CoreProperties.Modified); } else if (props.CoreProperties.LastPrinted != null) { metadata.Add("LastPrinted", props.CoreProperties.LastPrinted); } else if (props.CoreProperties.Created != null) { metadata.Add("Created", props.CoreProperties.Created); } else if (props.CoreProperties.Creator != null) { metadata.Add("Creator", props.CoreProperties.Creator); } else if (props.CoreProperties.Description != null) { metadata.Add("Description", props.CoreProperties.Description); } } if (props.ExtendedProperties != null && props.ExtendedProperties.props != null) { var extProps = props.ExtendedProperties.props.GetProperties(); if (extProps.Application != null) { metadata.Add("Application", extProps.Application); } if (extProps.AppVersion != null) { metadata.Add("AppVersion", extProps.AppVersion); } if (extProps.Characters > 0) { metadata.Add("Characters", extProps.Characters); } if (extProps.CharactersWithSpaces > 0) { metadata.Add("CharactersWithSpaces", extProps.CharactersWithSpaces); } if (extProps.Company != null) { metadata.Add("Company", extProps.Company); } if (extProps.Lines > 0) { metadata.Add("Lines", extProps.Lines); } if (extProps.Manager != null) { metadata.Add("Manager", extProps.Manager); } if (extProps.Notes > 0) { metadata.Add("Notes", extProps.Notes); } if (extProps.Pages > 0) { metadata.Add("Pages", extProps.Pages); } if (extProps.Paragraphs > 0) { metadata.Add("Paragraphs", extProps.Paragraphs); } if (extProps.Words > 0) { metadata.Add("Words", extProps.Words); } if (extProps.TotalTime > 0) { metadata.Add("TotalTime", extProps.TotalTime); } } } finally { if(pack!=null) pack.Close(); } return metadata; }