Pdf import and open

KisuKisu Member Posts: 381
Basic question: Is it possible to import a pdf file in to a blob object and open the pdf file on a Form? And does the large fields transfer slow between 2 tables (does the DB move the file or just change the pointer or something)?

I guess you need to use "OCX" for opening the pdf and "FILE" for the import am I right on those?

Thanks beforehand :)
K.S.

Answers

  • bostjanlbostjanl Member Posts: 107
    Kisu wrote:
    Basic question: Is it possible to import a pdf file in to a blob object and open the pdf file on a Form? And does the large fields transfer slow between 2 tables (does the DB move the file or just change the pointer or something)?

    I guess you need to use "OCX" for opening the pdf and "FILE" for the import am I right on those?

    Thanks beforehand :)

    Importing can be done blob.IMPORT(FileName).

    Opening can be done with hyperlink. first you have to EXPORT content of blob field with EXPORT to some temp file and then use this temp file in HYPERLINK command.

    bostjanl
  • KisuKisu Member Posts: 381
    bostjanl wrote:

    Importing can be done blob.IMPORT(FileName).

    Opening can be done with hyperlink. first you have to EXPORT content of blob field with EXPORT to some temp file and then use this temp file in HYPERLINK command.

    bostjanl

    Nice! Cheers for the quick ansver :)
    K.S.
  • KisuKisu Member Posts: 381
    Hmm couldn't get this one working.
    I made the code for the import and it goes fine, the table even shows asterisk after the import on the row column, but
    when I try to export the thingy

    (doing it like this cause its list form):
    OnPush()...
    IF GET(mytable.linenmbr) THEN BEGIN //testing that there is the line and getting the pos.
    mytable.thefile.EXPORT(c:\temp\file.pdf);
    MESSAGE('Yay it worked!');
    HYPERLINK(c:\temp\file.pdf);
    END;

    Cant get the "Yay it worked!" you know :-k
    How can I be sure there is data in the field, doesnt that asterisk mark it, and how do I know the compy imported in file.pdf and not file.pdf.bmp or file.pdf.txt :o?
    K.S.
  • KisuKisu Member Posts: 381
    Hyperlink works, still something with inport or export tho
    K.S.
  • SavatageSavatage Member Posts: 7,142
    Kisu wrote:
    IF GET(mytable.linenmbr) THEN BEGIN //testing that there is the line and getting the pos.

    I don't know the structure of your table but this to me "visually" does not seem to be
    1.testing that there is a line
    2.getting the position

    if you are going to use a MESSAGE to test if it's working I would test
    mytable & linenmbr to see if they have a value

    I would think use a FIND

    or if mytable.Get(Linenmber)
  • KisuKisu Member Posts: 381
    Savatage wrote:
    Kisu wrote:
    IF GET(mytable.linenmbr) THEN BEGIN //testing that there is the line and getting the pos.

    I don't know the structure of your table but this to me "visually" does not seem to be
    1.testing that there is a line
    2.getting the position

    if you are going to use a MESSAGE to test if it's working I would test
    mytable & linenmbr to see if they have a value

    The table is populated with rows from xml file, every row has that linenbr.

    On the list form, which shows the imported files rows are sorted by that number and when you use a button on the form you get the line where your cursor is in at that moment.

    the message is there just to show it works now, you get the line where the pdf is located and on that record I'm opening trying to export the blob to a pdf file and then open it with hyper link.
    K.S.
  • SavatageSavatage Member Posts: 7,142
    OK step back - I thought you imported something into a blob field.

    Now you want to export & print it.

    sample/
    yourTable.CALCFIELDS(yourBLOBfield);
    IF yourTABLE.yourBLOBfield.HASVALUE 
    THEN BEGIN 
      yourTABLE.yourBLOBfield.EXPORT('c:\temp\file.pdf',false); 
      HYPERLINK('c:\temp\file.pdf'); 
    END;
    

    HASVALUE will check if it exists or not, but you need to CALCFIELDS else HASVALUE will not work. If I remember correctly
  • SavatageSavatage Member Posts: 7,142
    Another train of thought would be to use LINKS if it's not important to save the PDF IN NAV.
    as discussed here..
    http://www.mibuso.com/forum/viewtopic.php?t=23783
  • KisuKisu Member Posts: 381
    Sorted
    Got the export working like this.
    yourtable.calcfields returnet error that there was no line so I user rec for it so I get the current record where the cursor was.
    Thanks everyone for help ^^

    Rec.CALCFIELDS(Rec.PDFliite);
    IF Rec.PDFliite.HASVALUE
    THEN BEGIN
    Rec.PDFliite.EXPORT('c:\temp\temp.pdf',FALSE);
    HYPERLINK('c:\temp\temp.pdf');
    END;

    Savatage wrote:
    OK step back - I thought you imported something into a blob field.

    Now you want to export & print it.

    sample/
    yourTable.CALCFIELDS(yourBLOBfield);
    IF yourTABLE.yourBLOBfield.HASVALUE 
    THEN BEGIN 
      yourTABLE.yourBLOBfield.EXPORT('c:\temp\file.pdf',false); 
      HYPERLINK('c:\temp\file.pdf'); 
    END;
    

    HASVALUE will check if it exists or not, but you need to CALCFIELDS else HASVALUE will not work. If I remember correctly
    K.S.
  • SavatageSavatage Member Posts: 7,142
    Cool deal - glad it works! \:D/
Sign In or Register to comment.