Insert SVG into Word Document Using OpenXML - svg

I am trying to insert SVG into a Word document using DocumentFormat.OpenXML. I was hoping it would be something simple like this:
string svg="<svg string goes here>";
DocumentFormat.OpenXml.Drawing.Blip pic = New DocumentFormat.OpenXml.Drawing.Blip(svg);
I get an error stating that the XML can't be processed, so the Blip constructor must be looking for something other than an svg string. I'm not even sure that the Blip class is what I need to use.
If you have a straightforward example of how to do this, I would be grateful. Thanks.

Related

neo4j: fulltext index on external documents and attachments

This is the situation. Don't ask why, it is the way it is.
I created a simple fulltext-index over the document-contents by grabbing the content from the document-server and adding the simple unformatted content as a new property (raw_content) to each Document-Object in the neo4jdb.
Then i created a fulltext-index like:
CALL db.index.fulltext.createNodeIndex('content', ['Document'], ['title', 'teaser', 'raw_content'])
So far so good. Search works very well.
Now I want to index the attachments. I've got Attachment-URLs for each document, which I can call by the docid.
So, before I slide into any antipatterns, I'd like to ask the community, about how to do this. I've got two ways on my mind:
similar to the way I index the raw_content - is there a way to make Lucene get and parse the URLs, that I give to it?
the batch does all the parsing and adds the content to new fields like "attachment01_content" ...
Solution 1 would be appreciated, but i did not find any documentation on this.
Solution 2 is ugly, especially because Lucene can handle with pdf, doc ...
any ideas on how to solve this?

NodeJS Jade (Pug) inline link in dynamic text

I have this NodeJS application, that uses Jade as template language. On one particular page, one text block is retrieved from the server, which reads the text from database.
The problem is, the returned text might contain line-breaks and links, and an operator might change this text at any time. How do I make these elements display correctly?
Most answers suggest using a new line:
p
| this is the start of the para
a(href='http://example.com') a link
| and this is the rest of the paragraph
But I cannot do this, since I cannot know when the a element appears. I've solved how to get newline correct, by this trick:
p
each l in line.description.split(/\n/)
= l
br
But I cannot seem to solve how to get links to render correctly. Does anyone know?
Edit:
I am open to any kind of format for links in the database, whatever would solve the issue. For example, say database contains the following text:
Hello!
We would like you to visit [a("http://www.google.com")Google]
Then we would like that to output text that looks like this:
Hello!
We would like you to visit Google
Looks like what you're looking for is unescaped string interpolation. The link does not work in the output because Pug automatically escapes it. Wrap the content you want to insert with !{} and it should stop breaking links. (Disclaimer: Make sure you don't leave user input unescaped - this only is a viable option if you know for sure the content of your DB does not have unwanted HTML/JS code in it.)
See this CodePen for illustration.
With this approach, you would need to use standard HTML tags (<a>) in your DB text. If you don't want that, you could have a look at Pug filters such as markdown-it (you will still need to un-escape the compilation output of that filter).

How to add bullets in featured snippet using structured data?

I want to add bullets in featured snippet. When i search for 'gastric balloon' in google it gives me featured snippet for this link www.bariatric-surgery-source.com/gastric-balloon.html as shows in below image :
PLEASE OPEN THIS IMAGE => https://i.stack.imgur.com/1MBoD.png .
I have marked those lines with red color i.e i want to make display them with bullets symbol instead of plain text.
Someone suggest me that it could be possible with structured data but how?
And which code i have to write and where?
You have done everything semantically, so I would make the assumption that Google will strip out any formatting, and apply their own.
Best thing you could do is mark it up with ListItem schema.
An list item, e.g. a step in a checklist or how-to description.
Source - https://schema.org/ListItem

Getting thumbnails in OpenSearchServer search results

I need an alternative to Google Custom Search for a website I look after, it has to be something that will crawl a website, index it, allow fiddling of priorities, and then allow search queries via REST or something similar and return XML or JSON etc. It needs to run on a Windows Server instance.
So, I'm up and running with http://www.opensearchserver.com/ and it seems to do the trick, but can't, for the life of me, work out how to get thumbnail images in the results? I've searched the documentation and read everything I could, but can't find out how to do this (or how to get my head around it).
I'm crawling standard web pages and they all have thumbnail meta data, which I'm assuming should be able to be parsed somehow for results and included in the JSON results?
Any pointers at all would be very helpful, thanks!
I figured this out, in case anyone else is struggling, here's how I did it. The answer is in the documentations, it's just not that simple.
Read: http://www.opensearchserver.com/documentation/faq/crawling/how_to_extract_specific_information_from_web_pages.md - it contains the method
Assume you set up a 'web crawler' index.
Assuming you're using a meta thumbnail like this:
<meta name="thumbnail" content="http://my_cdn.com/news/images/29637.jpg">
Go into Schema / Fields. Add a new field called 'thumbnail' with index no, store yes, vector no, analyser Text, copy of blank. Save that.
Now go to schema / parser list, edit HTML parser. Go to 'field mapping', now add a new regex for the thumbnail in the html. We map from the 'htmlSource' to the thumbnail' with the matching regex.
My imperfect regex (that works though) is:
htmlSource -> linked in: thumbnail -> captured by:
(?s)<meta name="thumbnail" content="(.*?)">
Now SAVE this and go to crawl/manual crawl, enter a url that has a thumbnail and then check if the field now appears in the list below when it's read. If not check your regex, and check you actually saved the HTML Parser changes.
To get the thumb in your results, simply add the fieldname to the JSON you send with the query:
"returnedFields": [ "
"url",
"thumbnail"
],

full text searching in managed object context and core data

I am building a notes-like application. It has a NStableview displaying all notes' titles, and a NStextview displaying the plain text of the selected note. I am using bindings and core data. I want to have a search feature:
1. the tableview only shows the notes that contains the text you query
2. the textview displays the first note, and highlight the text you queried
I just started doing Cocoa development, and not sure how to implement this, and what classes and methods should I use. I googled around, and didn't find a good answer.
Can anyone please give me some ideas and resource to look at? Thanks.
If you have an NSSearchField in your xib, you can go to the bindings inspector and bind a predicate to it, instead of a value. Leave the model key path empty, and in Predicate Format (pretend your model is storing the text content with the attribute name "textContent") put this:
textContent contains[c] $value
The [c] tells it to search regardless of the case. It will automatically update your NSTableView if you're using bindings for that.
As far as highlighting your content, I'm not sure there's an easy way to do this with bindings (there might be).
Edit: Make sure you bind it to your NSArrayController, even though you leave the model key path blank

Resources