How to use python-docx to insert an image into a word's self-selected graphic? - python-docx

I have a word document, such as Figure 1, the black part on the left is a self-selected graphics.
I now want to insert a picture in the self-selected graphic on the left, and the effect after insertion is shown below:
How to use python-docx to achieve the above function?

Related

Stripes in background in RDL

Is it possible to add stripes in the textbox in report?
So the result looks like in the picture?
User chooses color for the column in the application
color
This is no built in way of doing this (no fill style) but you could use an image of the stripes as a background image. You would need to create and save images for each colour and style and add them as embedded images in the report.
You can then set the background image of a textbox to the required image.
... or better still use an expression to select the image based on conditions.
=SWITCH(
Fields!ItemCode.Value >10 , "RedStripe",
Fields!ItemCode.Value >50 , "GreenStripe",
True, Nothing
)
Where Redstripe and GreenStripe are the image names you embedded.
You can set the image to repeat etc from the properties panel
Update after OP stated that colour is parameterised.
If the colour is a parameter then we need a slightly different approach.
First you need to create an image with stripes (any colour will do ), and then remove the stripe pixels so that the stipes are now transparent. Save this as a PNG.
I created one quickly whist testing which you can save from here hopefully. You'll just have to move the mouse around in the area below as it's a white on white image! Or switch StackOverflow to the dark theme, then you can right-click and save the image. If not you'll just have to create one yourself.
Image below here.. switch StackOverflow to Dark theme to see it
Image above here..
Now you will need to set the background image to this image but also set the backgroundcolor property to an expression. In this exmaple, I set the background to the value of my parameter.
My parameter is just text and I typed in some hex values in the form #FFFFFF. You will have to work out how to get the value from your color pickers to the report yourself, ask a new question if required.
Here's the report design
and here is the report running using a few sample hex values.

Can I create a html and css text container from multiple rectangles?

As I have already stated in the title, I would like to know, if it is possible to make a text container that is made up of multiple rectangles in html and css.
For example, if I make a div and put the text in there, it will always be a single rectangle, but I want mine to be made up of two rectangles, through which the text can freely flow.
Here is an image of what I mean:
The darker part is the one, where I want text to be. It is supposed to be like a card with a title, a description and a call to action button, but I want the description to go over and then beside the button. I created this prototype with two separate rectangles, and I want to know if this is possible in html and css, and if it will count as one single container, so that I dont have to split the text into two separate parts.
Thanks in advance!

SSRS - Indicator and value in same cell?

I have created a Directional indicator (Green up arrow and Red down arrow) in my SSRS report, referring to the value of the column next to it. This all works ok:
However, I really want the indicator and the value to be in the same cell, like Excel can:
A Google found the following article , where the last post suggest it is possible using the following syntax:
=Format(Fields!Column1.Value, "Format") + " " + "Indicator"
I assume "Indicator" refers to the name I gave to my Direction indicator, but I can't get it to work..
I have read that by using border formatting I can get my two cells to look like one, but I would ideally like it all to be in one.
Any thoughts appreciated!
Mark
I would do this by placing a Rectangle inside of the cell and place your indicator along with another text box inside the rectangle. The downside to this is (depending on how you align the items in the rectangle) the formatting may cause split cells in excel exports.
Ross's method will work and there are alternatives..
The article you referenced was a text indicator not an image (from what I could tell).
You could do something similar by simply adding a a placeholder in the cell (right-click inside the cell and click "create placeholder"). You can then set the font and colour independently from the rest of the cell.
You could use a common font such as wingdings to get arrows and then the value and color properties would be expressions to show the correct 'character' (arrow) and the correct colour.

Identify color hex codes in a straight line

How can I programmatically ascertain the html color hex codes for colors in a single spectral line? I'm definitely using the wrong terminology I'm just not sure how else to phrase it. This picture should bring clarity:
Notice how the cursor in the top rectangle is always in the same position. It's simply the cursor in the first bar that moves into different color segments, thus generating the hex codes visible below.
Is it possible to generate these programmatically?
it would take 3 steps to get there programatically:
choose the base color (for each of your screen shots its the right top corner)
then lighten it to the the right amount (the X axis of your squares)
then darken it to the right amount (the Y axis of your squares)
if your'e using precompiled css like SASS it would look like that:
$someColor: red;
$lighten: brighten($someColor,20%);
$darkenedColor : darken($lighten, 32%);
$darkenedColor will get you the point that you are looking for, it will work for any given $someColor

Generate rectangle with variable dimensions in CSS with inner gradient background

i have some variables on PHP who gain values from 0 to 100. I want to develop a simple graph system that draw a horizontal rectangle given the number (0, 1 , 50 and soo). Also i want to add some gradient to the background, doing this in php is complicated and i dont want more load in my server, so i know this is possible in css, but im not a css developer. So if any body can help me with this. In this page (http://www.answerbag.com/) you can se how i want the rectangle, in the results of the pool section in the middle of the above page.
that's very simple since you know the width. Since you probably want the full spectrum of the gradient to show, you probably want to resize the gradient image by using a css #score1 { width: 30px } on that <img id="score1" src="blue_gradient.png"> Then later on, you can use one of the many rounder corner methods to add the round corners to it.