Want to get the html for pdf template from PDF manager(Sugar 7.6) - sugarcrm

I want to get the html of pdf manager using bean. I know how to get the html for email template but unable to get the html for pdf template which u build in pdf manager.
$template = new EmailTemplate();
$template->retrieve_by_string_fields(array(‘name’ => $template_name,’type’=>’email’));
$html=$template->body_html;
How can i achieve the same functionality when i want to get the html template from pdf manager?

The retrieve_by_string_fields function is deprecated as of 7.6 as per this, so you might want to consider using SugarQuery instead. There's no "type" field in the PDF Manager, so I've just gone with the name attribute from your code. This should provide you with an array of records matching the condition.
require_once("include/SugarQuery/SugarQuery.php");
$sugarQuery = new SugarQuery();
$sugarQuery->select("body_html");
$sugarQuery->from(BeanFactory::newBean('PdfManager'));
$sugarQuery->where()->equals("name", $template_name);
$html = $sugarQuery->execute();

Related

Rendering RichText in a Lotus Notes document

I am trying to create documents inside a LotusNotes Database by using the COM API. So far everything is working, except for the rendering of the RichText.
The RichText is created by converting a MarkDown document to RichText using Pandoc. Afterwards, I create a new RichTextItem.
In PowerShell it looks like this:
# A LotusNotes document
$Document = $Database.CreateDocument()
# Add a Body field as type RichText
$RTI = $Document.CreateRichTextItem("Body")
# Append the RichText to the field
$RTI.AppendText("THE_CONVERTED_MARKDOWN_COMES_HERE")
$Document.Save($true, $true)
But when I view the document, I only see the raw unformatted RichText in the body field. How can I render the text?
That's what AppendText does. It takes whatever you give it and renders it as plain text.
I am not familiar with Pandoc and have no idea what format is coming out of your conversion from MarkDown, but if it is HTML then you probably need to be using NotesMIMEEntity and other classes related to it. Otherwise, investigating a third party product like the MIDAS Rich Text API from Genii Software may be your best course of action.

How to get plaintext of tx_news?

I'm trying to send a Newsletter with tx_news and direct_mail.
The HTML rendering is fine, but I have problems with the plain text and the documentation handles only tt_news.
How do I get the plaintext of tx_news?
Addendum: I only have a Template for the HTML rendering and a Template for the plaintext - the plaintext template is empty yet. I have integrated the template via TypoScript.
plugin.tx_directmail_pi1 {
siteUrl = http://my.domain.com/
}
tx_directmail_pi1.10 = TEMPLATE
tx_directmail_pi1.10 {
template = FILE
template.file = EXT:my_extension/Resources/Private/Layouts/Page/Newsletter.tmpl
}
I propose the following solution: Use a different template for plaintext. This is described in the manual at https://docs.typo3.org/typo3cms/extensions/news/AdministratorManual/Templates/Start/Index.html and afterwards use one of those scripts to transform HTML to plaintext. I found https://github.com/mtibben/html2text and https://github.com/soundasleep/html2text or search yourself for "plaintext html to text".
The reason is simple: there is no transformation available in news or the TYPO3 core which transforms the bodytext with its links to plain text.

Cannot retrieve the fields name from form PDF using pdftk

When I try to using
pdftk my.pdf dump_data_fields >result.txt
have empty data result
Your file my.pdf may not be compatible with pdftk. Convert the file first using the following command:
>pdftk my.pdf output my_converted.pdf
Then try,
>pdftk my_converted.pdf dump_data_fields > result.txt
I've taken this from the following http://www.fpdf.org/en/script/script93.php where the converting process is suggested when the fields won't write to the pdf file so converting before dumping the fields may not help.
If your pdf has fields you it should be fillable in your pdf viewer. If in isn't fillable then it would seem that it has no fields.
This is most likely because the pdf you are using doesn't have any data fields to dump! Use a tool like Adobe Acrobat to open the pdf, go to wherever you need to to Edit Fields, and add fields anywhere you need them to show up. Make sure they are named so you can utilize them by using the attributes[] call in pdftk.
I recommend using snake case (i.e. text box named 'first_name') and then you should have access to it using attributes[:first_name] = 'your text'.
Hope this helps, let me know if you have any other questions/issues.

Need to find the tags under a tag in an XML using jQuery

