Comments (4)
Only directly as HTML file. I guess it would be possible to add a way to convert HTML directly without being in a file, but so far not available.
public static void Example_EmbedFileHTML(string folderPath, string templateFolder, bool openWord) {
Console.WriteLine("[*] Creating standard document with embedded HTML file");
string filePath = System.IO.Path.Combine(folderPath, "EmbeddedFileHTML.docx");
string htmlFilePath = System.IO.Path.Combine(templateFolder, "SampleFileHTML.html");
using (WordDocument document = WordDocument.Create(filePath)) {
Console.WriteLine("Embedded documents in word: " + document.EmbeddedDocuments.Count);
Console.WriteLine("Embedded documents in Section 0: " + document.Sections[0].EmbeddedDocuments.Count);
document.AddParagraph("Add HTML document in DOCX");
document.AddSection();
Console.WriteLine("Embedded documents in Section 1: " + document.Sections[1].EmbeddedDocuments.Count);
document.AddEmbeddedDocument(htmlFilePath);
document.EmbeddedDocuments[0].Save("C:\\TEMP\\EmbeddedFileHTML.html");
Console.WriteLine("Embedded documents in word: " + document.EmbeddedDocuments.Count);
Console.WriteLine("Embedded documents in Section 0: " + document.Sections[0].EmbeddedDocuments.Count);
Console.WriteLine("Embedded documents in Section 1: " + document.Sections[1].EmbeddedDocuments.Count);
Console.WriteLine("Content type: " + document.EmbeddedDocuments[0].ContentType);
document.Save(openWord);
}
}
One would need to add a method that skips the first few lines and goes straight for content.
OfficeIMO/OfficeIMO.Word/WordEmbeddedDocument.cs
Lines 71 to 110 in 91a87ac
from officeimo.
This is amazing - thanks for the fast reply! Let me give it a go and see how dangerous I can get. 😄
from officeimo.
Just wanted to let you know that your solution worked perfectly. Thanks again!
from officeimo.
I think i will add ability to add fragments directly, I guess you created file and added file which was then created as a fragment. We should have direct ability as well.
from officeimo.
Related Issues (20)
- dotnet 8.0 error HOT 13
- Any way to implement numbered list (a., b., c., ....)? HOT 4
- Setting font size for list symbol HOT 7
- Any way to insert rich text HTML content? HOT 8
- Remove continue numbering & restart numbering for lists
- Add ability to merge & remove lists
- Image layout options HOT 8
- Mislabeled Behavior? HOT 8
- Potential Bug: Does iteration over TableCell's Paragraphs property allow mutation? HOT 21
- Stable and unlikely to change vs unstable and subject to change vs depreciated api HOT 13
- How to add paragraph without pagebreak? HOT 4
- ContentControls.Add() is trimming space from user selection HOT 1
- How to display the specific gravity value in a pie chart HOT 2
- How to add image watermark? HOT 3
- how can I add a table with two rows and each row had diff columns and width? HOT 1
- Issue with Text Replacement in Multi-Line Text Boxes HOT 1
- ConditionalFormattingFirstColumn sample HOT 1
- [Question] Is Save As Web Page support? HOT 2
- Repeat as header row at the top on each page HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from officeimo.