coffeycathal_cp 16 anos atrás
pai
commit
7fa4cfc53d

DocX/DocX/CustomProperty.cs → DocX v1.0.0.5/CustomProperty.cs Ver arquivo


DocX/DocX/DocX.cs → DocX v1.0.0.5/DocX.cs Ver arquivo


DocX/DocX/DocX.csproj → DocX v1.0.0.5/DocX.csproj Ver arquivo


DocX/DocX/DocX.csproj.vspscc → DocX v1.0.0.5/DocX.csproj.vspscc Ver arquivo


DocX/DocX/Enumerations.cs → DocX v1.0.0.5/Enumerations.cs Ver arquivo


DocX/DocX/Extensions.cs → DocX v1.0.0.5/Extensions.cs Ver arquivo


DocX/DocX/Formatting.cs → DocX v1.0.0.5/Formatting.cs Ver arquivo


DocX/DocX/Help/DocX v1.0.0.5 - Documentation.chm → DocX v1.0.0.5/Help/DocX v1.0.0.5 - Documentation.chm Ver arquivo


DocX/DocX/Image.cs → DocX v1.0.0.5/Image.cs Ver arquivo


DocX/DocX/License/License.html → DocX v1.0.0.5/License/License.html Ver arquivo


DocX/DocX/Paragraph.cs → DocX v1.0.0.5/Paragraph.cs Ver arquivo


DocX/DocX/Picture.cs → DocX v1.0.0.5/Picture.cs Ver arquivo


DocX/DocX/Properties/AssemblyInfo.cs → DocX v1.0.0.5/Properties/AssemblyInfo.cs Ver arquivo


DocX/DocX/Resources/styles.xml → DocX v1.0.0.5/Resources/styles.xml Ver arquivo


DocX/DocX/Run.cs → DocX v1.0.0.5/Run.cs Ver arquivo


DocX/DocX/Table.cs → DocX v1.0.0.5/Table.cs Ver arquivo


DocX/DocX/Text.cs → DocX v1.0.0.5/Text.cs Ver arquivo


DocX/DocX/styles.xml → DocX v1.0.0.5/styles.xml Ver arquivo


+ 0
- 81
Examples/Examples.csproj Ver arquivo

@@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EF2E13CC-B36B-4B5A-AE73-78F5DDCA094E}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Examples</RootNamespace>
<AssemblyName>Examples</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Input\Image.docx" />
<None Include="Input\Template.docx" />
<None Include="Input\StringReplace.docx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DocX\DocX.csproj">
<Project>{E863D072-AA8B-4108-B5F1-785241B37F67}</Project>
<Name>DocX</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Input\Donkey.JPG" />
</ItemGroup>
<ItemGroup>
<Folder Include="Output\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

+ 0
- 10
Examples/Examples.csproj.vspscc Ver arquivo

@@ -1,10 +0,0 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

BIN
Examples/Input/Donkey.JPG Ver arquivo


BIN
Examples/Input/Image.docx Ver arquivo


BIN
Examples/Input/StringReplace.docx Ver arquivo


BIN
Examples/Input/Template.docx Ver arquivo


+ 0
- 219
Examples/Program.cs Ver arquivo