I have this xml as part of the responseXml of an Ajax call:
<banner-ad>
<title><span style="color:#ffff00;"><strong>Title</strong></span></title>
</banner-ad>
When I used this jQuery(responseXml).find("title").text(); the result is "Title".
I also tried jQuery(responseXml).find("title:first-child") but the result is [object Object].
I want to get the result:
<span style="color:#ffff00;"><strong>Title</strong></span>
Please let me know how to do this in jQuery.
Thanks in advance for any help.
Regards,
Racs
Your problem is that you cannot simply append nodes from one document (the XML response) to another (your HTML page). The issue is two-fold:
You can use jQuery to append nodes from the XML document to the HTML page. This works; the nodes appear in the HTML DOM, but they stay XML nodes and therefore the browser ignores the style attribute, for example. Consequently the text will not be yellow (#ffff00).
As far as I can see, jQuery offers no built-in way to get the XML string (i.e. a serialized node) from an XML node. jQuery can handle XML documents quite well, but there is no equivalent to what .html() does in HTML documents.
So to make this work we need to extract the XML string from the XML document. Some browsers support the .xml property on XML nodes (namely, IE), the others come with an XMLSerializer object:
// find the proper XML node
var $title = $(doc).find("title");
// either use .xml or, when unavailable, an XMLSerializer
var html = $title[0].xml || (new XMLSerializer()).serializeToString($title[0]);
// result:
// '<title><span style="color:#ffff00;"><strong>Title</strong></span></title>'
Then we have to feed this HTML string to jQuery so new, real HTML elements can be created from it:
$("#target").append(html);
There is a fiddle to show this in action: http://jsfiddle.net/Tomalak/QWHj8/. This example also gets rid of the superfluous <title> element.
Anyway. If you have a chance to influence the XML itself, it would make sense to change it:
<banner-ad>
<title><span style="color:#ffff00;"><strong>Title</strong></span></title>
</banner-ad>
Just XML-encode the payload of <title> and you can do this in jQuery:
$("#target").append( $(doc).find("title").text() );
This would probably work:
$(responseXml).find("title").html();

Raw HTML in body text after importing content using transmorgrifier

I'm using a transmorgrifier recipe to import some data from drupal into a Plone 4.1 based buildout. The buildout is based on https://github.com/claytron/drupal-plone-transmogrifier, (mostly I updated it to use plone 4.1 instead of 4.0). The import works, I successfully imported data from a drupal site into my plone site. The only issue is that the html tags from the imported html show as the literal tags.
If, after the successful import, I manually go to each item and select 'edit' then click 'save' then the html is interpreted properly, but that would be a lot of editing and saving in order to fix my problem.
see screenshot of freshly imported content with html tags showing.
The blueprint doing the actual import of the field is (I believe) the one shown below:
[text_mimetype]
blueprint = collective.transmogrifier.sections.inserter
key = string:_text_mimetype
value = string:text/html
I experimented with using text/structured instead of text/html in the blueprint but that gave the same result:
What I need is either an additional blueprint that causes the html to be interpreted or a hints on how to ensure that my html gets interpreted at import.
The full list of blueprints used in my pipeline are shown here:
https://github.com/claytron/drupal-plone-transmogrifier/blob/master/src/my.migration/my/migration/config/base.cfg
Ran into the same problem when migrating content using wsapi4plone.core.
Solution: Pin zope.contenttype to version 3.5.5 (the default in the upcoming 4.1.1)
Cause: PLIP #9938 - http://dev.plone.org/plone/ticket/9938 as per esteele.
If it works under Plone 4.0 but not under Plone 4.1, then I'm guessing it has to do with the "factor custom output transformations out of the editors" PLIP that was merged as a part of the Plone 4.1. I would look into the changes from that PLIP and see how the pipeline needs to be adjusted.
Actually that section only insert a value "text/html" in the key "_text_mimetype"
The real encapsulation is done here:
[mimetype_encapsulator]
data-key = text
mimetype = python:item.get('_%s_mimetype' % key)
# replace the data in-place
field = key
condition = mimetype
more info: http://pypi.python.org/pypi/plone.app.transmogrifier#mime-encapsulator-section
Anyway i've experimented that it's not strictly mandatory to encapsulate the html text, it works also with a simple string.
Bye, Giacomo