Pascal Script

  • 05 May

    Check pdf pagewidth in order to move files to a different folder

    Q: A big help would also be a width check. If pdf width > 300 mm move to another folder. Then I could use some system tools on the pdf.

    A: In version v2022.5.5.0 we added some Pascal Script function to achieve this.

    -First we added two WIN destinations.

    • Destination with ID1 should contain the pdf files with a width <= 300 points
    • Destination with ID2 should contain the pdf files with a width > 300 points

    Limagito File Mover multiple Windows destinations

    -Next you’ll some Pascal Script

    Limagito FileMover Pascal Script option

    -Please Add and Enable ‘On Destinations

    Var
      tmpCount: Integer;
      tmpHeight, tmpWidth: Double;
      tmpFile: String;
    Const
      ctMaxWidth = 300;  
    Begin
      psExitCode:= -1;
      // ... add your code here
      tmpFile := psFilePath + psFileName;
      If psPdfGetPageCount(tmpFile, '', tmpCount) Then
        psLogWrite(1, '', 'Page Count of ' + tmpFile +' : ' + IntToStr(tmpCount));
      If psPdfGetPageHeight(psFilePath+psFileName, '', 1, tmpHeight) Then
        psLogWrite(1, '', 'Page Height of ' + tmpFile + ' : ' + FloatToStr(tmpHeight));
      If psPdfGetPageWidth(psFilePath+psFileName, '', 1, tmpWidth) Then
      Begin
        psLogWrite(1, '', 'Page Width of ' + tmpFile + ' : ' + FloatToStr(tmpWidth));
        // Check Width
        // Pdf Files <= ctMaxWidth should go to DestinationID 1 
        // Pdf Files > ctMaxWidth should go to DestinationID 2    
        If (psDestinationID = 'ID1') And (tmpWidth <= ctMaxWidth) Then psExitCode := 1; 
        If (psDestinationID = 'ID2') And (tmpWidth > ctMaxWidth) Then psExitCode := 1;  
      End
      Else
      begin
        // Error Loading Pdf File, set psExitCode to 0
        psExitCode := 0;
      End;   
    End.

    Limagito File Mover Pascal Script

    – RunTime Log Result:

    Limagito File Mover RunTime Log result

    #Filetransfer #PDF

    If you need any info about this ‘Check pdf pagewidth’ option, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Pascal Script PDF ,
  • 31 Mar

    Csv to Xls conversion problems

    Q: Csv to Xls conversion problems. I have a small problem with the conversion of .csv to .xls files. My original file is separated by ; saved as .txt.

    • I also tried with a comma separated .csv and I get the same result.
    • I also tried to import full csv as text
    • I also tried adding a header
    • I still get the same result

    I have attached some screenshots, I have also attached the txt file to convert. My file contains data in French with accents, can this have an impact?

    A: It looks like a problem with the encoding of the txt file. We converted it to UTF8 first using a Pascal Script and afterwards the conversion worked just fine.

    1. Open the Pascal Script option:

    Limagito File Mover Pascal Script option

    2. Enable and add the following ‘On Destination’ Pascal Script. This will first change the Encoding of the Source txt file to UTF8. The conversion to XLS was ok afterwards.

    Var
      tmpFile: String;
    Begin
      psExitCode:= 0;
      // ... add your code here
      tmpFile := psFilePath + psFileName;
      If psChangeTxtEncoding(tmpFile, tmpFile, 0) Then
        psExitCode := 1;
    End.

    Limagito File Mover conversion problems

    More information about the “psChangeTxtEncoding function”:

    Use psChangeTxtEncoding to convert the encoding

    > Encoding possibilities:
    0: UTF8
    1: UTF7
    2: Unicode
    3: Default
    4: BigEndianUnicode
    5: ASCII
    6: ANSI
    7: ASCII TRIM
    8: ANSI TRIM

    i.e. psChangeTxtEncoding(psFilePath + psFileName, psFilePath + psFileName, 0);

    This script will change the encoding of the original source file before it is converted to .xls using XLS as Destination.

    Some extra screenshots of the XLS as Destination setup:

    Limagito File Mover conversion problems

    Limagito File Mover conversion problems

    #Filetransfer #csv #xls

    If you need any info about this ‘conversion problems’ issue, please let us know.

    Best regards,

    Limagito Team

  • 25 Mar

    Email When Transfer Size is not Above 90GBs

    Q: Email When Transfer Size is not Above 90GBs. I have a job that runs everyday and 91GBs is transferred. On some days the job only transfers 60GBs because a file is locked. Is there a way to send an email when Limagito transfers anything under 90Gbs?
    A: Yes this is possible since version v2022.3.25.0. In this option we added some Integer (Int64) Var: psVIA (= Pascal Script Var Integer A).

    You’ll need to add some Pascal Script and Rule Event options to your existing transfer rule.

    1. Open our ‘Pascal Script’ option:

    Limagito File Mover Pascal Script option

    2. Enable and add the following ‘On Rule Begin’ Pascal Script (this script will set the integer psVIA Var to zero):

    Begin
      // ... add your code here
      psExitCode := 1;
      psVIA := 0;
    End.

    Limagito File Mover Email When Transfer Size Pascal Script

    3. Enable and add the following ‘On Rule End’ Pascal Script (this script will return an error internally when the total transfered size is not ok):

    Const
      ctMaxSize = 97710505984; // 90 GByte
    Begin
      psExitCode := 1;
      // Debug
      psLogWrite(1, '', 'End Size: ' + '%VIA');
      // Check
      If psVIA <= ctMaxSize Then
      Begin
        psLogWrite(1, '', 'End Size not above 90GBs');
        psExitCode := 0;
      End;
    End.

    Limagito File Mover Email When Transfer Size Pascal Script

    4. In the Function setup set ‘Destination Options’ to ‘Destination Memory & Exit Cyclus on Error’:

    Limagito File Mover Function Setup

    5. Add a Pascal Script as Destination. If you have multiple Destinations then our Pascal Script must be the last one in the list.

    Limagito File Mover Destinations

    6. Add the following Pascal Script as Destination (this will add the transfered filesize to the psVIA Integer Var):

    Begin
      // ... add your code here
      psExitCode:= 1;
      psVIA := psVIA + psFileSize;
      // Debug
      psLogWrite(1, '', 'Sum of Bytes: ' + Int64ToStr(psVIA));
    End.

    Limagito File Mover As Destination

    7. Open our ‘Rule Events’ option:

    Limagito File Mover Rule Events

    8. Select and enable ‘On Pascal Script Error’ event. With this event selected enable ‘Enable Mail’ and setup the Email and SMTP Setup.

    Limagito File Mover On Pascal Script Error Event

    Limagito File Mover Email Setup

    9. Received email in case 90GBs were not transfered:

    Limagito File Mover Email When Transfer Size email

    10. RunTime log will also show yout when transfered size was not reached:

    Limagito File Mover Email When Transfer Size RunTime Log

     

    #Filetransfer

    If you need any info about this ‘Email When Transfer Size’ request, please let us know.

    Best regards,

    Limagito Team

1 13 14 15 16 17 18 19 29
SEARCH