2Sxc DNN: Custom Input Type: Image Cropper - 2sxc

I'm currently trying to extend the functionality of a 2sxc App in DNN. I created a new content-type and added my custom input-type (image cropper with cropper.js) as explained in this Tutorial:
How To Create Custom Input Fields (v11.2)
It currently looks like this:
And the Data is currently stored as a base64 string.
The last thing that is missing now, is to save the cropped image, if possible with 2sxc ADAM.
I found this Tutorial: Recipe: Form Files SaveInADAM in Your Custom WebAPI, but I don't know where to put the cshtml file.
Here is my current code:
How to save the image with 2sxc ADAM?

This sounds like a great idea.
Just before I guide you to completing this, I would like to note that you could also just save the crop coordinates (instead of the new image) and then use the built in image-resizer to crop to these at runtime.
If you want to do that, you could save the coordinates as json or something in the field.
Now if you really want to save the cropped image, use the SaveInAdam(...) command in your API controller https://docs.2sxc.org/api/dot-net/ToSic.Sxc.Dnn.ApiController.html#ToSic_Sxc_Dnn_ApiController_SaveInAdam_System_String_System_IO_Stream_System_String_System_String_System_Nullable_System_Guid__System_String_System_String_
You can also find examples of this in the Mobius App.

Related

Dynamically updating the view with Handlebars

I'm working on an app using Express.js and Handlebars. I want to have a page where you can enter text into a search bar, and the view will update to display the results of your search. The backend part of this is already working - the data is being retrieved just fine - but I'm not sure how to best go about updating the view.
I'm using express-handlebars for this app, so the views are formatted as .handlebars files, and being sent to the client via the res.render method. I have seen examples of, for instance, using a button to fill out a Handlebars template, but these examples use a static HTML file with a template in a script tag; I don't know how to translate that to what I'm working with.

Get TinyMCE 4.3 Image Tools to save images as regular image files

The new TinyMCE 4.3 Image Tools (eg when cropping) saves images as blob data instead of image files in a directory. the edited mage url is like
blob:http://www.example.com/f2953aa1-e64f-49e1-a6e3-a283986663bf
I want to upload the image file to a specific folder and then use it as regular image referance / path.
Note
The question I am going to put is similar to Image edit issue. but the answer to this question is not working. I also tried http://archive.tinymce.com/forum/viewtopic.php?id=35740 solution but not working because it produces always same name image name.
The basic process is that TinyMCE will create a separate HTTP POST for each image that you modify with the image editor. It will send that image to a URL of your choosing (via HTTP POST) based on the setting of the images_upload_url option in your init.
The image handler at the URL referenced in the images_upload_url (which you have to create) has to do whatever needs to be done to "store" the image in your application. That could mean something like:
Store the item in a folder on your web server
Store the item in a database
Store the item in an asset management system
...regardless of where you choose to store the image your image handler needs to return a single line of JSON telling TinyMCE the new location of the image. As referenced in the TinyMCE documentation this might look like:
{ location : '/uploaded/image/path/image.png' }
TinyMCE will then update the image's src attribute to the value you return. If you use the images_upload_base_path setting in the init that will be prepended to the returned location. The TinyMCE page has more details on all of this:
https://www.tinymce.com/docs/advanced/handle-async-image-uploads/
The net here is that TinyMCE knows when an embedded image exists in your content but it can't possibly know what to do with that image in the context of your application so that job (the "image handler") is something you must create.

Update GUI from Config File in Qt

I am making a GUI in which based on user login a certain number of buttons are supposed to be enabled and the rest disabled. I have to do this with the help of a config file.
Can anyone please share any examples or references if they know.
Thank you :)
You can write a Qt application that parses an xml file by validating it against a predefined xsd file.
The xml file had layout, grid, button text, and other various information for the user.
The goal of this was the end user could create his/her own xml file to custom configure their buttons.
What you need:
Define a data structure that will match your objective
Validate and test XML
Create a widget with whatever kind of layout you want. If you're doing buttons, you probably want to use a QGrid
Load the XML and configure your layout.

how to images store localy from xml using flex 3?

I have one xml link. that link have collections of images(apx 1000 images).
when i flex applications start at the time load all images in locally. then when i need that images then use it.
How i do this... give me some links and logic.
Using flex 3.
Thanks advance.
senthil.
Load the .xml form server or so.
Parse the .xml and create a Map where you store all the image URLs
Place an Image Component on your UI and set the "source" property to the value of the image URL
Flash Plugin will load the image from the URL and will show the image when done.
If you are facing a "SandboxVaiolationException" (or something like that) you need to tell your server to let the request go.
If you want to change the "source" Property of the Image at runtime, just set it after a click oder an other Event. (is no problem)

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.

Resources