public void Odt11Schema(bool exportToOdt11Specs) { //ExStart //ExFor:OdtSaveOptions //ExFor:OdtSaveOptions.#ctor //ExFor:OdtSaveOptions.IsStrictSchema11 //ExSummary:Shows how to make a saved document conform to an older ODT schema. Document doc = new Document(MyDir + "Rendering.docx"); OdtSaveOptions saveOptions = new OdtSaveOptions { MeasureUnit = OdtSaveMeasureUnit.Centimeters, IsStrictSchema11 = exportToOdt11Specs }; doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions); //ExEnd if (exportToOdt11Specs) { TestUtil.DocPackageFileContainsString("<text:span text:style-name=\"T118_1\" >Combobox<text:s/></text:span>", ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", "content.xml"); } else { TestUtil.DocPackageFileContainsString("<text:span text:style-name=\"T118_1\" >Combobox<text:s/></text:span>" + "<text:span text:style-name=\"T118_2\" >" + "<text:drop-down><text:label text:value=\"Line 1\" ></text:label>" + "<text:label text:value=\"Line 2\" ></text:label>" + "<text:label text:value=\"Line 3\" ></text:label>Line 2</text:drop-down></text:span>", ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", "content.xml"); } }
public void MeasurementUnits(OdtSaveMeasureUnit odtSaveMeasureUnit) { //ExStart //ExFor:OdtSaveOptions //ExFor:OdtSaveOptions.MeasureUnit //ExFor:OdtSaveMeasureUnit //ExSummary:Shows how to use different measurement units to define style parameters of a saved ODT document. Document doc = new Document(MyDir + "Rendering.docx"); // When we export the document to .odt, we can use an OdtSaveOptions object to modify how we save the document. // We can set the "MeasureUnit" property to "OdtSaveMeasureUnit.Centimeters" // to define content such as style parameters using the metric system, which Open Office uses. // We can set the "MeasureUnit" property to "OdtSaveMeasureUnit.Inches" // to define content such as style parameters using the imperial system, which Microsoft Word uses. OdtSaveOptions saveOptions = new OdtSaveOptions { MeasureUnit = odtSaveMeasureUnit }; doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions); //ExEnd switch (odtSaveMeasureUnit) { case OdtSaveMeasureUnit.Centimeters: TestUtil.DocPackageFileContainsString("<style:paragraph-properties fo:orphans=\"2\" fo:widows=\"2\" style:tab-stop-distance=\"1.27cm\" />", ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", "styles.xml"); break; case OdtSaveMeasureUnit.Inches: TestUtil.DocPackageFileContainsString("<style:paragraph-properties fo:orphans=\"2\" fo:widows=\"2\" style:tab-stop-distance=\"0.5in\" />", ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", "styles.xml"); break; } }
public void SaveDocumentEncryptedWithAPassword(SaveFormat saveFormat) { //ExStart //ExFor:OdtSaveOptions.#ctor(SaveFormat) //ExFor:OdtSaveOptions.Password //ExFor:OdtSaveOptions.SaveFormat //ExSummary:Shows how to encrypted your odt/ott documents with a password. Document doc = new Document(MyDir + "Document.docx"); OdtSaveOptions saveOptions = new OdtSaveOptions(saveFormat); saveOptions.Password = "******"; // Saving document using password property of OdtSaveOptions doc.Save(ArtifactsDir + "OdtSaveOptions.SaveDocumentEncryptedWithAPassword" + FileFormatUtil.SaveFormatToExtension(saveFormat), saveOptions); //ExEnd // Check that all documents are encrypted with a password FileFormatInfo docInfo = FileFormatUtil.DetectFileFormat( ArtifactsDir + "OdtSaveOptions.SaveDocumentEncryptedWithAPassword" + FileFormatUtil.SaveFormatToExtension(saveFormat)); Assert.IsTrue(docInfo.IsEncrypted); }
public void DetectDocumentEncryption() { //ExStart //ExFor:FileFormatUtil.DetectFileFormat(String) //ExFor:FileFormatInfo //ExFor:FileFormatInfo.LoadFormat //ExFor:FileFormatInfo.IsEncrypted //ExSummary:Shows how to use the FileFormatUtil class to detect the document format and encryption. Document doc = new Document(); // Configure a SaveOptions object to encrypt the document // with a password when we save it, and then save the document. OdtSaveOptions saveOptions = new OdtSaveOptions(SaveFormat.Odt); saveOptions.Password = "******"; doc.Save(ArtifactsDir + "File.DetectDocumentEncryption.odt", saveOptions); // Verify the file type of our document, and its encryption status. FileFormatInfo info = FileFormatUtil.DetectFileFormat(ArtifactsDir + "File.DetectDocumentEncryption.odt"); Assert.AreEqual(".odt", FileFormatUtil.LoadFormatToExtension(info.LoadFormat)); Assert.True(info.IsEncrypted); //ExEnd }
public void MeasureUnit() { //ExStart:MeasureUnit Document doc = new Document(MyDir + "Document.docx"); // Open Office uses centimeters when specifying lengths, widths and other measurable formatting // and content properties in documents whereas MS Office uses inches. OdtSaveOptions saveOptions = new OdtSaveOptions { MeasureUnit = OdtSaveMeasureUnit.Inches }; doc.Save(ArtifactsDir + "WorkingWithOdtSaveOptions.MeasureUnit.odt", saveOptions); //ExEnd:MeasureUnit }
public void MeasureUnitOption() { //ExStart //ExFor:OdtSaveOptions.MeasureUnit //ExSummary: Show how to work with units of measure of document content Document doc = new Document(MyDir + "OdtSaveOptions.MeasureUnit.docx"); //Open Office uses centimeters, MS Office uses inches OdtSaveOptions saveOptions = new OdtSaveOptions(); saveOptions.MeasureUnit = OdtSaveMeasureUnit.Inches; doc.Save(MyDir + @"\Artifacts\OdtSaveOptions.MeasureUnit.odt"); //ExEnd }
public static void SetMeasureUnitForODT(string dataDir) { // ExStart:SetMeasureUnitForODT //Load the Word document Document doc = new Document(dataDir + @"Document.doc"); //Open Office uses centimeters when specifying lengths, widths and other measurable formatting //and content properties in documents whereas MS Office uses inches. OdtSaveOptions saveOptions = new OdtSaveOptions(); saveOptions.MeasureUnit = OdtSaveMeasureUnit.Inches; //Save the document into ODT doc.Save(dataDir + "MeasureUnit_out.odt", saveOptions); // ExEnd:SetMeasureUnitForODT Console.WriteLine("\nSet MeasureUnit for ODT successfully.\nFile saved at " + dataDir); }
public void MeasureUnit(bool doExportToOdt11Specs) { //ExStart //ExFor:OdtSaveOptions //ExFor:OdtSaveOptions.#ctor //ExFor:OdtSaveOptions.IsStrictSchema11 //ExFor:OdtSaveOptions.MeasureUnit //ExFor:OdtSaveMeasureUnit //ExSummary:Shows how to work with units of measure of document content. Document doc = new Document(MyDir + "Rendering.docx"); // Open Office uses centimeters, MS Office uses inches OdtSaveOptions saveOptions = new OdtSaveOptions { MeasureUnit = OdtSaveMeasureUnit.Centimeters, IsStrictSchema11 = doExportToOdt11Specs }; doc.Save(ArtifactsDir + "OdtSaveOptions.MeasureUnit.odt", saveOptions); //ExEnd }
public void MeasureUnitOption() { //ExStart //ExFor:OdtSaveOptions //ExFor:OdtSaveOptions.#ctor //ExFor:OdtSaveOptions.IsStrictSchema11 //ExFor:OdtSaveOptions.MeasureUnit //ExFor:OdtSaveMeasureUnit //ExSummary:Shows how to work with units of measure of document content Document doc = new Document(MyDir + "OdtSaveOptions.MeasureUnit.docx"); // Open Office uses centimeters, MS Office uses inches OdtSaveOptions saveOptions = new OdtSaveOptions { MeasureUnit = OdtSaveMeasureUnit.Inches, IsStrictSchema11 = true }; doc.Save(ArtifactsDir + "OdtSaveOptions.MeasureUnit.odt", saveOptions); //ExEnd }
public void Encrypt(SaveFormat saveFormat) { //ExStart //ExFor:OdtSaveOptions.#ctor(SaveFormat) //ExFor:OdtSaveOptions.Password //ExFor:OdtSaveOptions.SaveFormat //ExSummary:Shows how to encrypt a saved ODT/OTT document with a password, and then load it using Aspose.Words. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world!"); // Create a new OdtSaveOptions, and pass either "SaveFormat.Odt", // or "SaveFormat.Ott" as the format to save the document in. OdtSaveOptions saveOptions = new OdtSaveOptions(saveFormat); saveOptions.Password = "******"; string extensionString = FileFormatUtil.SaveFormatToExtension(saveFormat); // If we open this document with an appropriate editor, // it will prompt us for the password we specified in the SaveOptions object. doc.Save(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString, saveOptions); FileFormatInfo docInfo = FileFormatUtil.DetectFileFormat(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString); Assert.IsTrue(docInfo.IsEncrypted); // If we wish to open or edit this document again using Aspose.Words, // we will have to provide a LoadOptions object with the correct password to the loading constructor. doc = new Document(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString, new LoadOptions("@sposeEncrypted_1145")); Assert.AreEqual("Hello world!", doc.GetText().Trim()); //ExEnd }
public void Odt11Schema(bool exportToOdt11Specs) { //ExStart //ExFor:OdtSaveOptions //ExFor:OdtSaveOptions.#ctor //ExFor:OdtSaveOptions.IsStrictSchema11 //ExSummary:Shows how to make a saved document conform to an older ODT schema. Document doc = new Document(MyDir + "Rendering.docx"); OdtSaveOptions saveOptions = new OdtSaveOptions { MeasureUnit = OdtSaveMeasureUnit.Centimeters, IsStrictSchema11 = exportToOdt11Specs }; doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions); //ExEnd doc = new Document(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt"); Assert.AreEqual(Aspose.Words.MeasurementUnits.Centimeters, doc.LayoutOptions.RevisionOptions.MeasurementUnit); if (exportToOdt11Specs) { Assert.AreEqual(2, doc.Range.FormFields.Count); Assert.AreEqual(FieldType.FieldFormTextInput, doc.Range.FormFields[0].Type); Assert.AreEqual(FieldType.FieldFormCheckBox, doc.Range.FormFields[1].Type); } else { Assert.AreEqual(3, doc.Range.FormFields.Count); Assert.AreEqual(FieldType.FieldFormTextInput, doc.Range.FormFields[0].Type); Assert.AreEqual(FieldType.FieldFormCheckBox, doc.Range.FormFields[1].Type); Assert.AreEqual(FieldType.FieldFormDropDown, doc.Range.FormFields[2].Type); } }
public void MeasureUnit(bool doExportToOdt11Specs) { //ExStart //ExFor:OdtSaveOptions //ExFor:OdtSaveOptions.#ctor //ExFor:OdtSaveOptions.IsStrictSchema11 //ExFor:OdtSaveOptions.MeasureUnit //ExFor:OdtSaveMeasureUnit //ExSummary:Shows how to work with units of measure of document content. Document doc = new Document(MyDir + "Rendering.docx"); // Open Office uses centimeters, MS Office uses inches OdtSaveOptions saveOptions = new OdtSaveOptions { MeasureUnit = OdtSaveMeasureUnit.Centimeters, IsStrictSchema11 = doExportToOdt11Specs }; doc.Save(ArtifactsDir + "OdtSaveOptions.MeasureUnit.odt", saveOptions); //ExEnd if (doExportToOdt11Specs) { TestUtil.DocPackageFileContainsString("<text:span text:style-name=\"T118_1\" >Combobox<text:s/></text:span>", ArtifactsDir + "OdtSaveOptions.MeasureUnit.odt", "content.xml"); } else { TestUtil.DocPackageFileContainsString("<text:span text:style-name=\"T118_1\" >Combobox<text:s/></text:span>" + "<text:span text:style-name=\"T118_2\" >" + "<text:drop-down><text:label text:value=\"Line 1\" ></text:label>" + "<text:label text:value=\"Line 2\" ></text:label>" + "<text:label text:value=\"Line 3\" ></text:label>Line 2</text:drop-down></text:span>", ArtifactsDir + "OdtSaveOptions.MeasureUnit.odt", "content.xml"); } }