@@ -1,219 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Novacode;
using System.Text.RegularExpressions;
using System.Drawing;
namespace Examples
{
class Program
{
static void Main(string[] args)
{
StringReplaceExample();
CustomPropertiesExample();
CreateDocumentOnTheFly();
ImageExample1();
//ImageExample2();
}
private static void StringReplaceExample()
{
File.Copy(@"..\..\Input\StringReplace.docx", @"..\..\Output\StringReplace.docx", true);
// Load the document that you want to manipulate
DocX document = DocX.Load(@"..\..\Output\StringReplace.docx");
// Loop through the paragraphs in the document
foreach (Paragraph p in document.Paragraphs)
{
/*
* Replace each instance of the string pear with the string banana.
* Specifying true as the third argument informs DocX to track the
* changes made by this replace. The fourth argument tells DocX to
* ignore case when matching the string pear.
*/
p.Replace("pear", "banana", true, RegexOptions.IgnoreCase);
}
// File will be saved to ..\..\Output\
document.Save();
}
private static void CustomPropertiesExample()
{
// A list which contains three new users
List<User> newUsers = new List<User>
{
new User
{
forname = "John", username = "John87",
freeGift = "toaster", joined = DateTime.Now,
HomeAddress = "21 Hillview, Naas, Co. Kildare",
RecieveFurtherMail = true
},
new User
{
forname = "James", username = "KingJames",
freeGift = "kitchen knife", joined = DateTime.Now,
HomeAddress = "37 Mill Lane, Maynooth, Co. Meath",
RecieveFurtherMail = false
},
new User
{
forname = "Mary", username = "McNamara1",
freeGift = "microwave", joined = DateTime.Now,
HomeAddress = "110 Cherry Orchard Drive, Navan, Co. Roscommon", RecieveFurtherMail= true
}
};
// Foreach of the three new user create a welcome document based on template.docx
foreach (User newUser in newUsers)
{
// Copy template.docx so that we can customize it for this user
string filename = string.Format(@"..\..\Output\{0}.docx", newUser.username);
File.Copy(@"..\..\Input\Template.docx", filename, true);
/*
* Load the document to be manipulated and set the custom properties to this
* users specific data
*/
DocX doc = DocX.Load(filename);
doc.SetCustomProperty("Forname", CustomPropertyType.Text, newUser.forname);
doc.SetCustomProperty("Username", CustomPropertyType.Text, newUser.username);
doc.SetCustomProperty("FreeGift", CustomPropertyType.Text, newUser.freeGift);
doc.SetCustomProperty("HomeAddress", CustomPropertyType.Text, newUser.HomeAddress);
doc.SetCustomProperty("PleaseWaitNDays", CustomPropertyType.NumberInteger, 4);
doc.SetCustomProperty("GiftArrivalDate", CustomPropertyType.Date, newUser.joined.AddDays(4).ToUniversalTime());
doc.SetCustomProperty("RecieveFurtherMail", CustomPropertyType.YesOrNo, newUser.RecieveFurtherMail);
// File will be saved to ..\..\Output\
doc.Save();
doc.Dispose();
}
}
private static void CreateDocumentOnTheFly()
{
// Create a new .docx file
DocX d = DocX.Create(@"..\..\Output\Hello.docx");
// Add a new paragraph to this document
Paragraph one = d.AddParagraph();
one.Alignment = Alignment.both;
// Create a text formatting called f1
Formatting f1 = new Formatting();
f1.FontFamily = new FontFamily("Agency FB");
f1.Size = 28;
f1.Bold = true;
f1.FontColor = Color.RoyalBlue;
f1.UnderlineStyle = UnderlineStyle.doubleLine;
f1.UnderlineColor = Color.Red;
// Insert some new text, into the new paragraph, using the created formatting f1
one.Insert(0, "I've got style!", f1, false);
// Create a text formatting called f2
Formatting f2 = new Formatting();
f2.FontFamily = new FontFamily("Colonna MT");
f2.Size = 36.5;
f2.Italic = true;
f2.FontColor = Color.SeaGreen;
// Insert some new text, into the new paragraph, using the created formatting f2
one.Insert(one.Value.Length, " I have a different style.", f2, false);
// Save the document
d.Save();
d.Dispose();
}
private static void ImageExample1()
{
File.Copy(@"..\..\Input\Image.docx", @"..\..\Output\Image.docx", true);
// Load a .docx file
DocX document = DocX.Load(@"..\..\Output\Image.docx");
// Add an image to the docx file
Novacode.Image img = document.AddImage(@"..\..\Input\Donkey.jpg");
// Decide which paragraph to add the image to
Paragraph p = document.Paragraphs.Last();
#region pic1
// Create a picture, a picture is a customized view of an image
Picture pic1 = new Picture(img.Id, "Donkey", "Taken on Omey island");
// Set the pictures shape
pic1.SetPictureShape(BasicShapes.cube);
// Rotate the picture clockwise by 30 degrees
pic1.Rotation = 30;
// Insert the picture at the end of this paragraph
p.InsertPicture(pic1, p.Value.Length);
#endregion
#region pic2
// Create a picture, a picture is a customized view of an image
Picture pic2 = new Picture(img.Id, "Donkey", "Taken on Omey island");
// Set the pictures shape
pic2.SetPictureShape(CalloutShapes.cloudCallout);
// Flip the picture horizontal
pic2.FlipHorizontal = true;
// Insert the picture at the end of this paragraph
p.InsertPicture(pic2, p.Value.Length);
#endregion
// Save the docx file
document.Save();
document.Dispose();
}
private static void ImageExample2()
{
// Load the document that you want to manipulate
DocX document = DocX.Load(@"..\..\Output\Image.docx");
foreach (Paragraph p in document.Paragraphs)
{
foreach (Picture pi in p.Pictures)
{
pi.Rotation = 30;
}
}
// File will be saved to ..\..\Output\
document.Save();
document.Dispose();
}
}
// This class is used in the CustomPropertiesExample()
class User
{
public string forname, username, freeGift, HomeAddress;
public DateTime joined;
public bool RecieveFurtherMail;
public User()
{ }
}
}

+ 0
- 36
Examples/Properties/AssemblyInfo.cs Ver arquivo

@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Examples")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft IT")]
[assembly: AssemblyProduct("Examples")]
[assembly: AssemblyCopyright("Copyright © Microsoft IT 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6ffd1827-4c08-4b2f-89fb-8ade88ac71f0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Carregando…
Cancelar
Salvar