/* * Concordance Programming Language * Utility to print PDF files via DDE communication with Acrobat. * Copyright (C) 2000, 2001 Dataflight Software, Inc. ALL RIGHTS RESERVED. * Dataflight Software and Concordance are registered trademarks of Dataflight Software, Inc. * * Dataflight Software, Inc. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * * * */ main() { int i, f, db, length; char string[256]; if (f = isfield(db, "PDFFILE")) { switch(messageBox("Print every PDF file in this query?", "Concordance PDF Printing", MB_ICONQUESTION | MB_YESNOCANCEL)) { case IDCANCEL: break; case IDNO: printPDF(db,f); break; case IDYES: cycle(db) { Message("Record "+str(docno(db))+" of "+str(count(db)), FALSE); /* Get the file's size. */ length = 0; string = trim(db->f); if ((i = open(string, "r")) <> EOF) { length = lseek(i, 0, 'E'); close(i); } /* Print the PDF file. */ printPDF(db,f); /* Pause one second for each megabyte in the PDF for Acrobat to finish printing. */ /* Allow a minimum of .5 seconds. The sleep command parameter is in milliseconds. */ sleep(500 + ((length / 1000000) * 2000)); } break; } } user("Windows", "Browse"); return 0; } /* main() */ printPDF(int db, f) { char szDosFile[256]; char szCommand[256]; int hConv; szDosFile = trim(db->f); if ((hConv = ddeConnect("acroview", "control")) == 0) { shellExecute("open", szDosFile, "", "", SW_SHOWNORMAL); /* Allow the program to initialize for one second before proceeding. */ sleep(1000); hConv = ddeConnect("acroview", "control"); } if (hConv) { szCommand = '[CloseAllDocs()]'; ddeExec(hConv, szCommand); szCommand = '[FilePrintSilentEx("'+szDosFile+'")]'; ddeExec(hConv, szCommand); ddeDisconnect(hConv); } else messageBox("Couldn't connect to Acrobat DDE server.", program(), MB_OK); } RGB(char red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait) { text screen; int key, rc; int fg, bk, tr, tc; tr = 8; tc = 13; fg = RGB(0,0,0); cursoroff(); box(tr , tc , tr + 2, tc + 54,"3D", RGB(160,160,160), bk = RGB(200,200,200)); puts(tr + 1,tc + 1,pad(message,'C',53), fg, bk); return(asc(upper(chr(key)))); } /* Message() */ /**************************************************************** * Name: Path * * Synopsis: Returns the path up to the last \ and without * * the file's name. * ****************************************************************/ Path(text dosPath) { int i, j; if ((i = match(dosPath,":",1)) == 0) i = match(dosPath,"\",1); while(j = match(dosPath,"\",i+1)) i = j; return(substr(dosPath,1,i)); } /* Path() */ /**************************************************************** * Name: FileName * * Synopsis: Trims the path from the file name. * ****************************************************************/ FileName(text name) { int i; while(i = match(name,"\",1)) name = substr(name,i+1); return(name); } /* FileName() */ /**************************************************************** * Global Variable Declarations and Initialization * ****************************************************************/ /* findfirst() file attributes. */ int A_NORMAL = 00; /* Normal file - No read/write restrictions */ int A_RDONLY = 01; /* Read only file */ int A_HIDDEN = 02; /* Hidden file */ int A_SYSTEM = 04; /* System file */ int A_VOLID = 08; /* Volume ID file */ int A_SUBDIR = 16; /* Subdirectory */ int A_ARCH = 32; /* Archive file */ /* edit() mode attributes. A // Alpha only mode. U // Upper case conversion. N // Numeric only mode. Y // Y mode for dates. M // M mode for dates. D // D mode for dates. C // Cut and paste mode. S // Scroll field left and right, no wordwrapping. E // Return on [Enter], no CR in data. T // Always edit from the top. B // Always edit from the bottom. @ // Display only this field. ! // Return when this field is entered, don't edit. N:99.99 */ int CTRLPGUP = 33792, F11 = 34048, F12 = 34304, EOF = -1; short LEFT = 19200, RIGHT = 19712, UP = 18432, DOWN = 20480, HOME = 18176, END = 20224, PGUP = 18688, PGDN = 20736, CTRLPGDN = 30208, F1 = 15104, F2 = 15360, F3 = 15616, F4 = 15872, F5 = 16128, F6 = 16384, F7 = 16640, F8 = 16896, F9 = 17152, F10 = 17408; char ESC = 27, CTRLP = 16, FALSE = 0, TRUE = 1, TAB = 9, CR = 13, LF = 10, FF = 12; /* Standard dialog button return values. */ int IDOK = 1; int IDCANCEL = 2; int IDABORT = 3; int IDRETRY = 4; int IDIGNORE = 5; int IDYES = 6; int IDNO = 7; /* MessageBox() display options. */ int MB_OK = 0; int MB_OKCANCEL = 1; int MB_ABORTRETRYIGNORE = 2; int MB_YESNOCANCEL = 3; int MB_YESNO = 4; int MB_RETRYCANCEL = 5; int MB_ICONHAND = 16; int MB_ICONQUESTION = 32; int MB_ICONEXCLAMATION = 48; int MB_ICONASTERISK = 64; int MB_ICONINFORMATION = MB_ICONASTERISK; int MB_ICONSTOP = MB_ICONHAND; int MB_DEFBUTTON1 = 0; int MB_DEFBUTTON2 = 256; int MB_DEFBUTTON3 = 512; int MB_APPLMODAL = 0; int MB_SYSTEMMODAL = 4096; int MB_TASKMODAL = 8192; int MB_NOFOCUS = 32768; /**********************************************************/ /* The first byte of every entry in the database.TRK file */ /* indicates the type of log entry and the type of event. */ /**********************************************************/ int LOGDELETION = 'D'; int LOGDELETION_OLD = 1 ; int LOGFIELDEDITED = 2 ; int LOGTAGADDED = 4 ; int LOGTAGDELETED = 8 ; int LOGEVENTSDELETED = 'P'; int LOGREINDEX = 'R'; int LOGSECURITYDELETION = 'S'; /********************************************************/ /* Definitions for the shellExecute() command. */ /********************************************************/ int SW_HIDE = 0; int SW_MINIMIZE = 6; int SW_RESTORE = 9; int SW_SHOW = 5; int SW_SHOWMAXIMIZED = 3; int SW_SHOWMINIMIZED = 2; int SW_SHOWMINNOACTIVE = 7; int SW_SHOWNA = 8; int SW_SHOWNOACTIVATE = 4; int SW_SHOWNORMAL = 1; /********************************************************/ /* Definitions for the search() command's flag param V7.*/ /********************************************************/ int SEARCHDATABASE = 4; int SEARCHNOTES = 8; int SEARCHALL = (4|8);