Bladeren bron

DocX no longer miss recognizes Shapes as Images. DocX does not yet support Shapes or Charts.

master
coffeycathal_cp 15 jaren geleden
bovenliggende
commit
4695789cc1
2 gewijzigde bestanden met toevoegingen van 8 en 32 verwijderingen
  1. 5
    28
      ConsoleApplication3/Program.cs
  2. 3
    4
      DocX/Paragraph.cs

+ 5
- 28
ConsoleApplication3/Program.cs Bestand weergeven

@@ -12,37 +12,14 @@ namespace ConsoleApplication3
static void Main(string[] args)
{
// Create a document.
using (DocX document = DocX.Create(@"Test.docx"))
using (DocX document = DocX.Load(@"C:\Users\cathal\Downloads\foo.docx"))
{
// Add a Table to this document.
Table table = document.AddTable(2, 3);
List<Picture> pictures = document.Pictures;
// Add a Hyperlink into this document.
Hyperlink h = document.AddHyperlink("Google", new Uri("http://www.google.com"));
List<Novacode.Table> imageTable = (from table in document.Tables
where table.Pictures.Count > 0
select table).ToList();
// Add an Image into this document.
Novacode.Image i = document.AddImage(@"C:\Users\cathal\Desktop\Logo.png");
// Create a Picture (Custom View) of this Image.
Picture p = i.CreatePicture();
p.Rotation = 10;
// Specify some properties for this Table.
table.Alignment = Alignment.center;
table.Design = TableDesign.LightShadingAccent2;
// Insert the Table into the document.
Table t1 = document.InsertTable(table);
// Add content to this Table.
t1.Rows[0].Cells[0].Paragraphs.First().AppendHyperlink(h).Append(" is my favourite search engine.");
t1.Rows[0].Cells[1].Paragraphs.First().Append("This text is bold.").Bold();
t1.Rows[0].Cells[2].Paragraphs.First().Append("Underlined").UnderlineStyle(UnderlineStyle.singleLine);
t1.Rows[1].Cells[0].Paragraphs.First().Append("Green").Color(Color.Green);
t1.Rows[1].Cells[1].Paragraphs.First().Append("Right to Left").Direction = Direction.RightToLeft;
t1.Rows[1].Cells[2].Paragraphs.First().AppendPicture(p);
document.Save();
}// Release this document from memory.
}
}

+ 3
- 4
DocX/Paragraph.cs Bestand weergeven

@@ -61,10 +61,9 @@ namespace Novacode
from e in p.Descendants()
where e.Name.LocalName.Equals("blip")
select e.Attribute(XName.Get("embed", "http://schemas.openxmlformats.org/officeDocument/2006/relationships")).Value
).Single()
let
img = new Image(Document, mainPart.GetRelationship(id))
).SingleOrDefault()
where id != null
let img = new Image(Document, mainPart.GetRelationship(id))
select new Picture(Document, p, img)
).ToList();

Laden…
Annuleren
Opslaan