Comments (7)
You can always try fixing it, I will need to look at code to be able to tell whether that's the simplest way to fix it. for me if you have optional parameter that requires you to "fix" this or it throws an error - it's not good design. I would prefer something automatic, so when user does AddImage it just works without thinking on "paragraphs", but maybe there's no other way. I'll take a look when I get some time, but if you want you can always play with it.
from officeimo.
Seen above the documentation implies the result is going to be a paragraph. Seen below there is a failure
since the parent is null but the method used to create the parent does not return nullable.
The code in question is below.
((addParagraph "").AddImage (image.path, image.width, image.height, wrap)).AddParagraphAfterSelf() |> ignore
I got this from adding the call to addparagraphafterself to try checking if it was due to the requirement to end a cell with a paragraph. This tells me that AddImage is returning null, I can't say more than this as I don't know the codebase.
from officeimo.
public WordParagraph AddImage(string filePathImage, double? width = null, double? height = null, WrapTextImage wrapImageText = WrapTextImage.InLineWithText, string description = "") {
var wordImage = new WordImage(_document, this, filePathImage, width, height, wrapImageText, description);
// Why was this change made?
//var wordImage = new WordImage(_document, filePathImage, width, height);
var paragraph = new WordParagraph(_document);
VerifyRun();
_run.Append(wordImage._Image);
return paragraph;
from officeimo.
Looked around some, thinking I'm going to be looking around the Table Cell code in the morning.
from officeimo.
I believe that I found the problem.
WordTableCell creates a brand new WordParagraph via call to the default constructor with no arguments using new.
This causes the paragraph not to have it's own reference to _document, the field will be left null, and so when addImage
is called on this paragraph, there is an error because _wordimage is passed the null reference to the document from
the paragraph so the image resource cannot be added to the root of the document.
WordParagraph public methods
WordParagraph constructor definition
WordTableCell
Should I submit a PR adding an optional argument for the _document reference to the addImage method on WordParagraph?
from officeimo.
The alternative short term fix for adding an image into a table looks like the user needs to explicitly create a WordParagraph from the document or directly and then add this paragraph into the table cell.
from officeimo.
Just looked over the existing PR for improving the table class and this fix is not yet present there, maybe better to fix there idk.
from officeimo.
Related Issues (20)
- Questions around TextBox HOT 23
- InvalidProgramException HOT 5
- Open Office Writer can't open document created with OfficeIMO HOT 17
- Add Combo Chart HOT 1
- Upgrading DocumentFormat.OpenXML to version 3 HOT 1
- 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
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.