Telerik RadEditor memorystream/string save to RTF - asp.net

The required functionality I am aiming for is to pull out RTF content from a database, edit it through a web interface (with a WYSIWYG editor) and then place the modified text back in to the database (in RTF format).
The control that I am using to do this is Telerik RadEditor (we have a license already for these controls). In the most recent version there appears to be functionality to load in RTF content from a string or a stream, but the only method I can see that is exposed for getting RTF back out is exportToRTF(); this method modified the headers and allows you to save a RTF version of the content you have just edited as a file.
The functionality to convert from HTML to RTF must exist somewhere within their library as you can export a RTF file, but I can not find any publicly exposed methods to pass this in to a stream or a string.
Does anybody know of a way that I can convert the HTML back to RTF using the Telerik libraries without saving out to a file?
Thanks

I think the methods that do the actual conversion are not publicly available in the Telerik assembly, so your only choice is to use the built-in export functionality. You can add a handler for the ExportContent event. There you will have access to the content that will be saved to the file before the actual operation.
Since the export call changes the response of the current page request, you can create a new dummy page, add an editor there, set its .Content property to the content you wish to export, attach a handler to ExportContent and finally call the export method of the editor.

Related

How to see tags in a Powerpoint presentation

I am working for an office-add-in for PowerPoint. I need to assign some unique identifier to my files, so that files can be identified in any dot net application. I did similar work for Word using custom properties. But for PowerPoint there is no way to read/ write custom property using office.js.
The only way I found using tags:
https://learn.microsoft.com/en-us/office/dev/add-ins/powerpoint/tagging-presentations-slides-shapes
but when I add tags to the presentation, I am not able to see those tags in presentation directly, I am able to read/ write through code only. Also I am not getting a way to read these tags from dot net application.
Any help will be great.
I am storing my files to azure blob. And reading files in my dot net core application to identify whether it has been saved from an office-add in or not. I am using syncfusion library in dot net core application to work with files.
Try this:
Open a PPT file and add a few tags "wwwww", "yyyyy", "zzzzz".
Close and save the file.
Add ".zip" onto the end of the filename.
Use any unzipper program to unzip the file.
Search the folder of unzipped files for "wwwww", "yyyyy", "zzzzz".
This should tell you where/how tags are stored in the OOXML.
Your .NET app should be able to use the OOXML SDK to read the tags of a PPT file.
At present, Syncfusion Presentation library do not have support to read and edit the tags of PowerPoint elements. Please track the status of this feature from below link,
https://www.syncfusion.com/feedback/1800/create-and-edit-tags-for-powerpoint-elements
However, kindly try the below suggested workaround solutions to achieve your requirement,
Using Shape.Name property:
Add a shape with unique name while generating a document from Office-Addin. You can use Shape.Name property for this.
In .NET Core application, identify the corresponding shape by using Shape.ShapeName property of Syncfusion Presentation library and decide whether its generated by Office-Addin or not. You can refer below UG documentation for more details,
https://help.syncfusion.com/file-formats/presentation/working-with-shapes#specifying-shape-properties
Using custom meta-data on Presentation:
PowerPoint Javascript API documentation states that, when we apply the tags for Presentation object it’s maintained as a custom property of PowerPoint document.
Screenshot
If so, you can able to iterate the custom property of PowerPoint document using Presentation.CustomDocumentProperties API of Syncfusion Presentation library. You can refer below UG documentation for more details,
https://help.syncfusion.com/file-formats/presentation/working-with-powerpoint-presentation#adding-custom-document-properties
Note: This update is from Syncfusion team

How to convert a html table to downloadable excel file ASP.NET C#

I need a function to convert any HTML table to a excel file!
I like to add a button to my page and once that button is clicked I pass a complete HTML table in to such a function that will generate an excel file and past the html table into the file with the same layout and design!
I appreciate any help with this request.
I am using c# and asp.net
This is a nasty trick, but it works in recent version of excel.
You just save the html table as a normal html file, then just rename it to xls. If your application is a web application use response.setHeader("Content-Disposition", "attachment; filename=order.xls").
Recent version of excel support Microsoft Office XML Formats, so if the previous solution doesn't work, you may want to try to generate the xml from the html table.
See XML Spreadsheet Reference.
What I do, is to generate the xml from excel in the xml format, then hack into it. You can implement also advanced features like automatic filters, and cool layouts. I used a template engine to generate the xml (Freemarker, it's Java stuff, but I'm sure there are template engines also for .NET)

Tridion 2009 SP1: Image Thumbnails - How to publish the original image as well?

