[SOLVED] fill ocx container by pdf source

Author: dylan.huart@gmail.com (Dylan)

Hello Wink , I wanted to know how to fill an "OCX​​" by a data source (pdf) stored for example on the c :/ temp I have a FRM which, thanks to a button provides access to the OCX container Thank you for your help

31 Comments

  1. I just indenting my code and ... it works !! this is strange haha..


    Author: Dylan (dylan.huart@gmail.com)
  2. Hi, So, I've successful with a button  from the same "FROM"  without a "display" and "show", but by another "FRM" the problem remains the same : => FRM1 -> click on button -> call FRM2 "execute" ->

    variables HANDLE lh_ocx boolean ln_b endvariables

    show

    lh_ocx = $ocxhandle ( FIELDOCX.CINOMPJ ) lh_ocx->loadfile( ln_b, "c:\test2.pdf" )

    display

    I don't understand...   Dylan   Thank you for your help Wink


    Author: Dylan (dylan.huart@gmail.com)
  3. Although if your code is in the details trigger of a button, you shouldn't need either the show or display. In fact, I think display has no function outside the exec trigger.  I do believe the thing doesn't work unless in an actual runtime environment, (i.e. not from the test function in the IDF).  Also, ensure you have run the adobe reader on your machine and accepted the licence agreement.  (If running his in debug, what is the status on the loadfile operation)   Iain


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  4. Hi Dylan, This should work:
     

    variables HANDLE lh_ocx boolean ln_b endvariables

    show

    lh_ocx = $ocxhandle ( FIELDOCX.CINOMPJ ) lh_ocx->loadfile( ln_b, "c:\test2.pdf" )

    display

     
    And if you want to use display or edit depends on the purpose of the form in question - display: display only, content cannot be changed; edit: content can be changed.
     
    Hope this helps.
     
    Regards, Daniel

    Author: diseli (daniel.iseli@uniface.com)
  5. Hi, Thank you for your information, I'll try to test it one last question : when I do the display or edit ? Regards, Dylan


    Author: Dylan (dylan.huart@gmail.com)
  6. Hi Dylan, $ocxhandle can only be used after the OCX has been instantiated. And this happens when the form on which the OCX is painted has executed a show, edit or display statement. Hope this helps. Regards, Daniel


    Author: diseli (daniel.iseli@uniface.com)
  7. Hi Dylan, If memory serves me right, sometimes the OCX widget has to be 'run' outside the IDF - in other words, tested from a Uniface.exe / application shell environment - and that might be what's causing you the problem. Here's a snippet from the manual:

    Testing

    When the form containing the OCX is run using FileTest in the Development Environment, the OCX control runs in the UDE rather than in your application. This means that the OCX is loaded in a type of development mode (AmbientUserMode=false) that might have some restrictions for the OCX. For more information, see Test Form Components Containing OCX Controls. Regards, Knut


    Author: Knut (knut.dybendahl@gmail.com)
  8. With the ocx widget connected to the ocx container, import the signature (button on the OCX properties form) This should give you a signature caller ACROPDF (I think) The operation to use against this signature is loadfile(boolean,string) e.g. v_filename = "c:\temp\fred.pdf" $ocxhandle(ocx_field)->loadfile(v_loaded,v_filename)   This needs to be done after the edit or show command has been run on the form containing the ocx widget. (so not in the exec trigger, unless there's an explicit show).  Other operations imported with this signature should/will allow you to control which adobe functions are shown in the adobe menu, and to do things like print out the pdf from a uniface button/proc. 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  9. Hello, Thank you for your reply, but I have still the same problem: I create a FRM test to understand the OCX container, in this FRM I create a entity "CINOMPJ" in which I put my OCX, I then assigned AcroPDF then a button , in the trigger "Details" I put this code: variables HANDLE lh_ocx boolean ln_b endvariables lh_ocx = $ocxhandle ( FIELDOCX.CINOMPJ ) lh_ocx->loadfile( ln_b, "c:\test2.pdf" ) display   but when I test the OCX remains gray Cry any idea?   Thank you


    Author: Dylan (dylan.huart@gmail.com)
  10. That OCX will not support image types. (You can't open them in Adobe reader).  What we have done is to paint two widgets, one an OCX widget linked to adobe, and the other a picture widget side by side on the form, and set both of them to attach to window borders (left, right and bottom).  If the loaded file ends in ".pdf" we load it into the ocx as above and hide the picture widget , if not we use  lfileload/image "c:\test2.jpg", FIELDPIC.CINOMPJ and then hide the ocx field. 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  11. Hi, I understood Thank you again


    Author: Dylan (dylan.huart@gmail.com)
  12. You'll probably need to put the adobe loadfile into the occurrence gets focus trigger of the entity, I don't think you get a different copy of the ocx for each occurrence. 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  13. thank you Yes I will try to show (if several) the diferent pdf, for that I have the name of the document in database and based on a  folde number (unique) I must be able to recover it is not yet functional I esayer see how


    Author: Dylan (dylan.huart@gmail.com)
  14. Right click the entity, choose entity scroll bar, choose No.  (I assume the buttons at the top control entity occurrence position? )


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  15. The loadfile operation requires a file on the hard drive. So when you are loading the file into the OCX widget for display, where does that file name come from?  If you are storing the image/pdf in the database, then it's the database field (not the OCX field) which you need to lfiledump.  If you are reading files off the hard drive, and want to copy them to c:\temp check out lfilecopy... 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  16. I think occurrence gets focus is your friend here. However the occurrence is reached (first load, next or previous button) this trigger will be fired. Put your processing for the pdf  and the switch of the fields in here. 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  17. good job It's ok Last question, how save the current file on OCX or Picture in e.g. C:/temp ? Thanks for your help


    Author: Dylan (dylan.huart@gmail.com)
  18. for images  lfiledump/image <field>, <filename> for pdf lfiledump/raw <field>,<filename>


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  19. for images it's ok but for pdf I can't use lfiledump/raw <field>,<filename>, the size of my pdf is 0 octet : if($chaine$ = "pdf")      lfiledump/raw LIBTEXTE.CINOMPJ,$PJOINTE$     if($status > 0)Call GG_AFFMSG("I","", "Le fichier est bien enregistré : %%$PJOINTE$")  else     lfiledump/image IMGPJ.CINOMPJ,$PJOINTE$     if($status > 0)Call GG_AFFMSG("I","", "Le fichier est bien enregistré : %%$PJOINTE$")  Endif


    Author: Dylan (dylan.huart@gmail.com)
  20. Where did you get the file you used in the loadfile command from? 


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  21. In trigger Details of save button


    Author: Dylan (dylan.huart@gmail.com)
  22. I put the "show" at the end of each button event but now the first call from my FRM he doesn't read the first pdf,  for images there are no worries

    Author: Dylan (dylan.huart@gmail.com)
  23. The fields need to be shown or hidden within either your occurrence shifting code (from the buttons), or in the occurrence gets focus trigger of the entity.  There is no need for edit, or display.  Simply set the field_syntax of one field to "HID" and the other one to "" (or is it "DEF"?) to brting it back to view.  You may get results if you replace the code in your button which says edit with 'show'.


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  24. Hello, Thank for your help Ulrich, For the extensions it's good but when I would show a pdf file after an image, nothing :s because "Edit/Display/idle statement only allowed in EXECUTE trigger" I use 2 buttons for navigate between the attachments and this button call an Entries in Local Proc modules showing the next attachments (if I would show the next attachments e.g.) I don't see how I can show otherwise   ideas ? :/


    Author: Dylan (dylan.huart@gmail.com)
  25. for know how the loaded file ends in ".pdf"  what the best method for you ?


    Author: Dylan (dylan.huart@gmail.com)
  26. Method 1 if($lowercase(field[$length(field)-4:4]) = ".pdf") ; Get last 4 characters, compare (limits to 3 char extension) Method 2 (+; = <GOLD>;) if($lowercase($itemnr(-1,$replace(field,1,".","+;",-1))) = "pdf") ; Get string following last . compare. (Allows for many char extension) The first one is simpler, but the second allows for expansion to a case statement testing for different extensions...  selectcase $lowercase($itemnr(-1,$replace(field,1,".","+;",-1)))  case "pdf" ..... case "htm" .... case "html" ..... elsecase .... endselectcase


    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  27. thank you for this complete response, it helps me a lot, and brings new knowledge on uniface


    Author: Dylan (dylan.huart@gmail.com)
  28. you can use $rscan to find the position of the rightmost ".". Use the index returned to separate the extension. If you code the case statements using (syntax) strings in single quotes, you do not need the $lowercase.   selectcase (v_extension) case 'pdf' ...


    Author: ulrich-merkel (ulrichmerkel@web.de)
  29. I come back on the subject for ask you if you know how to load another pdf format in the ocx? e.g. :  .tif,.jpg,.png... Thanks Wink


    Author: Dylan (dylan.huart@gmail.com)
  30. Last question how remove this second slide bar ? :@ (it's on entity)


    Author: Dylan (dylan.huart@gmail.com)
  31. Some information is helpful. Thank for sharing. informdecisions


    Author: johnland (johnland8193@gmail.com)