× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Arco - MUCH appreciated

Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill

-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Arco Simonse
Sent: Friday, February 17, 2017 10:17 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: Storing images on, and printing same images from the AS/400

Hi Alan,

Please find code below for pdf printing from ifs.
To use this code you need Scott Klement's UNIXCMD and PRTSTMFR programs, and IFSIO prototypes which you can find on his website.

We have the pdf on the ifs. Ghostscript uses so called devices to transform the pdf to a specific format.
Device 'pxlcolor' for example will create a pcl color stream. Mediaposition is trayselection, heavily dependent of your target printer, and needs to be digged out of the printer documentation (sometimes a real pain).
For our printers we keep a table with "human tray" to mediaposition mappings.
Mediaposition 1 will choose the default tray on most (if not all) printers.

Once the pcl (or other format) is generated in the temp folder, it is sent to the printer as *USERASCII stream by the PRTSTMFR program.
We modified the PRSTMFR program a bit to allow for longer filename parameters.
After it has sent, we clean up by removing the temporary pcl.

The nice thing of using that wonderful UNIXCMDOA is that you can retrieve the output of what happens when the ghostscript is invoked.
As you can see we use a dataarea to turn logging on or off.

Hope this helps.

Regards,
-Arco

Snippet of calling program :

d/include yourlib/incsrc,ifsio_h

// Prototypes
d CVTPDFSTMR PR extpgm('CVTPDFSTMR')
d peFileIn 1024A const
d peFileOut 1024A const
d pePaperSize 10A const
d peMediaPosition 10I 0 const
d peDevice 10A const
d peAutoRotate 10A const

d PRTSTMFR PR extpgm('PRTSTMFR')
d peStream 1024A varying const
d peOutq 10A const
d peSpoolName 10A const

// Variables
d wwFileIn S 1024A
d wwFileOut S 1024A
d wwPaperSize S 10A
d wwMediaPosition S 10I 0
d wwDevice S 10A
d wwAutoRotate S 10A
d wwOutq S 10A
d wwSpoolName S 10A

/free
*inlr = *on ;

wwFileIn = '/temp/yourinput.pdf' ;
wwFileOut = '/temp/youroutput'
+ '-' + %char( %timestamp() ) ;
wwPaperSize = '*A4' ;
wwMediaPosition = 1 ;
wwAutoRotate = '*YES' ;
wwDevice = 'pxlcolor' ;
wwOutq = 'PRTXYX' ;
wwSpoolName = 'YOURSPLNAM' ;

// convert input doc to printerstream
CVTPDFSTMR( wwFileIn
: wwFileOut
: wwPaperSize
: wwMediaPosition
: wwDevice
: wwAutoRotate
) ;

// send stream to printer outq
prtstmfr( %trim( wwFileOut) : wwOutq : wwSpoolName ) ;

// remove temporary pcl file
unlink( %trim( wwFileOut ) + X'00' ) ;

return ;

/end-free


Below is the RPG wrapper around the Ghostscript conversion call.

**FREE
//------------------------------------------------------------------//
//
// Program : CVTPDFSTMR
// Description : Ifs to print stream conversion via ghostscript.
// The command output is retrieved by the use of
// the UNIXCMD tool (thanks to Scott Klement)
// which allows us to retrieve response
// data via rpg special file pipe and eventually
// save that to an logging spoolfile.
//
//------------------------------------------------------------------//

ctl-opt dftactgrp(*no)
option(*nodebugio:*srcstmt) ;

dcl-f UNIX disk(1000) handler('UNIXCMDOA': cmd) usropn ; dcl-f QSYSPRT printer(198) usage(*output) usropn ;


// main program *entry
dcl-pi CVTPDFSTMR ;
peFileIn char(1024) ;
peFileOut char(1024) ;
pePaperSize char(10) ;
peMediaPosition int(10) ;
peDevice char(10) ;
peAutoRotate char(10) ;
end-pi;

dcl-c GS_PROGRAM '/usr/bin/gs' ;
dcl-s parm1 varchar(30) ;
dcl-s parm2 varchar(30) ;
dcl-s parm3 varchar(30) ;
dcl-s parm4 varchar(30) ;
dcl-s parm5 varchar(30) ;
dcl-s parm6 varchar(30) ;
dcl-s parm7 varchar(30) ;
dcl-s parm8 varchar(1024) ;
dcl-s parm9 varchar(1024) ;

