SpireDoc html to word preserving data tags - spire.doc

I am working on a template generator usecase which involves a tinyMCE editor with the option to export and import to/from Microsoft Word files.
I use SpireDoc to save html files as docx and restore docx back to html.
The problem is, as this is a template generator, I need to include some metadata along some of the html nodes. Say a user's name is inserted in the tinyMCE and the html code would look like this:
<span data-type="user-name" data-id="234">Some Name</span>
Once converted to docx, all the data- tags are stripped off. Is there a way I could tell SpireDoc to preserve those tags and to put them back in the html file when I convert docx back to html?
I know I could resort to ugly placeholders like ##USERNAME|ID## but I would prefer if I could keep my metadata tags because I also need to do that for images and the user will not be able to size/format the image if it was just a text placeholder.

Related

Add logo to title page when backend is docbook

I am trying to customise the title page where the backend output is docbook. title, subtitle etc are all output correctly. But I cannot seem to get the title logo to output.
I have tried:
:title-logo-image: image:images/titleimage.png[]
The only way I can get this to kind-of work is to directly embed the image in the title text. But that is not ideal.
Is this possible when using docbook?
Since you convert AsciiDoc to DocBook I am assuming you are writing a book. The parameter title-logo-image you are using is not for asciidoctor (conversion to HTML and DocBook) but for asciidoctor-pdf (conversion to PDF), see https://docs.asciidoctor.org/pdf-converter/latest/title-page/#logo. If you are okay with PDF instead of DocBook you should try asciidoctor-pdf, it also allows you to customize your page it is pretty nice.
I am not sure what you expect though, is it a big picture on the first page? are you talking about the cover? If so you might want to create your own DocBook cover element and inject it in your DocBook file. This is possible in AsciiDoc by using a DocInfo file. You create a docinfo.dbk file where you write the <cover> element and the file content will then be injected in the <info> Element in the resulting DocBook file.

How to include images from the epub template with pandoc?

I've altered the epub template to display more information. It works fine, except when I specify images that refer to a local file. e.g. <img src = "my_file.png">. The code is there in the epub, but the image file isn't.
Pandoc does not parse the template as HTML, so it misses the <img> element when collecting media elements for inclusion in the EPUB. A quick and simple work-around is to list the missing images in some unused metadata field. E.g.,
---
missing-images: |
![](my_file.png)
---
Store the above in a file and pass it to pandoc via --metadata-file. This makes pandoc aware of the file, forcing its inclusion.
One could automate it by letting pandoc parse the template and extract the image information, e.g. with a pandoc Lua filter, but that's likely to be more trouble than it's worth.

Is there any way to convert ckeditor html content to ms word document?

I have a Laravel project where I need to create a doc/docx document based on user input in Ckeditor. I have previously worked with PHPword where I can convert simple text input to a docx document. But the problem with ckeditor is it gives you html with inline css (which i need) and PHPWORD can not convert this to a docx.
I also tried to convert the html to word by xml but no luck. I know there is a paid tool called phpdocx but I am looking for a free solution.
Just a note, I can actually convert the html to pdf. But again, there is no solution from pdf to doc.
So, any help in converting the html to word or pdf to word?
thanks

Allow copy / paste in a text_area field form but remove formatting

I have a text_area field in a form which allows some text formatting through a very simple WYSIWYG (bold / underline / bullet points). This was aimed at having a consistent formatting in the description profile of the users.
<%= l.text_area :access, value: "#{t('.access_placeholder_html')}" %>
Nevertheless, some users usually filled the text_area by copy / pasting directly from their website. And their specific formatting "hypertext links", font size, etc. is after reflected on my website, which makes it a bit dirty.
How can I solve this problem. Ideally I would love that when saving the form it gets rid of all the HTML code that is not allowed instead of not allowing copy / paste. Is this possible? Was wondering if should use Sanitize but if so how? (Sorry new to code, I guess you would have understood).
You didn't say which version of Rails, but you could use #sanitize from ActionView::Helpers::SanitizeHelper module to strip all the HTML formatting. It scrubs HTML from text with a scrubber. The default scrubber allows optional whitelisting of attributes. You can even build your own custom scrubber to modify the string if you need more control over what is output. The module also contains #strip_tags and #strip_links, which are very simple scrubbers that remove all HTML tags and all HTML link tags (leaving the link text).
Note that you can wind up with malformed text if the user's input wasn't valid HTML.
Quick examples from the docs:
// remove all HTML tags except <strong> <em> <a> and the
// <href> attributes from #text
nomarkup_text = sanitize #text, tags: %w(strong em a), attributes: %w(href)
// remove all HTML markup
strip_tags("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
returns the string Bold no more! See more here...
// remove just the link markup
strip_links('Please e-mail me at me#email.com.')
returns the string Please e-mail me at me#email.com.
More detail at the API page for SantizeHelper

Can't insert html with <object> tag

I'm struggling with ckeditor 4.5, as I'm creating plugins to insert specific tags in current document after having uploaded a file on my server.
For some specific file types, I want to embed the element. I can add <audio> or <video> tags (by using allowContent=true in my config file), but when I insert an <object> tag (to embed a pdf file), the tag is just ignored.
I already tested adding config.extraAllowedContent = 'object[id, name, width, height, data, type] to the config file, with no avail.
I found some workarounds by adding a <div> around the <object>, but the pdf viewer is not displayed in the editor (but the <object> tag is there).
I think I'm doing something wrong with ACF, but I really don't see what.
only wrapped the tag with or , and if you use wordpress , or drupal try to disable Advanced content filter from cms
<object> is not recommended for PDF and should not be a part of an editable area. There is no way it can be editable like text or paragraph. However, it can be a non-editable element inside the editor, with some editable parts. This is what CKEditor call widget, here is a tutorial how to create it: https://ckeditor.com/docs/ckeditor4/latest/guide/widget_sdk_intro.html
Note PDF format is not normally classed as "Media" more generally "Document" but there are two ways to embed. One is to use the allMedia plugin that does include PDF as a media format ;-) the other is to include content via google docs. So review the various "Demonstrations" on the website.

Resources