Boa noite,
Sou novo nesse forum e estou precisando de ajuda. É o seguinte...
Tenho uma pagina no apex que eu preciso imprimir em uma impressora matricial. Epson M119D (Família TM -U200). A impressora só entende comandos ESC/POS. Eu tenho um código de exemplo, mas não sei como posso fazer isso em PL/SQL. Eu estou tentando criar uma procedure que imprima o código ESC/POS em uma pagina em branco, mas não sei se isso vai dar certo. Alguém poderia me dar uma ideia de como ficaria esse codigo em PL/SQL ou teria alguma outra ideia melhor para fazer imprimir nessa impressora matricial?
O código que eu tenho de exemplo é este:
PRINT #1, CHR$(&H1B);"@"; 'Initializes the printer (ESC @)
PRINT #1, CHR$(&H1B);"a";CHR$(1);'Specifies a centered printing position (ESC a)
PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Specifies font A (ESC !)
PRINT #1, "January 14, 2002 15:00";
PRINT #1, CHR$(&H1B);"d";CHR$(3); 'Prints and 3 line feeding (ESC d)
PRINT #1, CHR$(&H1B);"a";CHR$(0); 'Selects the left print position (ESC a)
PRINT #1, CHR$(&H1B);"!";CHR$(1); 'Selects font B
PRINT #1, "TM-U210B $20.00";CHR$(&há);
PRINT #1, "TM-U210D $21.00";CHR$(&há);
PRINT #1, "PS-170 $17.00";CHR$(&há);
PRINT #1, CHR$(&há); 'Line feeding (LF)
PRINT #1, CHR$(&H1B);"!";CHR$(17); 'Selects double-height mode
PRINT #1, "TOTAL $58.00"; CHR$(&há);
PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Cancels double-height mode
PRINT #1, "------------------------------";CHR$(&há);
PRINT #1, "PAID $60.00";CHR$(&há);
PRINT #1, "CHANGE $ 2.00";CHR$(&há);
PRINT #1, CHR$(&H1D);"V";CHR$(66);CHR$(0); 'Feeds paper & cut
’Drawer Kick (ESC p)
PRINT #1, CHR$(&H1B); CHR$(&H70); CHR$(&H0); CHR$(60); CHR$(120);
Grato pela atenção.
Renan Ribeiro do Amaral
Impressora Matricial
- dr_gori
- Moderador
- Mensagens: 5026
- Registrado em: Seg, 03 Mai 2004 3:08 pm
- Localização: Portland, OR USA
- Contato:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
To tentando entender como que você vai fazer isso.
Veja: PLSQL roda dentro do servidor Oracle. Eu imagino que sua impressora está conectada localmente no seu PC :-S
O mesmo pro APEX, ele roda dentro do servidor.
Eu achei esse tópico que é +ou- a mesma dúvida.
https://forums.oracle.com/forums/thread ... dID=936321
Ali o cara criou uma solução em Apex para impressora Zebra. Talvez seja possível adaptar.
Ele criou uma pagina texto com os comandos. Ai talvez não seja possível colocar os comandos da sua dessa forma :-/
http://apex.oracle.com/pls/otn/f?p=43375:1 (LIVE DEMO)
http://apex.oracle.com/pls/otn/f?p=43375:3 (Fontes - copiados abaixo)
By Tom Fuhr, thomas.fuhr@oracle.com
Page 1
Create HTML Region (here: Zebra Printers) with the input fields
Create button "Print" (Tartget: URL , URL: javascript:print_zebra(); )
Field "HTML-Header"
Page 2
Create as empty page (I named it "Print")
(no tabs, no breadcrumb, no region required)
Create On Load - Before Header Process (I named it "Print" as well)
Shared Components
Create Application Process "set_zebra_items"
Process Point: On Demand: Run this app process when requested by a page process
Process Text:
PL/SQL Procedure
Veja: PLSQL roda dentro do servidor Oracle. Eu imagino que sua impressora está conectada localmente no seu PC :-S
O mesmo pro APEX, ele roda dentro do servidor.
Eu achei esse tópico que é +ou- a mesma dúvida.
https://forums.oracle.com/forums/thread ... dID=936321
Ali o cara criou uma solução em Apex para impressora Zebra. Talvez seja possível adaptar.
Ele criou uma pagina texto com os comandos. Ai talvez não seja possível colocar os comandos da sua dessa forma :-/
http://apex.oracle.com/pls/otn/f?p=43375:1 (LIVE DEMO)
http://apex.oracle.com/pls/otn/f?p=43375:3 (Fontes - copiados abaixo)
By Tom Fuhr, thomas.fuhr@oracle.com
Page 1
Create HTML Region (here: Zebra Printers) with the input fields
Create button "Print" (Tartget: URL , URL: javascript:print_zebra(); )
Field "HTML-Header"
<script type="text/javascript">
<!--
function callURL(url,open_in_newwindow,width,height,top,left) {
if (top == null) top = "100";
if (left == null) left = "100";
if (width == null) width = "400";
if (height == null) height = "400";
if (open_in_newwindow==1){
options ="menubar=1,scrollbars=1,resizable=1,top="+top;
options +=",left="+left+",width="+width+",height="+height;
w = open(url,"_blank",options);
w.focus();
}
else
window.location=url;
}
function print_zebra(){
//Create the AJAX call for the app process SET_ZEBRA_ITEMS
//We need to set the session state for the entered values
//before calling the print routine on page 2
ajaxRequest = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=set_zebra_items',1);
//Add the params
ajaxRequest.addParam('x01',$v('P1_ACCESSION'));
ajaxRequest.addParam('x02',$v('P1_FARMFIELD'));
ajaxRequest.addParam('x03',$v('P1_LOCLOW'));
ajaxRequest.addParam('x04',$v('P1_LOCTYPE'));
ajaxRequest.addParam('x05',$v('P1_LOC_ROWS'));
//Do the actual call and set the items on screen
//based on the JSON text returning
ajaxResponse = ajaxRequest.get();
json_SetItems(ajaxResponse);
callURL('f?p=&APP_ID.:2:&SESSION.::::',1);
}
//-->
</script>
Page 2
Create as empty page (I named it "Print")
(no tabs, no breadcrumb, no region required)
Create On Load - Before Header Process (I named it "Print" as well)
DECLARE
l_url VARCHAR2(500);
BEGIN
-- Modify accordingly:
-- http://server.com:port/pls/apex/.print_zenbra?....
l_url := 'http://apex.oracle.com/pls/otn/audi_apex.print_zebra?';
l_url := l_url || p_accession=' || :P1_ACCESSION;
l_url := l_url || '&p_farmfield=' || :P1_FARMFIELD;
l_url := l_url || '&p_loclow=' || :P1_LOCLOW;
l_url := l_url || '&p_loctype=' || :P1_LOCTYPE;
l_url := l_url || '&p_loc_rows=' || :P1_LOC_ROWS;
OWA_UTIL.REDIRECT_URL(l_url);
htmldb_application.g_unrecoverable_error := true;
END;
Shared Components
Create Application Process "set_zebra_items"
Process Point: On Demand: Run this app process when requested by a page process
Process Text:
BEGIN
apex_util.set_session_state('P1_ACCESSION',wwv_flow.g_x01);
apex_util.set_session_state('P1_FARMFIELD',wwv_flow.g_x02);
apex_util.set_session_state('P1_LOCLOW',wwv_flow.g_x03);
apex_util.set_session_state('P1_LOCTYPE',wwv_flow.g_x04);
apex_util.set_session_state('P1_LOC_ROWS',wwv_flow.g_x05);
apex_util.set_session_state('P1_TEST',wwv_flow.g_x01);
-- This is for test purpose
-- (does process work, that is does it give back something)
apex_util.json_from_items('P1_TEST');
END;
CREATE OR REPLACE PROCEDURE print_zebra (
p_accession IN VARCHAR2,
p_farmfield IN VARCHAR2,
p_loclow IN VARCHAR2,
p_loctype IN VARCHAR2,
p_loc_rows IN VARCHAR2)
IS
l_text VARCHAR2(32767);
l_clob CLOB;
l_blob BLOB;
FUNCTION "CLOB2BLOB" (
p_clob IN CLOB,
p_blob_csid IN NUMBER) RETURN BLOB
IS
l_blob BLOB;
l_src_offset NUMBER;
l_dest_offset NUMBER;
v_lang_context NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
l_warning NUMBER;
l_amount NUMBER;
BEGIN
DBMS_LOB.CREATETEMPORARY(l_blob, TRUE);
l_src_offset := 1;
l_dest_offset := 1;
l_amount := DBMS_LOB.GETLENGTH(p_clob);
DBMS_LOB.CONVERTTOBLOB(l_blob,
p_clob,
l_amount,
l_src_offset,
l_dest_offset,
p_blob_csid,
v_lang_context,
l_warning
);
RETURN l_blob;
END;
BEGIN
DBMS_LOB.CREATETEMPORARY(l_clob, TRUE, dbms_lob.call);
l_clob :=
'^xa
^ilr:val_set.grf2^fs
^fo88,132^a0,90,80^fb464,1,0,C,0^fd&' || p_accession || '^fs
^by2,3.0,32^fs
^ft64,402^BCb,32,n,n^fd' || p_farmfield ||'^fs
^ft600,402^BCb,32,n,n^sn' || p_loclow ||',1,y^fs
^fo304,232^a0r,20,20^fd' || p_loctype || '^fs
^fo334,232^a0,50,45^sn' || p_loclow ||',1,y^fs
^porque' || p_loc_rows ||'^fs
^xz';
l_blob := clob2blob(l_clob,871);
OWA_UTIL.MIME_HEADER('text/plain',FALSE);
HTP.P('Content-length: '||DBMS_LOB.GETLENGTH(l_blob));
HTP.P('Content-Disposition:inline');
OWA_UTIL.HTTP_HEADER_CLOSE;
WPG_DOCLOAD.DOWNLOAD_FILE(l_blob);
END;
GRANT EXECUTE ON "PRINT_ZEBRA" TO PUBLIC
/
Vou ver se consigo adaptar isso para a impressora que meu cliente usa.
Muito Obrigado!
Muito Obrigado!
-
- Informação
-
Quem está online
Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante