&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI ADM2 &ANALYZE-RESUME &Scoped-define WINDOW-NAME CURRENT-WINDOW &Scoped-define FRAME-NAME gPDFtoPrinter {adecomm/appserv.i} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS gPDFtoPrinter /*------------------------------------------------------------------------ File: Description: from cntnrdlg.w - ADM2 SmartDialog Template Input Parameters: Output Parameters: Author: Created: ------------------------------------------------------------------------*/ /* This .W file was created with the Progress AppBuilder. */ /*----------------------------------------------------------------------*/ /* Create an unnamed pool to store all the widgets created by this procedure. This is a good default which assures that this procedure's triggers and internal procedures will execute in this procedure's storage, and that proper cleanup will occur on deletion of the procedure. */ CREATE WIDGET-POOL. /* *************************** Definitions ************************** */ /* Parameters Definitions --- */ /* Local Variable Definitions --- */ DEF STREAM Out_Stream. { incl/dlgdefinition.i } { src/adm2/widgetprto.i } /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK /* ******************** Preprocessor Definitions ******************** */ &Scoped-define PROCEDURE-TYPE SmartDialog &Scoped-define DB-AWARE no &Scoped-define ADM-CONTAINER DIALOG-BOX &Scoped-define ADM-SUPPORTED-LINKS Data-Target,Data-Source,Page-Target,Update-Source,Update-Target /* Name of designated FRAME-NAME and/or first browse and/or first query */ &Scoped-define FRAME-NAME gPDFtoPrinter /* Standard List Definitions */ &Scoped-Define ENABLED-OBJECTS RECT-2 F_Dateiname Btn_OK Btn_Cancel &Scoped-Define DISPLAYED-OBJECTS F_Dateiname /* Custom List Definitions */ /* List-1,List-2,List-3,List-4,List-5,List-6 */ /* _UIB-PREPROCESSOR-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "SmartDialogCues" gPDFtoPrinter _INLINE /* Actions: adecomm/_so-cue.w ? adecomm/_so-cued.p ? adecomm/_so-cuew.p */ /* SmartDialog,ab,49267 Destroy on next read */ /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ************************ Function Prototypes ********************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD putPDFtoPrinter gPDFtoPrinter FUNCTION putPDFtoPrinter RETURNS INTEGER ( ipDatei AS CHAR , ipSchrift AS RECID, ipSchacht AS INT , ipBlockSize AS INT , ipMapTo AS CHAR , ipKopien AS INT ) FORWARD. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* *********************** Control Definitions ********************** */ /* Define a dialog box */ /* Definitions of the field level widgets */ DEFINE BUTTON Btn_Cancel AUTO-END-KEY LABEL "abbrechen" SIZE 15 BY 1. DEFINE BUTTON Btn_OK AUTO-GO LABEL "OK" SIZE 15 BY 1. DEFINE VARIABLE F_Dateiname AS CHARACTER FORMAT "X(256)":U LABEL "Dateiname" VIEW-AS FILL-IN SIZE 45 BY 1 NO-UNDO. DEFINE RECTANGLE RECT-2 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL SIZE 60 BY 7.14. /* ************************ Frame Definitions *********************** */ DEFINE FRAME gPDFtoPrinter F_Dateiname AT ROW 3.57 COL 14 COLON-ALIGNED WIDGET-ID 4 Btn_OK AT ROW 10 COL 12.2 Btn_Cancel AT ROW 10 COL 33.4 RECT-2 AT ROW 1.48 COL 3 WIDGET-ID 2 SPACE(1.99) SKIP(2.94) WITH VIEW-AS DIALOG-BOX KEEP-TAB-ORDER SIDE-LABELS NO-UNDERLINE THREE-D SCROLLABLE TITLE "Drucke PDF-Datei" CANCEL-BUTTON Btn_Cancel WIDGET-ID 100. /* *********************** Procedure Settings ************************ */ &ANALYZE-SUSPEND _PROCEDURE-SETTINGS /* Settings for THIS-PROCEDURE Type: SmartDialog Allow: Basic,Browse,DB-Fields,Query,Smart Container Links: Data-Target,Data-Source,Page-Target,Update-Source,Update-Target Design Page: 1 Other Settings: COMPILE APPSERVER */ &ANALYZE-RESUME _END-PROCEDURE-SETTINGS &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB gPDFtoPrinter /* ************************* Included-Libraries *********************** */ {src/adm2/containr.i} /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* *********** Runtime Attributes and AppBuilder Settings *********** */ &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES /* SETTINGS FOR DIALOG-BOX gPDFtoPrinter FRAME-NAME */ ASSIGN FRAME gPDFtoPrinter:SCROLLABLE = FALSE FRAME gPDFtoPrinter:HIDDEN = TRUE. /* _RUN-TIME-ATTRIBUTES-END */ &ANALYZE-RESUME /* Setting information for Queries and Browse Widgets fields */ &ANALYZE-SUSPEND _QUERY-BLOCK DIALOG-BOX gPDFtoPrinter /* Query rebuild information for DIALOG-BOX gPDFtoPrinter _Options = "SHARE-LOCK" _Query is NOT OPENED */ /* DIALOG-BOX gPDFtoPrinter */ &ANALYZE-RESUME /* ************************ Control Triggers ************************ */ &Scoped-define SELF-NAME gPDFtoPrinter &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL gPDFtoPrinter gPDFtoPrinter ON END-ERROR OF FRAME gPDFtoPrinter /* Drucke PDF-Datei */ DO: RUN ENDE. RETURN NO-APPLY. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL gPDFtoPrinter gPDFtoPrinter ON WINDOW-CLOSE OF FRAME gPDFtoPrinter /* Drucke PDF-Datei */ DO: RUN ENDE. RETURN NO-APPLY. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME Btn_Cancel &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn_Cancel gPDFtoPrinter ON CHOOSE OF Btn_Cancel IN FRAME gPDFtoPrinter /* abbrechen */ DO: RUN ENDE. RETURN NO-APPLY. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME Btn_OK &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn_OK gPDFtoPrinter ON CHOOSE OF Btn_OK IN FRAME gPDFtoPrinter /* OK */ DO: btnOK = TRUE. DEF VAR iSize AS INT NO-UNDO. iSize = DYNAMIC-FUNCTION('putPDFtoPrinter':U, F_Dateiname:SCREEN-VALUE, 1240075, 0, 240, /* Blockgrösse */ '', 1). /* Anzahl Kopien */ IF iSize = 0 THEN DO: MESSAGE 'Druckvorgang gescheitert !!! ' VIEW-AS ALERT-BOX ERROR. END. MESSAGE 'Anzahl gedruckte Zeichen = ' iSize VIEW-AS ALERT-BOX ERROR. RUN ENDE. RETURN NO-APPLY. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &UNDEFINE SELF-NAME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK gPDFtoPrinter /* *************************** Main Block *************************** */ { incl/dlgmainblock.i } {src/adm2/dialogmn.i} /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ********************** Internal Procedures *********************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects gPDFtoPrinter _ADM-CREATE-OBJECTS PROCEDURE adm-create-objects : /*------------------------------------------------------------------------------ Purpose: Create handles for all SmartObjects used in this procedure. After SmartObjects are initialized, then SmartLinks are added. Parameters: ------------------------------------------------------------------------------*/ END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI gPDFtoPrinter _DEFAULT-DISABLE PROCEDURE disable_UI : /*------------------------------------------------------------------------------ Purpose: DISABLE the User Interface Parameters: Notes: Here we clean-up the user-interface by deleting dynamic widgets we have created and/or hide frames. This procedure is usually called when we are ready to "clean-up" after running. ------------------------------------------------------------------------------*/ /* Hide all frames. */ HIDE FRAME gPDFtoPrinter. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enableObject gPDFtoPrinter PROCEDURE enableObject : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ F_Dateiname = 'D:\PDF\Allgemeine Geschäftsbedingungen - Homeservice24.pdf'. { incl/dlgenableobject.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI gPDFtoPrinter _DEFAULT-ENABLE PROCEDURE enable_UI : /*------------------------------------------------------------------------------ Purpose: ENABLE the User Interface Parameters: Notes: Here we display/view/enable the widgets in the user-interface. In addition, OPEN all queries associated with each FRAME and BROWSE. These statements here are based on the "Other Settings" section of the widget Property Sheets. ------------------------------------------------------------------------------*/ DISPLAY F_Dateiname WITH FRAME gPDFtoPrinter. ENABLE RECT-2 F_Dateiname Btn_OK Btn_Cancel WITH FRAME gPDFtoPrinter. VIEW FRAME gPDFtoPrinter. {&OPEN-BROWSERS-IN-QUERY-gPDFtoPrinter} END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE ENDE gPDFtoPrinter PROCEDURE ENDE : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ IF btnOK THEN DO: END. { incl/dlgende.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ************************ Function Implementations ***************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION putPDFtoPrinter gPDFtoPrinter FUNCTION putPDFtoPrinter RETURNS INTEGER ( ipDatei AS CHAR , ipSchrift AS RECID, ipSchacht AS INT , ipBlockSize AS INT , ipMapTo AS CHAR , ipKopien AS INT ) : /*------------------------------------------------------------------------------ Purpose: Notes: ------------------------------------------------------------------------------*/ DEF VAR cAusgabe AS CHAR NO-UNDO. DEF VAR cSchrift AS CHAR NO-UNDO. DEF VAR TZeile AS MEMPTR NO-UNDO. DEF VAR QZeile AS LONGCHAR NO-UNDO. DEF VAR XZeile AS CHAR NO-UNDO. DEF VAR iSize AS INT NO-UNDO. DEF VAR iRest AS INT NO-UNDO. DEF VAR iString AS INT NO-UNDO. DEF VAR cFormat AS CHAR NO-UNDO. DEF VAR ja AS LOG NO-UNDO. DEF VAR ix AS INT NO-UNDO. DEF VAR AnzKop AS INT NO-UNDO. FIND Schrift NO-LOCK WHERE RECID(Schrift) = ipSchrift NO-ERROR. IF NOT AVAILABLE Schrift THEN RETURN 0. ASSIGN cAusgabe = Schrift.Schname cSchrift = Schrift.Schbild. FIND Drucker NO-LOCK WHERE Drucker.Drucker = Schrift.Schdru NO-ERROR. IF NOT AVAILABLE Drucker THEN RETURN 0. FILE-INFO:FILE-NAME = ipDatei NO-ERROR. IF ERROR-STATUS:ERROR THEN RETURN 0. IF FILE-INFO:FULL-PATHNAME = ? OR FILE-INFO:FULL-PATHNAME = '' THEN RETURN 0. ipDatei = FILE-INFO:FULL-PATHNAME. ASSIGN iSize = FILE-INFO:FILE-SIZE iRest = iSize MOD ipBlockSize ix = 1. message ipdatei ' mit ' isize view-as alert-box. /* SESSION:PRINTER-NAME = cAusgabe NO-ERROR. IF ERROR-STATUS:ERROR OR SESSION:PRINTER-NAME <> cAusgabe THEN DO: cAusgabe = DYNAMIC-FUNCTION('setDrucker':U, cAusgabe) NO-ERROR. IF cAusgabe = ? OR cAusgabe = '' THEN RETURN 0. ELSE cAusgabe = SESSION:PRINTER-NAME. END. */ OUTPUT STREAM Out_Stream TO PRINTER BINARY NO-ECHO. SET-SIZE(TZeile) = iSize + 1. COPY-LOB FILE ipDatei FOR iSize TO TZeile NO-CONVERT NO-ERROR. message 'eingelesen' view-as alert-box. DO WHILE ix <= iSize: IF (ix + ipBlockSize - 1) > iSize THEN iString = iRest. ELSE iString = ipBlockSize. COPY-LOB FROM TZeile STARTING AT ix FOR iString TO QZeile NO-CONVERT NO-ERROR. ASSIGN XZeile = '' XZeile = QZeile cFormat = SUBSTITUTE('x(&1)', iString). PUT STREAM Out_Stream CONTROL XZeile. ix = ix + ipBlockSize. END. iString = LENGTH(xZeile). PUT STREAM Out_Stream CONTROL CHR(12). SET-SIZE(TZeile) = 0. OUTPUT STREAM Out_Stream CLOSE. RETURN iSize. END FUNCTION. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME