FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
FastReport - exportar PDF de cliente a Servidor
Tengo una aplicación Cliente-Servidor realizada con DataSnap, a la cual quiero agregarle la opción de que el Programa Server, el que se ejecuta remotamente, grabe un fichero PDF en el servidor remoto.
pra la producción de los reportes en el lado Cliente uso la libreria FastReport, y como ella me permite exportar un fichero PDF, haciendo las pruebas he desarrollado el siguiente código: En el Lado Cliente: Procedimiento que imprime el reporte y los envia al Servidor Código Delphi [-] procedure TfrmExpediente.btnImpClick(Sender: TObject); var Path, Doc: string; MStream : TMemoryStream; Arr: TBytes; //Array of Byte; begin Path := 'C:\Aplicaciones\Kronos\Reportes\'; with DM do begin PresentaExpedientes(edOficina.Text, edExpediente.Text); PresentaNotas(edOficina.Text, edExpediente.Text); PresentaPasajeros(edOficina.Text, edExpediente.Text); PresentaServicios(edOficina.Text, edExpediente.Text, ''); frxReport.LoadFromFile(Path + 'LstExpedientes.fr3'); frxReport.PrepareReport(); frxReport.ShowReport; // Se imprime el reporte localmente // Preparación para la exportación del reporte a PDF MStream := TMemoryStream.Create; try frxReport.SaveToStream(MStream); MStream.Position := 0; // Puesto que el Stream no es serializable lo convertimos a Array de bytes // y luego a un string para pasarlo como parámetro SetLength(Arr, MStream.Size); MStream.Read(Arr[0], MStream.Size); Doc := IdGlobal.BytesToString(Arr, nil); // Llamo a la Función del Servidor a través del DataSnap client class with TSMDataDocClient.Create(DM.SQLConnectionDOC.DBXConnection) do begin try if not GrabaDocPdf(IntToStr(DM.IDEmpresa),edOficina.Text,edExpediente.Text,1,Doc) then showmessage('No grabado PDF') else showmessage('Correcto'); finally Free; end; end; finally FreeAndNil(MStream); end; end; end; En el lado Servidor: Funcion que recibe lo enviado por el cliente y exporta el PDF Código Delphi [-] function TSMDataDoc.GrabaDocPdf(Cia, Suc, Exp: string; TipoDoc: Integer; Rpt: string): Boolean; var PathDOC, FullPath: string; frxReport: TfrxReport; frxPDFExport: TfrxPDFExport; Pdf: TMemoryStream; begin Result := False; // Se crean los componentes frx frxReport := TfrxReport.Create(Self); frxPDFExport := TfrxPDFExport.Create(Self) ; try // Convertir el string Rpt a un TMemoryStream Pdf := TMemoryStream.Create; IdGlobal.WriteStringToStream(Pdf, Rpt, -1); try Pdf.Position := 0; frxReport.LoadFromStream(Pdf); frxPDFExport.FileName:= Suc+'-'+Exp+'.pdf'; frxPDFExport.ShowDialog := False; frxPDFExport.ShowProgress := False; frxPDFExport.OpenAfterExport := False; finally Pdf.Free; end; // Se define la carpeta destino en el Servidor FullPath := 'C:\CataDoc\'+ Trim(Cia)+'\'+Trim(Suc)+'\'+ Trim(Exp)+'\'; if Copy(VerificaPath(FullPath),1,5) <> 'ERROR' then begin frxPDFExport.DefaultPath := FullPath; Result := frxReport.Export(frxPDFExport); // as frxExportPDF); end; finally frxReport.Free; frxPDFExport.Free; end; end; // Funcion que verifica si existe la carpeta destino function TSMDataDoc.VerificaPath(PathDoc: string): string; var n: integer; begin while Length(PathDoc) > 0 do begin n := Pos('\',PathDoc); if n > 0 then begin Result := Result+Copy(PathDoc,1,n); if not DirectoryExists(Result) then begin if not CreateDir(Result) then begin Result := 'ERROR '+Result; Exit; end; end; PathDoc := Copy(PathDoc,n+1,Length(PathDoc)-n); end; end; end; El problema que se me presenta es el siguiente: El Servidor recibe el String correctamente, he comprobado que el tamaño del string enviado por el cliente es el mismo que se recibe en el Servidor, sin embargo se graba el PDF vacío, sin contenido. Por favor alguien me puede indicar como debo realizar esta operación. Muchas gracias. |
#2
|
|||
|
|||
NOTA: repito el mensaje anterior porque el código delphi no se ha formateado correctamente
Tengo una aplicación Cliente-Servidor realizada con DataSnap, a la cual quiero agregarle la opción de que el Programa Server, el que se ejecuta remotamente, grabe un fichero PDF en el servidor remoto. pra la producción de los reportes en el lado Cliente uso la libreria FastReport, y como ella me permite exportar un fichero PDF, haciendo las pruebas he desarrollado el siguiente código: En el Lado Cliente: Procedimiento que imprime el reporte y los envia al Servidor
En el lado Servidor: Funcion que recibe lo enviado por el cliente y exporta el PDF
El problema que se me presenta es el siguiente: El Servidor recibe el String correctamente, he comprobado que el tamaño del string enviado por el cliente es el mismo que se recibe en el Servidor, sin embargo se graba el PDF vacío, sin contenido. Por favor alguien me puede indicar como debo realizar esta operación. Muchas gracias. |
#3
|
|||
|
|||
He encontrado la solución gracias a l soporte técnico on line de FastReport, son estupendos. Lo publico por si alguien tiene un problema similar, como siempre la solución era bastante sencilla, finalmente el código queda así:
En el lado Cliente:
En el lado Server:
Todo se reducía a usar el evento PreviewPages Un saludo |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Exportar en FastReport | bismarito | Impresión | 7 | 14-01-2015 17:15:20 |
cliente servidor | kapcomx | Conexión con bases de datos | 2 | 28-08-2007 22:48:25 |
cliente servidor | dmagui | Conexión con bases de datos | 4 | 21-10-2005 20:07:16 |
Exportar FastReport a Word | acrophet | Impresión | 1 | 19-06-2004 01:21:21 |
Cliente - Servidor | Sotrono | Internet | 5 | 16-04-2004 05:50:35 |
|