Portal Engine
Version 3.x > Portal Engine > Use custom functions in CustomEventHandler View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
Bram - 11/11/2008 9:46:36 AM
   
Use custom functions in CustomEventHandler
Hi,

I use a custom event handler for creating a pdf file when a page of a certain class is saved. This works except that i am unable to use functions like "GetImage" to get the path to a picture. Does anybody know which library i'm missing? Or is there another solution?

Kind regards,
Bram


User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/12/2008 4:31:14 AM
   
RE:Use custom functions in CustomEventHandler
Hi,

Could you please describe the scenario with more details?

- Where is the image stored?
- Where you want to place the URL of the image, or where you want to display the image?
- What code are you using right now?

I am sorry for bothering you, but we need to know more details since I am not getting the meaning of the picture in process of creating PDF file.

Thank you in advance.

Best Regards,
Juraj Ondrus

User avatar
Certified Developer v7
Certified  Developer v7
Bram - 11/12/2008 5:23:22 AM
   
RE:Use custom functions in CustomEventHandler
I added the CustomEventHandler project to my solution as described in the DevGuide 3.1s. In the file CustomTreeNodeHandler.cs I added code to the after-update part.

Here I want to generate a PDF based on the document that is being updated at that moment (of a certain custum document type). One of the fields in the custom document type is of the field type "Upload File". Here a user can select an image (ex. bla.jpg) which will be displayed in the webpage on a fixed position.

The layout of the PDF document must be different than the page, so I created a html string in which i insert the document field data:


TreeNode caseDoc = (TreeNode)treeNodeObj;
StringBuilder htmlPageBuilder = new StringBuilder();

htmlPageBuilder.Append("some html code");
htmlPageBuilder.Append(ValidationHelper.GetString(caseDoc.GetValue("Content"), ""));
htmlPageBuilder.Append("some html code");
htmlPageBuilder.Append("<img src=\"path_to_image\" alt=\"\"");

string htmlString = htmlPageBuilder.ToString();


This string is given to the PDF add-on and converted to a PDF file.
Now I wanted to add the path of the image (bla.jpg) to the html string (path_to_image). I can get the guid of the image with caseDoc.GetValue("Image"), but I can't figure out what to do next.

I hope this clears up my first post. If not, just ask what info you are missing...

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 11/12/2008 6:39:08 AM
   
RE:Use custom functions in CustomEventHandler
Hi,

Thank you, now I got the meaning. Could you please read this knowledge base article - http://devnet.kentico.com/Knowledge-Base/API-and-Internals/How-to-display-link-to-a-file-or-document-without-.aspx?

It is very similar to your need. You can find there how to get link to the attached file.
I hope it will help.

Best Regards,
Juraj Ondrus

User avatar
Certified Developer v7
Certified  Developer v7
Bram - 11/13/2008 3:45:49 AM
   
RE:Use custom functions in CustomEventHandler
Thanks!

I've got it working now.

Cheers,
Bram