shestakov / wordroller Goto Github PK
View Code? Open in Web Editor NEWFree Microsoft Word document (aka .docx) processing library for .Net
Home Page: https://www.nuget.org/packages/Wordroller/
License: Apache License 2.0
Free Microsoft Word document (aka .docx) processing library for .Net
Home Page: https://www.nuget.org/packages/Wordroller/
License: Apache License 2.0
Добавляю несколько изображений в цикле, как это сделано в тесте библиотеки, но все картинки отображаются только как первая. В архиве они есть, но в document.xml.rels тоже только первая.
foreach (var A in Doc.Attachments)
{
if (A.AType == Types.AttachmentType.Photo)
{
var Photo = A as Types.Attachment.Photo;
var image = document.AddImage(new System.IO.MemoryStream(Photo.Data), Wordroller.Content.Images.KnownImageContentTypes.Jpg);
var picture = section.WrapImageIntoInlinePicture(image,
$"{Photo.Id}",
Photo.Text,
300,
Photo.GetHeight(300));
var paragraph = section.AppendParagraph();
paragraph.AppendPicture(picture);
}
else
{
var paragraph = section.AppendParagraph();
paragraph.AppendText(A.ToString());
}
}
Hello,
Firstly, thank you very much for this lib, it's a pleasure to work with. Easy to use, fast, and well documented thanks to the tests.
I work for a small company here in Switzerland, we use Wordroller to generate documents from existing templates. However, we would also need to replace images in a document.
Wordroller can replace text and add images to a document, so I think we're not so far away. I've tried many ways to accomplish this with the current version, but it looks like it's not a supported scenario...
I would be really happy to contribute to this project by adding this feature myself, but I'm completely new to the Office Open XML world and would probably need some guidance if it's possible,
Thanks again for the great work accomplished, it's very helpful !
Selmir
Действую по вашем примерам, размер файла увеличивается, а изображения нет.
document = new WordDocument(new MemoryStream(Resources.test));
//document = new WordDocument(CultureInfo.CurrentCulture);
section = document.Body.Sections.Last();
var stream = new FileStream(@"D:\photo\photo.jpg", FileMode.Open);
var image = document.AddImage(stream, KnownImageContentTypes.Jpg);
var picture = section.WrapImageIntoInlinePicture(image, "123", "321", 200, 200);
var paragraph = section.AppendParagraph();
paragraph.AppendPicture(picture);
var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write);
document.Save(fileStream);
Так-же, при такой вставке, могут слетать стили и форматы предустановленных колонтитулов
Версия 1.1.1 из NuGet
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.