I have a Dynamic Component Template which publishes XML to the Broker database which is then dynamically loaded using the Component Presentation factory.
This Xml contains URLs to Images. I need a thumbnail and a full image to be available. I have managed to use the Image Resizer TBB to produce the thumbnails however, I was hoping that this would add separate package items and binaries that could be referenced, but it seems to overwrite the full size images.
Is there a way I can get both into my Xml and the Package without writing my own custom TBB?
Tridion Content Delivery can store multiple variants of the same Multimedia Component. Each such variant has an ID that identifies it and the variant with no ID (of in newer versions #def# as its ID) is known as the default variant.
When you reference an image from a DWT, it is automatically added as an item to package when the render engine executes your DWT. This item is then later processed by the default "Publish Binaries in Package" TBB that is part of the Default Finish Actions. The Publish Binaries in Package TBB publishes binaries by calling AddBinary on them - you can verify this by looking at the original code for most default TBBs that was published on the Tridion forum here (login required).
appliedTemplateUri = new TcmUri(item.Properties[Item.ItemPropertyTemplateUri]);
...
engine.AddBinary(itemUri, appliedTemplateUri, targetStructureGroup,
data, fileName);
The AddBinary method that is called is defined in the TOM.NET CHM as:
public abstract string AddBinary(
TcmUri componentUri,
TcmUri templateUri,
TcmUri targetLocation,
byte[] data,
string fileName
)
componentUri
The multimedia component this item refers to
templateUri
The template in whose context this AddBinary call is executed (used as variant id)
targetLocation
The location to publish the binary to (if null, publish to standard path)
data
The binary data to publish
fileName
The filename to publish the file under
So as you can see in that last call to AddBinary, the Publish Binaries in Package TBB uses a property (look here if you've never heard of Item.Properties) to determine which variant to publish (and publishes the binary as the default variant if the property is not present).
With all this knowledge in hand, the task becomes quite simple: you have to ensure that there are two binary Items in the package for your MMC, each with a different value of the Item.ItemPropertyTemplateUri property.
The default Image Resizer TBB replaces the binary content of the Item it resizes and does not set this property. So the least code you'll have to write is either a pre-processor TBB that duplicates the item or a post-processor TBB that re-adds the item. In both cases the TBB will have to set the "magic" property too.
Useful links:
the original C# source code of the default template building blocks
a page describing Item.Properties and how to see what they do in your compound template
a recent post on the SDL Tridion forum about the same topic (login required)
Basically all the Image Resizer TBB does is resize the image already in package, so the Default Finish Actions TBBcan publish it (using an AddBinary() call).
So what you require is a slight change in the logic of the Resizer TBB (you need to do something yourself here), so that it does not resize the original item in the package, but publishes a variant of it. Then you have two images available on the delivery side (you can distinguish them by sending the resized image to a different structure group for instance).

How can I create new PDF files based on a template where some text will be replaced?

I'm developing a CMS aplication in ASP .Net using WebForms and I'm looking for a way to create new PDF files based on a template.
This feature will be used to generate contracts where some placeholders will be replaced with the customer data.
What's the best approach to do that?
Edited: The templates will be static, the main content will never change from customer to customer, only some text in the beginning that will contain the placeholders to recive the customer data. The catch is that I must allow the owner of the application to upload new templates in PDF, with the predetermined placeholders in it to allow the replacement to occur.
I can think of two approaches depending on what type of template you are looking at:
1) Static Template - Say the template does not change with the data (Ex.some standard compliance form etc)
You can try something like iTextSharp, where you have your templates defined in your .net code, and you just "plug in" the relevant data and render the PDF via iTextSharp.
2) Dynamic Templates - Say your template isn't standard and is user customizable. In this case, I'd say go for HTML for designing and "print" the for to PDF. There are many components available.
You may also want to try out components like crystal reports.
I'd go with static HTML templates containing substitution tokens e.g. {FullName} which you can then replace with your data. Once you have created an HTML file like this, say in a StringBuilder, you can use PrinceXML or ABCPdf.net (www.websupergoo.com) to transform your HTML into a PDF.
I hope I am understaning this correctly but wouldn't using standard PDF Form Fields give you the functionality and features you require. Load the PDF template into Adobe Acrobat Full or Foxit Phantom and define standard PDF Form Fields on top of the PDF. Each field has a name, position, font etc.
Then just use a standard PDF library to fill in the PDF form fields and 'flatten' the form fields if that is required.
This solution allows the customer to design new PDF layouts and so long as they define form fields with names that match up then you will be able to drop in the replacement form with a simple file copy.
The iText or iTextSharp library should be able to do all of this quite easily. If not them there are many PDF libraries out there that can.

How to display XSL-transformed XML in ASP.NET page?

So far all the XML / XSLT I've worked with takes an XML document and transforms it to a standalone HTML webpage using an XSLT file.
In my web application, I'm using a web service to retrieve the XML document, which I need to render and make human-readable, and then insert that formatted content into a content placeholder in my master page.
The easiest way would be to append the XSLT to the retrieved XML file and link that to the content placeholder, but something tells me I can't just do that.
I took a look at these Stack Overflow pages, but they just want to render the straight XML whereas I want a transformed XML. Also, I need to be able to put it into my master page template.
This article shows how:
http://www.codeproject.com/Articles/37868/Beginners-Introduction-To-XSL-Transform-Rendering-XML-Data-using-XSL-Get-HTML-output.aspx
even if the spelling is as bad as mine...
Added
And here's another link that shows how, perhaps a bit more simply
http://www.aspfree.com/c/a/XML/Applying-XSLT-to-XML-Using-ASP.NET/2/

Resources