dcl-s cmd char(5000);
dcl-ds record len(1000) end-ds;
dcl-s Command varchar(100);
dcl-ds outrec len(198) end-ds ;
dcl-s LogCPdfStm char(1) dtaara ;

dcl-pr QCMDEXC extpgm('QCMDEXC');
*n char(32767) options(*varsize) const; *n packed(15: 5) const; end-pr;

*inlr = *on ;

in LogCPdfStm ;

if LogCPdfStm = 'Y' ;
if not %open(qsysprt) ;
// - ovrprtf
Command = 'OVRPRTF FILE(QSYSPRT) SCHEDULE(*IMMED)'
+ ' OVRSCOPE(*JOB) PAGESIZE(66 198) CPI(15)'
+ ' DFRWRT(*NO)' ;
// execute override
QCMDEXC( Command : %len(Command)) ;
open qsysprt ;
PrintLine(*ALL'-') ;
PrintLine('Start report for: ' + %trim(peFileIn)) ;
PrintLine('File out : ' + %trim(peFileOut)) ;
PrintLine('Device : ' + %trim(peDevice)) ;
PrintLine('MediaPosition : ' + %char(peMediaPosition)) ;
endif ;
endif ;

//parm1 = ' -dBATCH' ;
parm1 = '' ;
parm2 = ' -dNOPAUSE' ;
parm3 = ' -dSAFER' ;
parm4 = ' -sDEVICE=' + %trim(peDevice) ;
parm5 = ' -sPaperSize='
+ %trim( %subst( pePaperSize : 2 ) ) ; if peAutoRotate = '*YES' ;
parm6 = ' -dAutoRotatePages=/All' ;
else ;
parm6 = ' -dAutoRotatePages=/None' ;
endif;
parm7 = ' -dMediaPosition=' + %trim(%char(peMediaPosition)) ;
parm8 = ' -sOutputFile=' + %trim(peFileOut) ;
parm9 = ' ' + %trim( peFileIn ) ;

cmd = GS_PROGRAM
+ parm1 + parm2 + parm3 + parm4 + parm5
+ parm6 + parm7 + parm8 + parm9
;
if LogCPdfStm = 'Y' ;
PrintLine('Called program : ' + %trim(GS_PROGRAM )) ;
PrintLine(' parm 1 : ' + %trim(parm1)) ;
PrintLine(' parm 2 : ' + %trim(parm2)) ;
PrintLine(' parm 3 : ' + %trim(parm3)) ;
PrintLine(' parm 4 : ' + %trim(parm4)) ;
PrintLine(' parm 5 : ' + %trim(parm5)) ;
PrintLine(' parm 6 : ' + %trim(parm6)) ;
PrintLine(' parm 7 : ' + %trim(parm7)) ;
PrintLine(' parm 8 : ' + %trim(parm8)) ;
PrintLine(' parm 9 : ' + %trim(parm9)) ;
endif ;

open UNIX;

dow '1' ;
read UNIX record ;
if %eof(UNIX) ;
leave ;
endif ;
if LogCPdfStm = 'Y' ;
PrintLine(%subst(record:1:198)) ;
endif ;
enddo ;


if %open(qsysprt) ;
close qsysprt ;
endif ;
return ;

dcl-proc PrintLine;
dcl-pi *n ;
peLine char(198) const ;
end-pi ;

outrec = peLine ;
write QSYSPRT outrec ;
return ;

end-proc ;

2017-02-16 20:58 GMT+01:00 Alan Shore <ashore@xxxxxxxx>:

Thanks for your reply Arco
Do you have a web site that explains your process - or some type of
documentation?
Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill


-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
Arco Simonse
Sent: Thursday, February 16, 2017 2:55 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: Storing images on, and printing same images from the
AS/400

We created RPG wrappers around Ghostscript and do a pdf to pcl
conversion there. Then send the pcl directly to the printer as
*USERASCII stream. No need for a "pdf ready" printer.

Regards,
-Arco

2017-02-16 19:51 GMT+01:00 Bradley Stone <bvstone@xxxxxxxxx>:

We have software that will let you add images to an existing PDF
file, but the only problem there is you still run into the issue of
printing from the IFS (if that is what the OP was asking.. printing
images from
the IFS).

There are solutions, but I haven't seen one that works for all printers.
Most have to be "PDF ready" if I recall properly


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.