g-pdf-druck.w 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI ADM2
  2. &ANALYZE-RESUME
  3. &Scoped-define WINDOW-NAME CURRENT-WINDOW
  4. &Scoped-define FRAME-NAME gPDFtoPrinter
  5. {adecomm/appserv.i}
  6. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS gPDFtoPrinter
  7. /*------------------------------------------------------------------------
  8. File:
  9. Description: from cntnrdlg.w - ADM2 SmartDialog Template
  10. Input Parameters:
  11. <none>
  12. Output Parameters:
  13. <none>
  14. Author:
  15. Created:
  16. ------------------------------------------------------------------------*/
  17. /* This .W file was created with the Progress AppBuilder. */
  18. /*----------------------------------------------------------------------*/
  19. /* Create an unnamed pool to store all the widgets created
  20. by this procedure. This is a good default which assures
  21. that this procedure's triggers and internal procedures
  22. will execute in this procedure's storage, and that proper
  23. cleanup will occur on deletion of the procedure. */
  24. CREATE WIDGET-POOL.
  25. /* *************************** Definitions ************************** */
  26. /* Parameters Definitions --- */
  27. /* Local Variable Definitions --- */
  28. DEF STREAM Out_Stream.
  29. { incl/dlgdefinition.i }
  30. { src/adm2/widgetprto.i }
  31. /* _UIB-CODE-BLOCK-END */
  32. &ANALYZE-RESUME
  33. &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
  34. /* ******************** Preprocessor Definitions ******************** */
  35. &Scoped-define PROCEDURE-TYPE SmartDialog
  36. &Scoped-define DB-AWARE no
  37. &Scoped-define ADM-CONTAINER DIALOG-BOX
  38. &Scoped-define ADM-SUPPORTED-LINKS Data-Target,Data-Source,Page-Target,Update-Source,Update-Target
  39. /* Name of designated FRAME-NAME and/or first browse and/or first query */
  40. &Scoped-define FRAME-NAME gPDFtoPrinter
  41. /* Standard List Definitions */
  42. &Scoped-Define ENABLED-OBJECTS RECT-2 F_Dateiname Btn_OK Btn_Cancel
  43. &Scoped-Define DISPLAYED-OBJECTS F_Dateiname
  44. /* Custom List Definitions */
  45. /* List-1,List-2,List-3,List-4,List-5,List-6 */
  46. /* _UIB-PREPROCESSOR-BLOCK-END */
  47. &ANALYZE-RESUME
  48. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "SmartDialogCues" gPDFtoPrinter _INLINE
  49. /* Actions: adecomm/_so-cue.w ? adecomm/_so-cued.p ? adecomm/_so-cuew.p */
  50. /* SmartDialog,ab,49267
  51. Destroy on next read */
  52. /* _UIB-CODE-BLOCK-END */
  53. &ANALYZE-RESUME
  54. /* ************************ Function Prototypes ********************** */
  55. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD putPDFtoPrinter gPDFtoPrinter
  56. FUNCTION putPDFtoPrinter RETURNS INTEGER
  57. ( ipDatei AS CHAR ,
  58. ipSchrift AS RECID,
  59. ipSchacht AS INT ,
  60. ipBlockSize AS INT ,
  61. ipMapTo AS CHAR ,
  62. ipKopien AS INT ) FORWARD.
  63. /* _UIB-CODE-BLOCK-END */
  64. &ANALYZE-RESUME
  65. /* *********************** Control Definitions ********************** */
  66. /* Define a dialog box */
  67. /* Definitions of the field level widgets */
  68. DEFINE BUTTON Btn_Cancel AUTO-END-KEY
  69. LABEL "abbrechen"
  70. SIZE 15 BY 1.
  71. DEFINE BUTTON Btn_OK AUTO-GO
  72. LABEL "OK"
  73. SIZE 15 BY 1.
  74. DEFINE VARIABLE F_Dateiname AS CHARACTER FORMAT "X(256)":U
  75. LABEL "Dateiname"
  76. VIEW-AS FILL-IN
  77. SIZE 45 BY 1 NO-UNDO.
  78. DEFINE RECTANGLE RECT-2
  79. EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
  80. SIZE 60 BY 7.14.
  81. /* ************************ Frame Definitions *********************** */
  82. DEFINE FRAME gPDFtoPrinter
  83. F_Dateiname AT ROW 3.57 COL 14 COLON-ALIGNED WIDGET-ID 4
  84. Btn_OK AT ROW 10 COL 12.2
  85. Btn_Cancel AT ROW 10 COL 33.4
  86. RECT-2 AT ROW 1.48 COL 3 WIDGET-ID 2
  87. SPACE(1.99) SKIP(2.94)
  88. WITH VIEW-AS DIALOG-BOX KEEP-TAB-ORDER
  89. SIDE-LABELS NO-UNDERLINE THREE-D SCROLLABLE
  90. TITLE "Drucke PDF-Datei"
  91. CANCEL-BUTTON Btn_Cancel WIDGET-ID 100.
  92. /* *********************** Procedure Settings ************************ */
  93. &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
  94. /* Settings for THIS-PROCEDURE
  95. Type: SmartDialog
  96. Allow: Basic,Browse,DB-Fields,Query,Smart
  97. Container Links: Data-Target,Data-Source,Page-Target,Update-Source,Update-Target
  98. Design Page: 1
  99. Other Settings: COMPILE APPSERVER
  100. */
  101. &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
  102. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB gPDFtoPrinter
  103. /* ************************* Included-Libraries *********************** */
  104. {src/adm2/containr.i}
  105. /* _UIB-CODE-BLOCK-END */
  106. &ANALYZE-RESUME
  107. /* *********** Runtime Attributes and AppBuilder Settings *********** */
  108. &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
  109. /* SETTINGS FOR DIALOG-BOX gPDFtoPrinter
  110. FRAME-NAME */
  111. ASSIGN
  112. FRAME gPDFtoPrinter:SCROLLABLE = FALSE
  113. FRAME gPDFtoPrinter:HIDDEN = TRUE.
  114. /* _RUN-TIME-ATTRIBUTES-END */
  115. &ANALYZE-RESUME
  116. /* Setting information for Queries and Browse Widgets fields */
  117. &ANALYZE-SUSPEND _QUERY-BLOCK DIALOG-BOX gPDFtoPrinter
  118. /* Query rebuild information for DIALOG-BOX gPDFtoPrinter
  119. _Options = "SHARE-LOCK"
  120. _Query is NOT OPENED
  121. */ /* DIALOG-BOX gPDFtoPrinter */
  122. &ANALYZE-RESUME
  123. /* ************************ Control Triggers ************************ */
  124. &Scoped-define SELF-NAME gPDFtoPrinter
  125. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL gPDFtoPrinter gPDFtoPrinter
  126. ON END-ERROR OF FRAME gPDFtoPrinter /* Drucke PDF-Datei */
  127. DO:
  128. RUN ENDE.
  129. RETURN NO-APPLY.
  130. END.
  131. /* _UIB-CODE-BLOCK-END */
  132. &ANALYZE-RESUME
  133. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL gPDFtoPrinter gPDFtoPrinter
  134. ON WINDOW-CLOSE OF FRAME gPDFtoPrinter /* Drucke PDF-Datei */
  135. DO:
  136. RUN ENDE.
  137. RETURN NO-APPLY.
  138. END.
  139. /* _UIB-CODE-BLOCK-END */
  140. &ANALYZE-RESUME
  141. &Scoped-define SELF-NAME Btn_Cancel
  142. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn_Cancel gPDFtoPrinter
  143. ON CHOOSE OF Btn_Cancel IN FRAME gPDFtoPrinter /* abbrechen */
  144. DO:
  145. RUN ENDE.
  146. RETURN NO-APPLY.
  147. END.
  148. /* _UIB-CODE-BLOCK-END */
  149. &ANALYZE-RESUME
  150. &Scoped-define SELF-NAME Btn_OK
  151. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn_OK gPDFtoPrinter
  152. ON CHOOSE OF Btn_OK IN FRAME gPDFtoPrinter /* OK */
  153. DO:
  154. btnOK = TRUE.
  155. DEF VAR iSize AS INT NO-UNDO.
  156. iSize = DYNAMIC-FUNCTION('putPDFtoPrinter':U, F_Dateiname:SCREEN-VALUE,
  157. 1240075,
  158. 0,
  159. 240, /* Blockgrösse */
  160. '',
  161. 1). /* Anzahl Kopien */
  162. IF iSize = 0 THEN DO:
  163. MESSAGE 'Druckvorgang gescheitert !!! '
  164. VIEW-AS ALERT-BOX ERROR.
  165. END.
  166. MESSAGE 'Anzahl gedruckte Zeichen = ' iSize
  167. VIEW-AS ALERT-BOX ERROR.
  168. RUN ENDE.
  169. RETURN NO-APPLY.
  170. END.
  171. /* _UIB-CODE-BLOCK-END */
  172. &ANALYZE-RESUME
  173. &UNDEFINE SELF-NAME
  174. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK gPDFtoPrinter
  175. /* *************************** Main Block *************************** */
  176. { incl/dlgmainblock.i }
  177. {src/adm2/dialogmn.i}
  178. /* _UIB-CODE-BLOCK-END */
  179. &ANALYZE-RESUME
  180. /* ********************** Internal Procedures *********************** */
  181. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects gPDFtoPrinter _ADM-CREATE-OBJECTS
  182. PROCEDURE adm-create-objects :
  183. /*------------------------------------------------------------------------------
  184. Purpose: Create handles for all SmartObjects used in this procedure.
  185. After SmartObjects are initialized, then SmartLinks are added.
  186. Parameters: <none>
  187. ------------------------------------------------------------------------------*/
  188. END PROCEDURE.
  189. /* _UIB-CODE-BLOCK-END */
  190. &ANALYZE-RESUME
  191. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI gPDFtoPrinter _DEFAULT-DISABLE
  192. PROCEDURE disable_UI :
  193. /*------------------------------------------------------------------------------
  194. Purpose: DISABLE the User Interface
  195. Parameters: <none>
  196. Notes: Here we clean-up the user-interface by deleting
  197. dynamic widgets we have created and/or hide
  198. frames. This procedure is usually called when
  199. we are ready to "clean-up" after running.
  200. ------------------------------------------------------------------------------*/
  201. /* Hide all frames. */
  202. HIDE FRAME gPDFtoPrinter.
  203. END PROCEDURE.
  204. /* _UIB-CODE-BLOCK-END */
  205. &ANALYZE-RESUME
  206. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enableObject gPDFtoPrinter
  207. PROCEDURE enableObject :
  208. /*------------------------------------------------------------------------------
  209. Purpose: Super Override
  210. Parameters:
  211. Notes:
  212. ------------------------------------------------------------------------------*/
  213. F_Dateiname = 'D:\PDF\Allgemeine Geschäftsbedingungen - Homeservice24.pdf'.
  214. { incl/dlgenableobject.i }
  215. END PROCEDURE.
  216. /* _UIB-CODE-BLOCK-END */
  217. &ANALYZE-RESUME
  218. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI gPDFtoPrinter _DEFAULT-ENABLE
  219. PROCEDURE enable_UI :
  220. /*------------------------------------------------------------------------------
  221. Purpose: ENABLE the User Interface
  222. Parameters: <none>
  223. Notes: Here we display/view/enable the widgets in the
  224. user-interface. In addition, OPEN all queries
  225. associated with each FRAME and BROWSE.
  226. These statements here are based on the "Other
  227. Settings" section of the widget Property Sheets.
  228. ------------------------------------------------------------------------------*/
  229. DISPLAY F_Dateiname
  230. WITH FRAME gPDFtoPrinter.
  231. ENABLE RECT-2 F_Dateiname Btn_OK Btn_Cancel
  232. WITH FRAME gPDFtoPrinter.
  233. VIEW FRAME gPDFtoPrinter.
  234. {&OPEN-BROWSERS-IN-QUERY-gPDFtoPrinter}
  235. END PROCEDURE.
  236. /* _UIB-CODE-BLOCK-END */
  237. &ANALYZE-RESUME
  238. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE ENDE gPDFtoPrinter
  239. PROCEDURE ENDE :
  240. /*------------------------------------------------------------------------------
  241. Purpose:
  242. Parameters: <none>
  243. Notes:
  244. ------------------------------------------------------------------------------*/
  245. IF btnOK THEN DO:
  246. END.
  247. { incl/dlgende.i }
  248. END PROCEDURE.
  249. /* _UIB-CODE-BLOCK-END */
  250. &ANALYZE-RESUME
  251. /* ************************ Function Implementations ***************** */
  252. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION putPDFtoPrinter gPDFtoPrinter
  253. FUNCTION putPDFtoPrinter RETURNS INTEGER
  254. ( ipDatei AS CHAR ,
  255. ipSchrift AS RECID,
  256. ipSchacht AS INT ,
  257. ipBlockSize AS INT ,
  258. ipMapTo AS CHAR ,
  259. ipKopien AS INT ) :
  260. /*------------------------------------------------------------------------------
  261. Purpose:
  262. Notes:
  263. ------------------------------------------------------------------------------*/
  264. DEF VAR cAusgabe AS CHAR NO-UNDO.
  265. DEF VAR cSchrift AS CHAR NO-UNDO.
  266. DEF VAR TZeile AS MEMPTR NO-UNDO.
  267. DEF VAR QZeile AS LONGCHAR NO-UNDO.
  268. DEF VAR XZeile AS CHAR NO-UNDO.
  269. DEF VAR iSize AS INT NO-UNDO.
  270. DEF VAR iRest AS INT NO-UNDO.
  271. DEF VAR iString AS INT NO-UNDO.
  272. DEF VAR cFormat AS CHAR NO-UNDO.
  273. DEF VAR ja AS LOG NO-UNDO.
  274. DEF VAR ix AS INT NO-UNDO.
  275. DEF VAR AnzKop AS INT NO-UNDO.
  276. FIND Schrift NO-LOCK WHERE RECID(Schrift) = ipSchrift NO-ERROR.
  277. IF NOT AVAILABLE Schrift THEN RETURN 0.
  278. ASSIGN cAusgabe = Schrift.Schname
  279. cSchrift = Schrift.Schbild.
  280. FIND Drucker NO-LOCK
  281. WHERE Drucker.Drucker = Schrift.Schdru NO-ERROR.
  282. IF NOT AVAILABLE Drucker THEN RETURN 0.
  283. FILE-INFO:FILE-NAME = ipDatei NO-ERROR.
  284. IF ERROR-STATUS:ERROR THEN RETURN 0.
  285. IF FILE-INFO:FULL-PATHNAME = ? OR
  286. FILE-INFO:FULL-PATHNAME = '' THEN RETURN 0.
  287. ipDatei = FILE-INFO:FULL-PATHNAME.
  288. ASSIGN iSize = FILE-INFO:FILE-SIZE
  289. iRest = iSize MOD ipBlockSize
  290. ix = 1.
  291. message ipdatei ' mit ' isize view-as alert-box.
  292. /*
  293. SESSION:PRINTER-NAME = cAusgabe NO-ERROR.
  294. IF ERROR-STATUS:ERROR OR
  295. SESSION:PRINTER-NAME <> cAusgabe THEN DO:
  296. cAusgabe = DYNAMIC-FUNCTION('setDrucker':U, cAusgabe) NO-ERROR.
  297. IF cAusgabe = ? OR
  298. cAusgabe = '' THEN RETURN 0.
  299. ELSE cAusgabe = SESSION:PRINTER-NAME.
  300. END.
  301. */
  302. OUTPUT STREAM Out_Stream TO PRINTER BINARY NO-ECHO.
  303. SET-SIZE(TZeile) = iSize + 1.
  304. COPY-LOB FILE ipDatei FOR iSize TO TZeile NO-CONVERT NO-ERROR.
  305. message 'eingelesen' view-as alert-box.
  306. DO WHILE ix <= iSize:
  307. IF (ix + ipBlockSize - 1) > iSize THEN iString = iRest.
  308. ELSE iString = ipBlockSize.
  309. COPY-LOB FROM TZeile STARTING AT ix FOR iString TO QZeile NO-CONVERT NO-ERROR.
  310. ASSIGN XZeile = ''
  311. XZeile = QZeile
  312. cFormat = SUBSTITUTE('x(&1)', iString).
  313. PUT STREAM Out_Stream CONTROL XZeile.
  314. ix = ix + ipBlockSize.
  315. END.
  316. iString = LENGTH(xZeile).
  317. PUT STREAM Out_Stream CONTROL CHR(12).
  318. SET-SIZE(TZeile) = 0.
  319. OUTPUT STREAM Out_Stream CLOSE.
  320. RETURN iSize.
  321. END FUNCTION.
  322. /* _UIB-CODE-BLOCK-END */
  323. &ANALYZE-RESUME