/*:VRX Main */ /* Main */ Main: /* Process the arguments. Get the parent window. */ parse source . calledAs . parent = "" argCount = arg() argOff = 0 if( calledAs \= "COMMAND" )then do if argCount >= 1 then do parent = arg(1) argCount = argCount - 1 argOff = 1 end end; else do call VROptions 'ImplicitNames' call VROptions 'NoEchoQuit' end InitArgs.0 = argCount if( argCount > 0 )then do i = 1 to argCount InitArgs.i = arg( i + argOff ) end drop calledAs argCount argOff /* Load the windows */ call VRInit parse source . . spec _VREPrimaryWindowPath = , VRParseFileName( spec, "dpn" ) || ".VRW" _VREPrimaryWindow = , VRLoad( parent, _VREPrimaryWindowPath ) drop parent spec if( _VREPrimaryWindow == "" )then do call VRMessage "", "Cannot load window:" VRError(), , "Error!" _VREReturnValue = 32000 signal _VRELeaveMain end /* Process events */ call Init signal on halt do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) ) _VREEvent = VREvent() interpret _VREEvent end _VREHalt: _VREReturnValue = Fini() call VRDestroy _VREPrimaryWindow _VRELeaveMain: call VRFini exit _VREReturnValue VRLoadSecondary: __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 ) if __vrlsWait then do call VRFlush end __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) ) if __vrlsHWnd = '' then signal __vrlsDone if __vrlsWait \= 1 then signal __vrlsDone call VRSet __vrlsHWnd, 'WindowMode', 'Modal' __vrlsTmp = __vrlsWindows.0 if( DataType(__vrlsTmp) \= 'NUM' ) then do __vrlsTmp = 1 end else do __vrlsTmp = __vrlsTmp + 1 end __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd ) __vrlsWindows.0 = __vrlsTmp do while( VRIsValidObject( VRWindow() ) = 1 ) __vrlsEvent = VREvent() interpret __vrlsEvent end __vrlsTmp = __vrlsWindows.0 __vrlsWindows.0 = __vrlsTmp - 1 call VRWindow __vrlsWindows.__vrlsTmp __vrlsHWnd = '' __vrlsDone: return __vrlsHWnd /*:VRX _AddToContainer */ _AddToContainer: FileToAdd = arg(1) RecHandle = VRMethod("CN_PDFs","AddRecord") ok = VRMethod("CN_PDFs","SetfieldData",rechandle,FilenameFH, FileToAdd) return /*:VRX _AdjustButton */ _AdjustButton: ButtonID = arg(1) ButtonNr = arg(2) ok=VRSet(ButtonID,"Left",TBL+TBW*(ButtonNr-1)) ok=VRSet(ButtonID,"Width",TBW) ok=VRSet(ButtonID,"Height",TBW) ok=VRSet(ButtonID,"Top",TBT) return 0 /*:VRX _AdjustToolBar */ _AdjustToolBar: TBT = 10 TBL = 10 TBPixelSize = 26 TBW = VRMethod( "Screen", "PixelsToTwips", TBPixelSize ) ok=VRSet("ToolBar","Left",0) ok=VRSet("ToolBar","Top",TBT) ok=VRSet("ToolBar","Height",trunc(TBW + TBT*2 + 10)) ok = _AdjustButton("ToolBar_Open",1) ok = _AdjustButton("ToolBar_Info",2) ok = _AdjustButton("ToolBar_PreviewToggle",3) ok = _AdjustButton("ToolBar_Split",4) ok = _AdjustButton("ToolBar_Tag",5) ok = _AdjustButton("Toolbar_TargetnameTemplate",6) ok = VRset("ToolBar","Visible",1) return /*:VRX _BrowseBaseFolder */ _BrowseBaseFolder: NewBaseFolder = _DirDialog("Choose a directory to add PDFs", strip(VRget("EF_BaseFolder","Value"),'T','\')) if NewBaseFolder = '' then return LastDir = NewBaseFolder ok = VRSet("EF_BaseFolder","Value",NewBaseFolder) return /*:VRX _CreateOBject */ _CreateOBject: Parse Arg Class, Title, Location, Setup, Collision /* Say 'Creating ['Title']' */ rc = SysCreateObject( Class, Title, Location, Setup, Collision ) If rc <> 1 Then do Msg.Text = ' > failed to create ['Title' | 'Class'] at location ['Location']' Msg.Type = 'Error' call _ShowMsg end return rc /*:VRX _CreateThumbnail */ _CreateThumbnail: if DisablePreview then return /* call VRSet VRWindow(), 'Pointer', 'Wait' */ ok = VRSet("Main", "Enabled", 0) ok = time('reset') SourceFile = arg(1) PreviewFile = VRParseFileName(Sourcefile,'DPN')'-thumb.bmp' if PreviewDPIChanged then ok = SysFileDelete(PreviewFile) ok = VRFileExists(PreviewFile) if \ok then do /* parameterfile for GhostScript */ RspFile = 'Thumbnail.RSP' RspFile = VRParseFileName(Rspfile,'DPNE') ok = SysFileDelete(RspFile) call lineout RspFile, '-I'GSPath'\lib;'GSPath'\..\fonts;'PSFonts /* call lineout RspFile, '-dLastPage=1' */ call lineout RspFile, '-dBATCH -dNOPAUSE' /* call lineout RspFile, '-dDOINTERPOLATE' */ call lineout RspFile, '-sDEVICE=bmp16' call lineout RspFile, '-r'ThumbDPI'x'ThumbDPI call lineout RspFile, '-sOutputFile="'PreviewFile'"' call lineout RspFile, '"'SourceFile'"' ok = stream(RspFile,'c', 'close') GSPath'\bin\gsos2.exe @'RspFile say 'GhostScript RC='RC if RC = 0 then do ok = VRSet("Pict_Thumbnail","PicturePath",PreviewFile) X = Garbage.0 X = X + 1 Garbage.X = PreviewFile Garbage.0 = X end else ok = VRSet("Pict_Thumbnail","PicturePath","#50") end else ok = VRSet("Pict_Thumbnail","PicturePath",PreviewFile) /* call VRSet VRWindow(), 'Pointer', '' */ ok = VRSet("ThumbNail","Caption", VRParsefilename(SourceFile,'NE')) ok = VRSet("ThumbNail","Visible", 1) ok = VRset("Thumbnail","Width",VRget("Pict_Thumbnail","width")+160) ok = VRset("Thumbnail","Height",VRget("Pict_Thumbnail","Height")+400) Dur = time('elapsed') ok = VRSet("DT_Speed","Caption",'['strip(Dur,'T','0')'sec.]') ok = VRSet("Main", "Enabled", 1) return /*:VRX _DirDialog */ _DirDialog: procedure Title = arg(1) InitDir = arg(2) RC = RxFuncQuery("DRCtrlPickDirectory") if RC = 0 then do /* use DrCtrl if available */ MyDir=DRCtrlPickDirectory(InitDir, Title) end else do MyDir = VRFileDialog(VRWindow,Title, 'o', InitDir||'\dummy') if MyDir <> '' then MyDir = strip(filespec('D',MyDir)||Filespec('P',MyDir),'T','\') end return MyDir /*:VRX _ePDF */ _ePDF: MergeFileName = SysTempFileName(TempDir'epdfm???.mpf') ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") ok = _ExportMPF(MergeFileName) LaunchStr = "ePDF.EXE -MERGE:'"MergeFileName"'" Msg.Title= word(VRGet("Main","HintText"),1) Msg.Text = LaunchStr Msg.Type = 'I' call _ShowMsg LaunchStr return /*:VRX _ExportMPF */ _ExportMPF: procedure expose PDFFiles. MergeFile = arg(1) call lineout MergeFile, 'program 'VRGet("Main","HintText") call lineout MergeFile, 'files 'PDFFiles.0 do I = 1 to PDFfiles.0 call lineout MergeFile, strip(PDFFiles.I,,'+') end ok = stream(MergeFile,'c','close') return 1 /*:VRX _GUIInit */ _GUIInit: say Import if Import then do if _ImportMPF(MPFFile) then do say 'Jawohl!' ok = VRMethod("LB_PDFs","Reset") ok = VRMethod("LB_PDFs","AddStringList", PDFFiles.) if \UseBuiltInDistiller then ok = VRSet("IPB_merge","Enabled",1) end else do Msg.Text = 'Failed to import "'MPFFile'"!' Msg.Type = 'E' call _ShowMsg end end ok = VRset("CB_TaggedFilesOnly","Set",TaggedFilesOnly) BD = 400 ok = VRseT("IPB_AddPDF","Top", 241+BD*0) ok = VRseT("IPB_AddPDF","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_AddPDF","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_RemovePDF","Top",241+BD*1) ok = VRseT("IPB_RemovePDF","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_RemovePDF","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_UpPDF","Top",241+BD*2) ok = VRseT("IPB_UpPDF","Width", VRMethod( "Screen", "PixelsToTwips", 40 )) ok = VRseT("IPB_UpPDF","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_DownPDF","Top",241+BD*2) ok = VRseT("IPB_DownPDF","Width", VRMethod( "Screen", "PixelsToTwips", 40 )) ok = VRseT("IPB_DownPDF","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_AddMany","Top",241+BD*3) ok = VRseT("IPB_AddMany","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_AddMany","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_EmptyPage","Top",241+BD*4) ok = VRseT("IPB_EmptyPage","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_EmptyPage","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_Reset","Top",241+BD*5) ok = VRseT("IPB_Reset","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_Reset","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_ErasePDF","Top",241+BD*6) ok = VRseT("IPB_ErasePDF","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_ErasePDF","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_Merge","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_Merge","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_Cancel","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_Cancel","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_SavePDF","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_SavePDF","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) call _GUIModeSwitch if WinTop <> "" then ok = VRSet("Main","Top",WinTop) if WinLeft <> "" then ok = VRSet("Main","Left",WinLeft) if ThumbTop <> "" then ok = VRSet("Thumbnail","Top",ThumbTop) if ThumbLeft <> "" then ok = VRSet( "Thumbnail", "Left", ThumbLeft) ok = VRSet("ThumbNail","Visible", 0) ok = VRSet("Menu_Contextmenu_TogglePreview","Checked", \DisablePreview) call _AdjustToolbar ok = VRSet("Main", "Visible", 1) return /*:VRX _GUIModeSwitch */ _GUIModeSwitch: ok = VRSet("GB_Target","Visible",UseBuiltInDistiller) ok = VRSet("GB_Target","Enabled",UseBuiltInDistiller) ok = VRSet("EF_TargetName","Enabled",UseBuiltInDistiller) ok = VRSet("IPB_SavePDF","Enabled",UseBuiltInDistiller) if UseBuiltinDistiller then do ok = VRseT("IPB_Print","Top",4830) ok = VRseT("IPB_Merge","Top",4830) ok = VRseT("IPB_Cancel","Top",4830) ok = VRSet("Main","Height", 6230) end else do ok = VRseT("IPB_Print","Top",4000) ok = VRseT("IPB_Merge","Top",4000) ok = VRseT("IPB_Cancel","Top",4000) ok = VRSet("Main","Height", 5400) end return /*:VRX _ImportMPF */ _ImportMPF: procedure expose PDFFiles. MPFFile = arg(1) say MPFFile ok = SysFileTree(MPFFile, 'Exists.','FO') if Exists.0 = 1 then do Line1 = linein(MPFFile) parse var Line1 'program ' Origin say Origin Line1 = linein(MPFFile) parse var Line1 'files ' NrOfSrcFiles say NrOfSrcFiles PDFFiles.0 = NrOfSrcFiles do I = 1 to PDFfiles.0 PDFfiles.I = linein(MPFFile) say PDFFiles.I end ok = stream(MPFFile,'c','close') RtC = 1 end else RtC = 0 return RtC /*:VRX _INIRead */ _INIRead: ePDFINI = "ePDF.INI" ok = SysFileTree(ePDFINI, INIFound.,'FO') if INIFound.0 = 1 then ePDFINI = INIFound.1 else do MsgType = 'E' Msg.Title= 'ePDFMerge' Msg.Text = 'ePDF.INI not found. Aborting...' call _ShowMsg call Quit end readybeep = VRGetIni( "options", "readybeep", ePDFINI , "NoClose" ) pdflaunch = VRGetIni( "options", "pdflaunch", ePDFINI , "NoClose" ) UseBuiltinDistiller = VRGetIni( "pdfmerge", "usebuiltin", ePDFINI , "NoClose" ) UseePDFparms = VRGetIni( "pdfmerge", "useepdfparms", ePDFINI , "NoClose" ) TaggedFilesOnly = VRGetIni( "pdfmerge", "taggedfilesonly", ePDFINI , "NoClose" ) PSQueue = VRGetIni( "pdfmerge", "psqueue", ePDFINI , "NoClose" ) DisablePreview = VRGetIni( "pdfmerge", "previewdisable", ePDFINI , 'NoClose' ) AddManyMask = VRGetIni( "pdfmerge", "addmanymask", ePDFINI , 'NoClose' ) if UseBuiltinDistiller = '' then UseBuiltinDistiller = 1 if UseePDFparms = '' then UseePDFparms = 0 if PSQueue = '' then PSQueue = '' if TaggedFilesOnly = '' then TaggedFilesOnly = 0 if DisablePreview = '' then DisablePreview = 0 if AddManyMask = '' then AddManyMask = '*.pdf' WinTop = VRGetIni( "pdfmerge", "top", ePDFINI , "NoClose" ) WinLeft = VRGetIni( "pdfmerge", "left", ePDFINI , "NoClose" ) ThumbTop = VRGetIni( "pdfmerge", "previewposy", ePDFINI , "NoClose" ) ThumbLeft = VRGetIni( "pdfmerge", "previewposx", ePDFINI , "NoClose" ) ThumbDPI = VRGetIni( "pdfmerge", "previewdpi", ePDFINI , "NoClose" ) if ThumbDPI = '' then ThumbDPI = '25' FileMask = VRGetIni( "pdfmerge", "filemask", ePDFINI , "NoClose" ) if FileMask = '' then FileMask = '*.pdf' PDFPath = strip(VRGetIni('pdffile', 'pdf_dir', ePDFINI ),,'0'x) PDFPath = strip(PDFPath,'T','\') LastDir = VRGetIni( "pdfmerge", "lastdir", ePDFINI , "NoClose" ) if LastDir = '' then LastDir = PDFPATH CurDist = strip(VRGetIni('ghostscript','distiller_selected', ePDFINI, 'NoClose' ),,'0'x) CurDistStuff = strip(VRGetIni('distiller', CurDist , ePDFINI, 'NoClose' ),,'0'x) CurParms = strip(VRGetIni('ghostscript','parameter_selected', ePDFINI, 'NoClose' ),,'0'x) CurParmStr = strip(VRGetIni('parameter', CurParms , ePDFINI ),,'0'x) GsPATH = strip(left(CurDistStuff,pos('\bin\',CurDistStuff)),'T','\') PsFonts = SysBootDrive()'\PSFonts' Import = 0 PreviewDPIChanged = 0 Garbage.0 = 0 PrtDriver = '' CRLF = '0D0A'x return /*:VRX _InitTempDir */ _InitTempDir: say 'Main: _InitTempDir()' /* Get temporary directory */ TempDir = value('TEMP',,'OS2ENVIRONMENT') if TempDir = '' then TempDir = value('TMP',,'OS2ENVIRONMENT') if TempDir = '' then TempDir = value('TMPDIR',,'OS2ENVIRONMENT') if TempDir = '' then TempDir = directory() TempDir = strip(TempDir,'T','\')||'\' say 'Main: _InitTempDir() done' return /*:VRX _InitXPDF */ _InitXPDF: PDFInfoEXE = SysSearchPath('PATH', 'PDFINFO.EXE') PDFTOPSEXE = SysSearchPath('PATH', 'PDFTOPS.EXE') PDFFONTSEXE= SysSearchPath('PATH', 'PDFFONTS.EXE') PDFTOPSEXE' 2>XPDF.ERR' ErrLine = linein('XPDF.ERR') ok = stream('XPDF.ERR','c','close') ok = SysFileDelete('XPDF.ERR') if left(Errline,3) = 'SYS' then do Msg.Title = 'Initializing XPDF components' Msg.Text = 'Cannot execute XPDF components - 'ErrLine Msg.Type = 'E' call _ShowMsg PDFTOPSEXE = '' PDFInfoEXE = '' PDFFontsEXE= '' end if PDFInfoEXE = '' then ok = VRset("Menu_Contextmenu_Info","Enabled", 0) if PDFTOPSEXE = '' then ok = VRset("Menu_Contextmenu_Split","Enabled", 0) return /*:VRX _INIWrite */ _INIWrite: ok = VRSetIni( "pdfmerge", "filemask", FileMask, ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "usebuiltin", UseBuiltinDistiller, ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "useepdfparms", UseePDFParms, ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "top", VRGet("Main","Top"), ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "left", VRGet("Main","left"), ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "psqueue", psqueue, ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "previewposx", VRget("Thumbnail","Left"), ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "previewposy", VRget("Thumbnail","Top"), ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "previewdpi", ThumbDPI, ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "previewdisable", DisablePreview, ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "addmanymask", AddManyMask, ePDFINI, 'NoClose' ) ok = VRSetIni( "pdfmerge", "lastdir", LastDir, ePDFINI) return /*:VRX _InstallObject */ _InstallObject: CreateCollision = 'R' rc = _CreateObject( 'WPProgram','ePDFmerge','',, 'EXENAME='||VRget("Application","Program")||';'||, 'PARAMETERS=/MIN;'||, 'STARTUPDIR='||VRParseFilename(VRget("Application","Program"),'DP')||';'||, 'PROGTYPE=PM;'||, 'TITLE=ePDFMerge;'||, 'NOPRINT=YES;'||, 'MINWIN=DEFAULT;'||, 'CCVIEW=DEFAULT;'||, 'OBJECTID=',, CreateCollision ) return /*:VRX _LoadOtherFuncs */ _LoadOtherFuncs: ok = VRRedirectStdIO('OFF') /* Load RexxUtil */ call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs /* Deal with DRCtrlxxx */ RC = RxFuncQuery("DRCtrlPickDirectory") if RC = 1 then do /* DRCtrlXXX not already registered */ /* Load DRCtrl functions */ ok = RxFuncAdd('DRCtrlLoadFuncs', 'drctl017', 'DRCtrlLoadFuncs') if ok = 0 then CALL DRCtrlLoadFuncs end return /*:VRX _MsgYesNo */ _MsgYesNo: buttons.0 = 2 buttons.1 = "~"Yes buttons.2 = "~"No default = 2 buttons.default = "~"No esc = 2 buttons.esc = "~"No RC = VRMessage( VRWindow(), Msg.Text, Msg.Title,"Q",buttons.,default, esc ) /* say 'Antwort: 'RC */ return RC /*:VRX _ParseCommandLine */ _ParseCommandLine: say 'Started _ParseCommandline()' CmdLine = translate(VRGet("Application","Commandline")) say ' CmdLine='CmdLine OrgCmdLine = VRGet("Application","Commandline") say ' OrgCmdLine='OrgCmdLine if pos('.MPF"',CmdLine) > 0 then do /* MPF file with blanks */ end else if pos('.MPF',CmdLine) > 0 then do /* MPF file without blanks */ rpos = pos('.MPF',CmdLine) lpos = lastpos(' ',CmdLine,rpos) + 1 Import = 1 MPFfile = substr(CMDLine,lpos, rpos+4-lpos) end if pos('/MERGE:',CmdLine) > 0 then do Import = 1 Fpos = pos('/MERGE:',CmdLine) + 7 MPFFile = strip(substr(CmdLine,FPos),,"'") end if pos('/MAKEOBJ', CmdLine) > 0 then do call _InstallObject end if pos('/DEBUG', CmdLine) > 0 then do call Menu_File_Debug_Click end return /*:VRX _RemoveGarbage */ _RemoveGarbage: do I = 1 to Garbage.0 ok = SysfileDelete(Garbage.I) end Garbage.0 = 0 PreviewDPIChanged = 0 return /*:VRX _ShowMsg */ _ShowMsg: Buttons.1 = "OK" Buttons.0 = 1 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 ) return /*:VRX _SimpleDistiller */ _SimpleDistiller: Outputfile = VRget("EF_TargetName","Value") /* Check whether targetfile alread exists */ ok = SysFileTree(Outputfile, 'Files.', 'FO') if Files.0 = 1 then do Msg.Title= 'PDF-Merge' Msg.Type = 'Q' Msg.Text = '"'Files.1'" already exists. Overwrite it?' ok = _MsgYesNo() if ok = 2 then do Msg.Type = 'W' Msg.Text = 'PDF file merging process aborted.' call _ShowMsg return end end /* determine script filename */ ScriptFile = 'PDFMrg.CMD' ScriptFile = VRParseFilename(ScriptFile,"DPNE") ok = SysFileDelete(ScriptFile) /* write script header */ call lineout ScriptFile, '@echo off' call lineout ScriptFile, 'rem 'VRget("Main","HintText") ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") if PDFFiles.0 > 1 then do call charout Scriptfile, GSPath'\bin\gsos2.exe -I'GSPath'\lib;'GSPath'\..\fonts;'PSFonts' -dBATCH -dNOPAUSE -dNOPLATFONTS -sPAPERSIZE=a4 -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dEmbedAllFonts=true -sOutputFile="'OutPutFile'" ' do I = 1 to PDFFiles.0 call charout ScriptFile, '"'PDFFiles.I'" ' end call lineout ScriptFile, ' ' ok = stream(ScriptFile,'c','close') /* ok = VRRedirectStdIO('ON') */ 'call 'scriptfile say 'GhostScript RC='RC if RC = 0 then do /* write Acrobat document EA to PDF file */ rc = SysPutEa(OutPutFile, '.type', x2c(DFFF00000100FDFF10004163726F62617420446F63756D656E74)) if readybeep = 1 | readybeep = 'ERROR:' then do beep(1000,200) beep(800,200) end /* ok = VRRedirectStdIO('OFF') */ if pdflaunch then ok = SysOpenObject(VRParseFileName(OUTPUTFILE),'DEFAULT','TRUE') ok = VRSet("IPB_ErasePDF","Enabled",1) end else do Msg.Type = 'E' Msg.Text = 'GhostScript error return code: 'RC Msg.Title= 'PDFMerge' call _ShowMsg end end return /*:VRX _SimpleDistiller2 */ _SimpleDistiller2: /* Outputfile stuff */ Outputfile = VRget("EF_TargetName","Value") ok = SysFileTree(Outputfile, 'Files.', 'FO') if Files.0 = 1 then do Msg.Title= 'PDF-Merge' Msg.Type = 'Q' Msg.Text = '"'Files.1'" already exists. Overwrite it?' ok = _MsgYesNo() if ok = 2 then do Msg.Type = 'W' Msg.Text = 'PDF file merging process aborted.' call _ShowMsg return end end /* get files to merge */ ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") /* parameterfile for GhostScript */ RspFile = 'ePDFMerge.RSP' ok = SysFileDelete(RspFile) call lineout RspFile, '-I'GSPath'\lib;'GSPath'\..\fonts;'PSFonts call lineout RspFile, '-sDEVICE=pdfwrite' call lineout RspFile, '-dBATCH -dNOPAUSE' if UseePDFParms then do call lineout RspFile, CurParmStr end else do call lineout RspFile, '-dNOPLATFONTS' call lineout RspFile, '-sPAPERSIZE=a4' call lineout RspFile, '-dPDFSETTINGS=/screen' call lineout RspFile, '-dEmbedAllFonts=true' end call lineout RspFile, '-sOutputFile="'OutPutFile'"' do I = 1 to PDFFiles.0 if \VRGet("CB_TaggedFilesOnly","Set") then call lineout RspFile, '"'strip(PDFFiles.I,,'+')'"' else do if left(PDFFiles.I,1) = '+' then call lineout RspFile, '"'strip(PDFFiles.I,,'+')'"' end end ok = stream(RspFile,'c','close') /* Distill */ say 'Distill now!' GSPath'\bin\gsos2.exe @'RspFile say 'GhostScript RC='RC if RC = 0 then do /* write Acrobat document EA to PDF file */ rc = SysPutEa(OutPutFile, '.type', x2c(DFFF00000100FDFF10004163726F62617420446F63756D656E74)) if readybeep = 1 | readybeep = 'ERROR:' then do beep(1000,200) beep(800,200) end if pdflaunch then ok = SysOpenObject(VRParseFileName(OUTPUTFILE),'DEFAULT','TRUE') ok = VRSet("IPB_ErasePDF","Enabled",1) end else do Msg.Type = 'E' Msg.Text = 'GhostScript error return code: 'RC Msg.Title= 'PDFMerge' call _ShowMsg end return /*:VRX AddMany_Close */ AddMany_Close: call AddMany_Fini return /*:VRX AddMany_Create */ AddMany_Create: call AddMany_Init ok = VRSet("EF_AddManyMask","Value",AddManyMask) ok = VRSet("EF_BaseFolder","Value",LastDir) Recurse = 0 ok = VRseT("IPB_AddManyPDFs","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_AddManyPDFs","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_CancelManyPDFs","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_CancelManyPDFs","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_ChooseDir","Width", VRMethod( "Screen", "PixelsToTwips", 40 )) ok = VRseT("IPB_ChooseDir","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) return /*:VRX AddMany_Fini */ AddMany_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX AddMany_Init */ AddMany_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX CB_DisablePreview_Click */ CB_DisablePreview_Click: DisablePreview = VRGet("CB_DisablePreview","Set") return /*:VRX CB_Recurse_Click */ CB_Recurse_Click: Recurse = VRget("CB_Recurse","Set") return /*:VRX CB_TaggedFilesOnly_Click */ CB_TaggedFilesOnly_Click: TaggedFilesOnly = VRget("CB_TaggedFilesOnly","set") return /*:VRX CB_UseePDFparms_Click */ CB_UseePDFparms_Click: UseePDFParms = VRGet("CB_UseePDFparms","set") return /*:VRX Components_Close */ Components_Close: call Components_Fini return /*:VRX Components_Create */ Components_Create: call Components_Init ok = VRSet("EF_ePDFINI","Value",ePDFINI) ok = VRSet("EF_PDFTOPSEXE","Value",PDFTOPSEXE) ok = VRSet("EF_PDFINFOEXE","Value",PDFINFOEXE) ok = VRSet("EF_PDFFONTSEXE","Value",PDFFONTSEXE) ok = VRSet("EF_GSPATH","Value",GSPATH'\bin\gsos2.exe') ok = VRSet("EF_GSIPATH","Value",GSPath'\lib;'GSPath'\..\fonts;'PSFonts) return /*:VRX Components_Fini */ Components_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX Components_Init */ Components_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX DDCB_FileMask_Change */ DDCB_FileMask_Change: FileMask=VRget("DDCB_FileMask","Value") return /*:VRX EF_AddManyMask_Change */ EF_AddManyMask_Change: AddManyMask = VRGet("EF_AddManyMask","Value") return /*:VRX EF_BaseFolder_Change */ EF_BaseFolder_Change: LastDir = VRGet("EF_BaseFolder","Value") ok = VRFileExists(LastDir) if \OK then ok = VRSet("EF_BaseFolder","ForeColor","DarkRed") else ok = VRSet("EF_BaseFolder","ForeColor","") return /*:VRX EF_psqueue_Change */ EF_psqueue_Change: psqueue = VRGet("EF_psqueue","Value") return /*:VRX EF_TargetName_Change */ EF_TargetName_Change: Outputfile = translate(VRGet("EF_TargetName","Value")) ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") InSource = 0 do X = 1 to PDFFiles.0 if Outputfile = translate(PDFfiles.X) then do InSource = 1 leave end end if InSource then do ok = VRset("EF_TargetName","BackColor","Red") call beep 800, 200 end else ok = VRset("EF_TargetName","BackColor","") if Outputfile = "" | PDFFiles.0 = 0 | InSource = 1 then do if UseBuiltInDistiller then ok = VRSet("IPB_merge","Enabled",0) else ok = VRSet("IPB_merge","Enabled",1) end else ok = VRSet("IPB_merge","Enabled",1) return /*:VRX EF_TargetName_ContextMenu */ EF_TargetName_ContextMenu: if VRget("EF_TargetName","Value") <> "" then ok = VRMethod( "Menu_LockMenu", "Popup", , , "", "" ) return /*:VRX Fini */ Fini: window = VRWindow() call VRSet window, "Visible", 0 drop window return 0 /*:VRX GSdevice_Close */ GSdevice_Close: call GSdevice_Fini return /*:VRX GSdevice_Create */ GSdevice_Create: call GSdevice_Init if PrtDriver = '' then do nop end else do select when PrtDriver = 'LASERJET' then do ok = VRSet("RB_ps2write","Enabled", 0) ok = VRSet("RB_epswrite","Enabled", 0) ok = VRSet("RB_ibmpro","Enabled", 0) GSDevice = 'laserjet' ok = VRSet("RB_laserjet","Set", 1) end when left(PrtDriver,7) = 'PSCRIPT' then do ok = VRSet("RB_laserjet","Enabled", 0) ok = VRSet("RB_pxlcolor","Enabled", 0) ok = VRSet("RB_pxlmono","Enabled", 0) ok = VRSet("RB_ibmpro","Enabled", 0) GSDevice = 'ps2write' ok = VRSet("RB_ps2write","Set", 1) end when left(PrtDriver,7) = 'FXPRINT' then do ok = VRSet("RB_ps2write","Enabled", 0) ok = VRSet("RB_epswrite","Enabled", 0) ok = VRSet("RB_pxlcolor","Enabled", 0) ok = VRSet("RB_pxlmono","Enabled", 0) GSDevice = 'ibmpro' ok = VRSet("RB_ibmpro","Set", 1) end otherwise do Msg.Type = 'E' Msg.Title = 'Unsupported printer 'PrtName Msg.Text = 'This printer is not supported by this application!' call _showMsg call PB_Back_Click end end end return /*:VRX GSdevice_Fini */ GSdevice_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX GSdevice_Init */ GSdevice_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Halt */ Halt: signal _VREHalt return /*:VRX InfoFonts_Close */ InfoFonts_Close: call InfoFonts_Fini return /*:VRX InfoFonts_Create */ InfoFonts_Create: call InfoFonts_Init PDFFontsStr = '' do I = 1 to PDFFonts.0 PDFFontsStr = PDFFontsStr||CRLF||" "left(PDFFonts.I,50) end ok = VRSet("DT_PDFFonts","Caption",PDFFontsStr) return /*:VRX InfoFonts_Fini */ InfoFonts_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX InfoFonts_Init */ InfoFonts_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX InfoGeneral_Close */ InfoGeneral_Close: call InfoGeneral_Fini return /*:VRX InfoGeneral_Create */ InfoGeneral_Create: call InfoGeneral_Init ok = VRSet("PDFinfo","Caption","About "Sourcefile) PDFInfoStr = '' do I = 1 to PDFInfo.0 PDFInfoStr = PDFInfoStr||CRLF||" "PDFInfo.I end ok = VRSet("DT_PDFInfo","Caption",PDFInfoStr) ok = VRseT("IPB_PDFInfo_OK","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_PDFInfo_OK","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) return /*:VRX InfoGeneral_Fini */ InfoGeneral_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX InfoGeneral_Init */ InfoGeneral_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Init */ Init: window = VRWindow() call VRMethod window, "CenterWindow" call VRSet window, "Visible", 0 call VRMethod window, "Activate" drop window return /*:VRX IPB_AddMany_Click */ IPB_AddMany_Click: window = VRLoadSecondary( "AddMany", "W" ) return /*:VRX IPB_AddManyPDFs_Click */ IPB_AddManyPDFs_Click: if Recurse then Options = 'FOS'; else Options = 'FO' status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if selects.0 = 0 then status = \status ok = SysFileTree(VRGet("EF_BaseFolder","Value")'\'VRGet("EF_AddManyMask","value"),AddMany.,Options) if \status then ok = VRMethod("LB_PDFs","AddStringList","AddMany.") else ok = VRMethod("LB_PDFs","AddStringList","AddMany.", selects.1+1) call AddMany_Close return /*:VRX IPB_AddPDF_Click */ IPB_AddPDF_Click: FileName = VRFileDialog( VRWindow(), "Add PDF file", "Open", LastDir||"\"FileMask, , , , "SelFiles." ) if Filename <> "" | SelFiles.0 <> 0 then do status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if selects.0 = 0 then status = \status LastDir = strip(Filespec('D',FileName)||Filespec('P',Filename),'T','\') OutPutFile = LastDir'\'VRParseFileName(Filename,'N')'-Merged.PDF' if \status then ok = VRMethod("LB_PDFs","AddStringList","SelFiles.") else ok = VRMethod("LB_PDFs","AddStringList","SelFiles.", selects.1+1) do I = 1 to SelFiles.0 /* call _AddToContainer Selfiles.I */ call _CreateThumbNail SelFiles.I end if \ManuallyChosen then ok = VRset("EF_TargetName","Value", OutPutFile) end return /*:VRX IPB_Cancel_Click */ IPB_Cancel_Click: call Main_Close return /*:VRX IPB_Cancel_Properties_Click */ IPB_Cancel_Properties_Click: UseBuiltInDistiller = OldDistiller FileMask = OldFileMask UseePDFparms = OldUseePDFparms ThumbDPI = OldThumbDPI DisablePreview = OldDisablePreview call Properties_Close return /*:VRX IPB_CancelManyPDFs_Click */ IPB_CancelManyPDFs_Click: call AddMany_Close return /*:VRX IPB_ChooseDir_Click */ IPB_ChooseDir_Click: call _BrowseBaseFolder return /*:VRX IPB_CloseComponents_Click */ IPB_CloseComponents_Click: call Components_Close return /*:VRX IPB_DownPDF_Click */ IPB_DownPDF_Click: obj = "LB_PDFs" ok = VRMethod( "LB_PDFs", "GetStringList", "AllPDFs." ) status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if( \status )then do return end if( selects.0 = 0 )then do return end Me = selects.1 if Me < AllPDFs.0 then do DN = Me + 1 Parking = AllPDFs.DN AllPDfs.DN = AllPDFs.Me AllPDfs.Me = Parking ok = VRMethod("LB_PDFs", "Reset") ok = VRMethod("LB_PDFs", "AddStringList", "AllPDFs.") selects.1 = DN ok = VRMethod("LB_PDFs", "SetSelectedList", "selects." ) end return /*:VRX IPB_EmptyPage_Click */ IPB_EmptyPage_Click: status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if selects.0 = 0 then status = \status Empty = VRget("Application","Program") Empty =filespec('D',Empty)||filespec('P',Empty)||'Empty.PDF' if \status then ok = VRMethod("LB_PDFs","addString",Empty) else ok = VRMethod("LB_PDFs","addString",Empty,selects.1+1) return /*:VRX IPB_ErasePDF_Click */ IPB_ErasePDF_Click: Msg.Title = 'PDFMerge' Msg.Text = 'Are you sure you want to delete the source PDF/PS files from disk?' Msg.Type = 'Q' ok = _MsgYesNo() if ok = 1 then do ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") if PDFFiles.0 > 0 then do do I = 1 to PDFfiles.0 if translate(VRParseFilename(strip(PDFfiles.I,,'+'),'NE')) <> 'EMPTY.PDF' then ok = SysFileDelete(strip(PDFfiles.I,,'+')) end ok = VRMethod("LB_PDFs","Reset") ok = VRSet("IPB_ErasePDF","Enabled",0) ok = VRSet("EF_TargetName","Value","") end call _RemoveGarbage ok = VRSet("Thumbnail","Visible", 0) end return /*:VRX IPB_Merge_Click */ IPB_Merge_Click: if UseBuiltInDistiller then do call _SimpleDistiller2 end else do call _ePDF end return /*:VRX IPB_PDFinfo_OK_Click */ IPB_PDFinfo_OK_Click: call PDFInfo_Close return /*:VRX IPB_Print_Click */ IPB_Print_Click: if PDFFiles.0 = 0 then return window = VRLoadSecondary( "PrintWizard", "W" ) return /*:VRX IPB_RemovePDF_Click */ IPB_RemovePDF_Click: obj = "LB_PDFs" status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if( \status )then do return end if( selects.0 = 0 )then do return end do i = 1 to selects.0 ok = VRMethod( obj, "Delete", selects.I ) end ok = VRSet("Thumbnail","Visible", 0) return /*:VRX IPB_Reset_Click */ IPB_Reset_Click: ManuallyChosen = 0 ok = VRMethod("LB_PDFs", "Reset") ok = VRSet("IPB_ErasePDF","Enabled",0) ok = VRSet("EF_TargetName","Value","") call _RemoveGarbage ok = VRSet("Thumbnail","Visible", 0) return /*:VRX IPB_Save_Properties_Click */ IPB_Save_Properties_Click: say 'UseBuiltinDistiller='UseBuiltinDistiller ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") if PDFFiles.0 > 0 then do do I = 1 to PDFfiles.0 SourceFile = strip(PDFfiles.I,,'+') PreviewFile = VRParseFileName(Sourcefile,'DPN')'-thumb.bmp' ok = SysFileDelete(PreviewFile) end PreviewDPIChanged = 0 end else PreviewDPIChanged = 0 call _GUIModeSwitch call _INIWrite call Properties_Close return /*:VRX IPB_SavePDF_Click */ IPB_SavePDF_Click: FileName = VRFileDialog( VRWindow(), "Save merged PDF file as", "Save", "*.PDF", , , ) if Filename <> "" then do ManuallyChosen = 1 ok = VRset("Menu_LockMenu_LockTargetfilename","Checked",1) ok = VRset("Menu_LockMenu_UnLockTargetfilename","Checked",0) ok = VRset("EF_TargetName","Value", Filename) end return /*:VRX IPB_UpPDF_Click */ IPB_UpPDF_Click: obj = "LB_PDFs" ok = VRMethod( "LB_PDFs", "GetStringList", "AllPDFs." ) status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if( \status )then do return end if( selects.0 = 0 )then do return end Me = selects.1 if Me > 1 then do DN = Me - 1 Parking = AllPDFs.DN AllPDfs.DN = AllPDFs.Me AllPDfs.Me = Parking ok = VRMethod("LB_PDFs", "Reset") ok = VRMethod("LB_PDFs", "AddStringList", "AllPDFs.") selects.1 = DN ok = VRMethod("LB_PDFs", "SetSelectedList", "selects." ) end return /*:VRX LB_PDFs_Click */ LB_PDFs_Click: SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') call _CreateThumbNail SourceFile return /*:VRX LB_PDFs_ContextMenu */ LB_PDFs_ContextMenu: obj = "LB_PDFs" status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if( \status )then do return end if( selects.0 = 0 )then do return end SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') if translate(VRparseFileName(SourceFile,'E')) = "PS" then do ok = VRset("Menu_Contextmenu_Open","Enabled", 0) ok = VRset("Menu_Contextmenu_Info","Enabled", 0) ok = VRset("Menu_Contextmenu_Split","Enabled", 0) end else do ok = VRset("Menu_Contextmenu_Open","Enabled", 1) if PDFInfoEXE <> '' then ok = VRset("Menu_Contextmenu_Info","Enabled", 1) if PDFTOPSEXE <> '' then ok = VRset("Menu_Contextmenu_Split","Enabled", 1) end ok = VRMethod( "Menu_Contextmenu", "Popup", , , "", "" ) return /*:VRX LB_PDFs_DoubleClick */ LB_PDFs_DoubleClick: SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') if Sourcefile <> "" then ok = SysOpenObject(SourceFile,'DEFAULT','TRUE') return /*:VRX LB_PDFs_DragDrop */ LB_PDFs_DragDrop: DragPDFFile = VRInfo("SourceFile") ok = VRMethod("LB_PDFs","AddString",DragPDFFile) OutPutFile = LastDir'\'VRParseFileName(DragPDFFile,'N')'-Merged.PDF' /* ok = VRMethod("LB_PDFs","AddStringList","SelFiles.") */ if \ManuallyChosen then ok = VRset("EF_TargetName","Value", OutPutFile) return /*:VRX Main_Close */ Main_Close: ok = VRREdirectStdio('OFF') call _INIWrite call _RemoveGarbage call Quit return /*:VRX Main_Create */ Main_Create: call _LoadOtherFuncs window = VRLoadSecondary( "Thumbnail" ) call _InitTempDir call _InitXPDF call _INIRead call _ParseCommandLine call _GUIInit ManuallyChosen = 0 Yes = 'Yes' No = 'No' return /*:VRX Menu_Contextmenu_Erase_Click */ Menu_Contextmenu_Erase_Click: Msg.Title = 'PDFMerge' Msg.Text = 'Are you sure you want to delete this PDF file from disk?' Msg.Type = 'Q' ok = _MsgYesNo() if ok = 1 then do obj = "LB_PDFs" status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if( \status )then do return end if( selects.0 = 0 )then do return end status = VRMethod( "LB_PDFs", "GetSelectedStringList", "selectedstrings." ) do i = 1 to selects.0 ok = VRMethod( obj, "Delete", strip(selects.I,,'+') ) ok = SysFileDelete(strip(selectedstrings.I,,'+')) end end return /*:VRX Menu_Contextmenu_Info_Click */ Menu_Contextmenu_Info_Click: SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') if Sourcefile <> "" then do if translate(VRParseFilename(Sourcefile,"E")) <> "PDF" then do Msg.Title= 'Attempt to obtain PDF info failed' Msg.Type = 'E' Msg.Text = '"'Sourcefile'" does not seem to be a PDF file!?' call _Showmsg return /* Err msg here */ end ok = VRSet("Main", "Enabled", 0) PDFinfoFile = TempDir'PDFINFO.TXT' ok = SysFileDelete(PdfInfoFile) say 'PDFinfoFile = 'PDFinfoFile pdfinfoexe' "'Sourcefile'" 1>'PDFinfoFile PdfInfo.0 = 0 X = 0 do while lines(PDFINFOFile) > 0 X = X + 1 PdfInfo.X = linein(PdfInfoFile) end PDFinfo.0 = X Ok = Stream(PDFinfoFile,'c','close') ok = SysFileDelete(PdfInfoFile) PDFFontsFile = TempDir'PDFFonts.TXT' ok = SysFileDelete(PdfFontsFile) say 'PDFFontsFile = 'PDFFontsFile PDFFONTSEXE' "'Sourcefile'" 1>'PDFFontsFile PdfFonts.0 = 0 X = 0 do while lines(PDFFontsFile) > 0 X = X + 1 PdfFonts.X = linein(PdfFontsFile) end PDFFonts.0 = X Ok = Stream(PDFFontsFile,'c','close') ok = SysFileDelete(PdfFontsFile) ok = VRSet("Main", "Enabled", 1) window = VRLoadSecondary( "PDFINFO", "W" ) end return /*:VRX Menu_Contextmenu_InvertTag_Click */ Menu_Contextmenu_InvertTag_Click: ok = VRMethod( "LB_PDFs", "GetStringList", "AllPDFs." ) do I = 1 to AllPDFS.0 if left(AllpDFs.I,1) <> '+' then AllpDFs.I = '+'||AllPDFs.I else AllpDFs.I = strip(AllpDFs.I,,'+') end ok = VRMethod( "LB_PDFs", "Reset") ok = VRMethod( "LB_PDFs", "AddStringList","AllPDFs.") return /*:VRX Menu_Contextmenu_Open_Click */ Menu_Contextmenu_Open_Click: SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') if Sourcefile <> "" then ok = SysOpenObject(SourceFile,'DEFAULT','TRUE') return /*:VRX Menu_Contextmenu_Remove_Click */ Menu_Contextmenu_Remove_Click: obj = "LB_PDFs" status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if( \status )then do return end if( selects.0 = 0 )then do return end do i = 1 to selects.0 ok = VRMethod( obj, "Delete", selects.I ) end return /*:VRX Menu_Contextmenu_Split_Click */ Menu_Contextmenu_Split_Click: SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') if Sourcefile <> "" then do if translate(VRParseFilename(Sourcefile,"E")) <> "PDF" then do Msg.Title= 'Attempt to split into pages failed' Msg.Type = 'E' Msg.Text = '"'Sourcefile'" does not seem to be a PDF file!?' call _Showmsg return /* Err msg here */ end ok = VRSet("Main", "Enabled", 0) PDFinfoFile = Tempdir'PDFINFO.TXT' ok = SysFileDelete(PdfInfoFile) say 'PDFinfoFile = 'PDFinfoFile PdfinfoExe' "'Sourcefile'" 1>'PDFinfoFile PdfInfo.0 = 0 PDFPages = 0 X = 0 do while lines(PDFINFOFile) > 0 X = X + 1 PdfInfo.X = linein(PdfInfoFile) if word(PdfInfo.X,1) = 'Pages:' then PDFPages = word(PdfInfo.X,2) end PDFinfo.0 = X Ok = stream(PDFinfoFile,'c','close') if PDFPages = 0 then do Msg.text = 'Unable to determine number of pages! Check "'PdfInfoFile'"!' Msg.Type = 'E' Msg.Title= 'Attempt to split into pages failed' call _ShowMsg ok = VRSet("Main", "Enabled", 1) return end ok = SysFileDelete(PdfInfoFile) X = Garbage.0 do J = 1 to PDFPages PDFTOPSEXE' -f 'J' -l 'J' -paper match "'Sourcefile'" "'VRParseFileName(SourceFile,'DPN')'-P'right('00'||J,3)'.PS"' X = X + 1 Garbage.X = VRParseFileName(SourceFile,'DPN')'-P'right('00'||J,3)'.PS' Garbage.0 = X ok = VRMethod("LB_PDFs","AddString", VRParseFileName(SourceFile,'DPN')'-P'right('00'||J,3)'.PS',selects.1+J) end ok = VRSet("Main", "Enabled", 1) call IPB_RemovePDF_Click end return /*:VRX Menu_Contextmenu_Tag_Click */ Menu_Contextmenu_Tag_Click: status = VRMethod( "LB_PDFs", "GetSelectedList", "selects." ) if \status then return SourceFile = VRget("LB_PDFs","SelectedString") if Sourcefile <> "" then do if left(SourceFile,1) = '+' then Sourcefile = strip(Sourcefile,,'+') else Sourcefile = '+'||Sourcefile say SourceFile say Selects.1 ok = VRMethod("LB_PDFs", "AddString", Sourcefile, selects.1+1) ok = VRMethod("LB_PDFs", "Delete", selects.1 ) ok = VRMethod("LB_PDFs", "SetSelectedList", "selects." ) end return /*:VRX Menu_Contextmenu_TagAll_Click */ Menu_Contextmenu_TagAll_Click: ok = VRMethod( "LB_PDFs", "GetStringList", "AllPDFs." ) do I = 1 to AllPDFS.0 if left(AllpDFs.I,1) <> '+' then AllpDFs.I = '+'||AllPDFs.I end ok = VRMethod( "LB_PDFs", "Reset") ok = VRMethod( "LB_PDFs", "AddStringList","AllPDFs.") return /*:VRX Menu_Contextmenu_TargetNameTemplate_Click */ Menu_Contextmenu_TargetNameTemplate_Click: SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') ok = VRSet("EF_TargetName","Value",VRParseFilename(Sourcefile,"DPN")'-Merged.PDF') return /*:VRX Menu_Contextmenu_TogglePreview_Click */ Menu_Contextmenu_TogglePreview_Click: DisablePreview = \DisablePreview ok = VRSet("Menu_Contextmenu_TogglePreview","Checked", \DisablePreview) if VRGet("Thumbnail","Picturepath") <> "" then ok = VRSet("ThumbNail","Visible", \DisablePreview) else ok = VRSet("ThumbNail","Visible", 0) return /*:VRX Menu_Contextmenu_UntagAll_Click */ Menu_Contextmenu_UntagAll_Click: ok = VRMethod( "LB_PDFs", "GetStringList", "AllPDFs." ) do I = 1 to AllPDFS.0 if left(AllpDFs.I,1) = '+' then AllpDFs.I = strip(AllpDFs.I,,'+') end ok = VRMethod( "LB_PDFs", "Reset") ok = VRMethod( "LB_PDFs", "AddStringList","AllPDFs.") return /*:VRX Menu_Edit_Copy_Click */ Menu_Edit_Copy_Click: SourceFile = strip(VRget("LB_PDFs","SelectedString"),,'+') ok = VRMethod( "Application", "PutClipboard", Sourcefile ) return /*:VRX Menu_File_About_Click */ Menu_File_About_Click: Msg.Title = word(VRget("Main","Hinttext"),1) Msg.Type = "I" Msg.Text = VRget("Main","Hinttext") call _showMsg return /*:VRX Menu_File_Components_Click */ Menu_File_Components_Click: window = VRLoadSecondary( "Components", "W" ) return /*:VRX Menu_File_Debug_Click */ Menu_File_Debug_Click: if VRget("Menu_File_Debug","Checked") then do ok = VRRedirectStdIO('OFF') ok = VRSet("Menu_File_Debug","Checked", 0) end else do ok = VRRedirectStdIO('ON') ok = VRSet("Menu_File_Debug","Checked", 1) end return /*:VRX Menu_File_Exit_Click */ Menu_File_Exit_Click: call Main_Close return /*:VRX Menu_File_ExportMPF_Click */ Menu_File_ExportMPF_Click: MergeFileName = VRGet("EF_TargetName","Value") if MergeFileName = '' then do MergeFileName = VRParseFileName(PDFfiles.1,'DPN')'-Export.mpf' Buttons.1 = "OK" Buttons.0 = 1 id = VRPrompt( VRWindow(), "Please enter an appropriate name", "MergeFileName" , "MPF file name", "Buttons.", buttons.1, buttons.1 ) end MergeFileName = VRParseFileName(MergeFileName,'DPN')||'.mpf' ok = SysFileDelete(MergeFileName) ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") ok = _ExportMPF(MergeFileName) Msg.Type = 'Info' Msg.Title= "ePDFmerge" Msg.Text = MergeFileName' successfully created.' call _ShowMsg return /*:VRX Menu_File_ImportMPF_Click */ Menu_File_ImportMPF_Click: MPFFileName = VRFileDialog( VRWindow(), "Import .MPF file", "Open", "*.mpf", , , ) if MPFFilename = '' then return ok = _ImportMPF(MPFFileName) if ok then do do I = 1 to PDFFiles.0 if VRFileExists(strip(PDFFiles.I,,'+')) then do ok VRMethod("LB_PDFs","AddString",PDFFiles.I) /* call _CreateThumbNail PDFFiles.I */ end end end return /*:VRX Menu_File_Properties_Click */ Menu_File_Properties_Click: window = VRLoadSecondary( "Properties", "W" ) return /*:VRX Menu_LockMenu_LockTargetfilename_Click */ Menu_LockMenu_LockTargetfilename_Click: ManuallyChosen = 1 ok = VRset("Menu_LockMenu_LockTargetfilename","Checked",1) ok = VRset("Menu_LockMenu_UnLockTargetfilename","Checked",0) return /*:VRX Menu_LockMenu_UnLockTargetfilename_Click */ Menu_LockMenu_UnLockTargetfilename_Click: ManuallyChosen = 0 ok = VRset("Menu_LockMenu_LockTargetfilename","Checked",0) ok = VRset("Menu_LockMenu_LockTargetfilename","Checked",1) return /*:VRX PB_AbortSelection_Click */ PB_AbortSelection_Click: call PrintWizard_Close return /*:VRX PB_Back_Click */ PB_Back_Click: call GSdevice_Close ImBack = 1 return /*:VRX PB_ChooseDir_Click */ PB_ChooseDir_Click: return /*:VRX PB_Continue_Click */ PB_Continue_Click: Say 'Name 'PrtName say 'Queue 'PrtQueue say 'Driver 'PrtDriver say 'Model 'Model say 'psqueue 'psqueue HavePrinted = 0 ok = VRSet("TM_PrintWizard","Enabled", 1) window = VRLoadSecondary( "GSDevice" ,'M') return /*:VRX PB_GSDevice_OK_Click */ PB_GSDevice_OK_Click: if GSDevice = '' then return say "GSdevice "GSdevice if Prtname = '' then do Outputfile = psqueue end else do Outputfile = SysTempFileName(TempDir'epdfm???.prt') end say 'Targetfor GS= 'Outputfile /* get files to merge */ ok = VRMethod("LB_PDFs","GetStringList","PDFFiles.") /* parameterfile for GhostScript */ RspFile = 'ePDFMerge.RSP' ok = SysFileDelete(RspFile) call lineout RspFile, '-I'GSPath'\lib;'GSPath'\..\fonts;'PSFonts call lineout RspFile, '-sDEVICE='GSdevice call lineout RspFile, '-dBATCH -dNOPAUSE' call lineout RspFile, '-dRotatePages=true' call lineout RspFile, '-sOutputFile="'OutPutFile'"' do I = 1 to PDFFiles.0 if \VRGet("CB_TaggedFilesOnly","Set") then call lineout RspFile, '"'strip(PDFFiles.I,,'+')'"' else do if left(PDFFiles.I,1) = '+' then call lineout RspFile, '"'strip(PDFFiles.I,,'+')'"' end end ok = stream(RspFile,'c','close') /* Distill */ say 'Distill now!' GSPath'\bin\gsos2.exe @'RspFile say 'GhostScript RC='RC if RC = 0 then do if readybeep = 1 | readybeep = 'ERROR:' then do beep(1000,200) beep(800,200) if PrtName <> '' then do ok = VRPrintFile( PrtName, OutputFile, , 'ePDFMerge print job' ) ok = SysFileDelete(Outputfile) end end end else do Msg.Type = 'E' Msg.Text = 'GhostScript error return code: 'RC Msg.Title= 'PDFMerge' call _ShowMsg end HavePrinted = 1 call GSdevice_Close return /*:VRX PDFInfo_Close */ PDFInfo_Close: call PDFInfo_Fini return /*:VRX PDFInfo_Create */ PDFInfo_Create: call PDFInfo_Init return /*:VRX PDFInfo_Fini */ PDFInfo_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX PDFInfo_Init */ PDFInfo_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Pict_Thumbnail_Click */ Pict_Thumbnail_Click: call Menu_Contextmenu_Open_Click return /*:VRX PrintWizard_Close */ PrintWizard_Close: call PrintWizard_Fini return /*:VRX PrintWizard_Create */ PrintWizard_Create: call PrintWizard_Init PrtName = '' PrtQueue = psqueue PrtDriver = '' Model = '' ok = VRset("EF_psqueue","Value",psqueue) return /*:VRX PrintWizard_Fini */ PrintWizard_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX PrintWizard_Init */ PrintWizard_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Properties_Close */ Properties_Close: call Properties_Fini return /*:VRX Properties_Create */ Properties_Create: say "UseBuiltinDistiller="UseBuiltinDistiller call Properties_Init ok = VRseT("IPB_Save_Properties","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_Save_Properties","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRseT("IPB_Cancel_Properties","Width", VRMethod( "Screen", "PixelsToTwips", 96 )) ok = VRseT("IPB_Cancel_Properties","Height", VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRSet("RB_SimpleDistiller","Set",UseBuiltinDistiller) ok = VRset("CB_UseePDFparms","Enabled", UseBuiltinDistiller) ok = VRset("CB_UseePDFparms","Set", UseePDFparms) ok = VRSet("RB_Use_ePDF","Set",\UseBuiltinDistiller) ok = VRSet("DDCB_FileMask","Value",FileMask) ok = VRSet("SPIN_PreViewDPI","Value",ThumbDPI) ok = VRset("CB_DisablePreview","Set", DisablePreview) OldDistiller = UseBuiltinDistiller OldUseePDFparms = UseePDFparms OldThumbDPI = ThumbDPI OldFileMask = FileMask OldDisablePreview = DisablePreview return /*:VRX Properties_Fini */ Properties_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX Properties_Init */ Properties_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Quit */ Quit: window = VRWindow() call VRSet window, "Shutdown", 1 drop window return /*:VRX RB_Auto_Select_Click */ RB_Auto_Select_Click: ok = VRSet("EF_psqueue","Enabled",\VRGet("RB_Auto_Select","set")) ok = VRSet("DT_Printer","Enabled",VRGet("RB_Auto_Select","set")) Buttons.1 = 'Yes' Buttons.2 = 'No' Title ='All Printers' ChPrinter = VRMethod( "PRT_1", "PrinterDialog", title, "Buttons.") say ChPrinter ok = VRMethod( "Application", "ListPrinters", "printer." ) if ok = 1 then do do i = 1 to printer.0 if left(printer.i,length(ChPrinter))= ChPrinter then leave end end parse var printer.I PrtName ';' PrtQueue ';' PrtDriver '.'Model ok = VRSet("DT_Printer","Caption",PrtName) return /*:VRX RB_epswrite_Click */ RB_epswrite_Click: if VRGet("RB_epswrite","Set") then GSDevice = 'epswrite' return /*:VRX RB_ibmpro_Click */ RB_ibmpro_Click: if VRGet("RB_ibmpro","Set") then GSDevice = 'ibmpro' return /*:VRX RB_laserjet_Click */ RB_laserjet_Click: if VRGet("RB_laserjet","Set") then GSDevice = 'laserjet' return /*:VRX RB_Manual_selection_Click */ RB_Manual_selection_Click: ok = VRSet("EF_psqueue","Enabled",VRGet("RB_Manual_selection","set")) ok = VRSet("DT_Printer","Enabled",\VRGet("RB_Manual_selection","set")) PrtQueue = VRGet("EF_psqueue","Value") psqueue = VRGet("EF_psqueue","Value") return /*:VRX RB_ps2write_Click */ RB_ps2write_Click: if VRGet("RB_ps2write","Set") then GSDevice = 'ps2write' return /*:VRX RB_pxlcolor_Click */ RB_pxlcolor_Click: if VRGet("RB_pxlcolor","Set") then GSDevice = 'pxlcolor' return /*:VRX RB_pxlmono_Click */ RB_pxlmono_Click: if VRGet("RB_pxlmono","Set") then GSDevice = 'pxlmono' return /*:VRX RB_SimpleDistiller_Click */ RB_SimpleDistiller_Click: ok = VRset("RB_SimpleDistiller","Set", 1) ok = VRset("CB_UseePDFparms","Enabled", 1) UseBuiltinDistiller = 1 return /*:VRX RB_Use_ePDF_Click */ RB_Use_ePDF_Click: ok = VRset("RB_Use_ePDF","set", 1) ok = VRset("CB_UseePDFparms","Enabled", 0) UseBuiltinDistiller = 0 return /*:VRX SPIN_PreViewDPI_Change */ SPIN_PreViewDPI_Change: ThumbDPI = VRGet("SPIN_PreviewDPI","Value") PreviewDPIChanged = 1 return /*:VRX Thumbnail_Close */ Thumbnail_Close: ok = VRSet("Thumbnail","Visible", 0) return /*:VRX Thumbnail_Create */ Thumbnail_Create: call Thumbnail_Init return /*:VRX Thumbnail_Fini */ Thumbnail_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX Thumbnail_Init */ Thumbnail_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do /* call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" */ nop end drop window return /*:VRX TM_PrintWizard_Trigger */ TM_PrintWizard_Trigger: if HavePrinted then call PrintWizard_Close return /*:VRX Toolbar_Info_Click */ Toolbar_Info_Click: call Menu_Contextmenu_Info_Click return /*:VRX Toolbar_Open_Click */ Toolbar_Open_Click: call Menu_Contextmenu_Open_Click return /*:VRX Toolbar_PreviewToggle_Click */ Toolbar_PreviewToggle_Click: call Menu_Contextmenu_TogglePreview_Click return /*:VRX Toolbar_Split_Click */ Toolbar_Split_Click: call Menu_Contextmenu_Split_Click return /*:VRX Toolbar_Tag_Click */ Toolbar_Tag_Click: call Menu_Contextmenu_Tag_Click return /*:VRX Toolbar_TargetnameTemplate_Click */ Toolbar_TargetnameTemplate_Click: call Menu_Contextmenu_TargetNameTemplate_Click return