trueSoft escribió:
trueSoft escribió:
Hola a todos.
Hace un tiempo dejé por estos foros la consulta de como generar PDF's desde C3. Bueno ya está solucionado.
Si alguien tiene interes que siga el hilo y pregunte.
Hola de nuevo a todos.
A ver si esta semana os pongo un ejemplo con codigo.
Os adelanto que estoy imprimiendo desde TPrinter a PDF por medio de CreatePDF. Funciona muy bien, tambien se puede hacer desde Word (2003 que es el que utilizo, ya que 2007 lo trae de fabrica).
Hola, de nuevo a los lectores.
Po's ya estoy aqui para contaros como he logrado generar PDF's desde C3.
Necesitamos:
* La aplicación (gratuita) PDFCreator.
* ...y C3 (por supuesto).
Po's con estos dos 'elementos' y las siguientes funciones, el tinglao funciona
* ------------
FUNCTION CreateOLEObject(cProgID) AS Object
LOCAL oServer AS Object
oServer := TOLEContainer():Create(cProgID)
IF oServer[1] = 0
oServer:Destroy()
return NIL
endif
return oServer
* ------------
FUNCTION IsPDFCreatorInstalled() AS Boolean
LOCAL lResult AS Boolean
with CreateObject( "MSScriptControl.ScriptControl" )
:Language := "VBScript"
:Reset()
:AddCode( 'Function Installed()' + CRLF +;
' Dim PDFCreator' + CRLF +;
' On Error Resume Next' + CRLF +;
' Set PDFCreator = CreateObject("PDFCreator.clsPDFCreator")' + CRLF +;
' If Err.Number <> 0 Then' + CRLF +;
' Installed = false' + CRLF +;
' Exit Function' + CRLF +;
' End If' + CRLF +;
' PDFCreator.cStart "/NoProcessingAtStartup"' + CRLF +;
' PDFCreator.cClose' + CRLF +;
' Installed = true' + CRLF +;
'End Function' )
lResult := :Eval("Installed")
![Very Happy :D](./images/smilies/icon_biggrin.gif)
estroy()
endwith
return lResult
* ------------
FUNCTION Printer2PDF( lShow, cDirectory, cFileName, cPDFPrinter ) AS Logical
LOCAL oDlg AS Object
LOCAL cDefaultPrinter AS Character
LOCAL lResult AS Logical
DEFAULT lShow TO False, cPDFPrinter TO "PDFCreator"
oDlg := MessageDlg( "Generando documento PDF. Espere, por favor.", mtCustom )
WITH CreateObject( "MSScriptControl.ScriptControl" )
:Language := "VBScript"
:Reset()
:AddCode( 'Function StorePDFOptions()' + CRLF +;
' Dim PDFCreator' + CRLF +;
' Set PDFCreator = CreateObject("PDFCreator.clsPDFCreator")' + CRLF +;
' PDFCreator.cStart "/NoProcessingAtStartup"' + CRLF +;
' WITH PDFCreator' + CRLF +;
' .cOption("UseAutosave") = 1' + CRLF +;
' .cOption("UseAutosaveDirectory") = 1' + CRLF +;
' .cOption("AutosaveFormat") = 0' + CRLF +;
' .cClearcache' + CRLF +;
' .cPrinterStop = false' + CRLF +;
' .cOption("AutosaveDirectory")="' + cDirectory + '"' + CRLF +;
' .cOption("AutosaveFilename")="'+ cFileName + '"' + CRLF +;
' .cSaveOptions' + CRLF +;
' .cClose' + CRLF +;
' End With' + CRLF +;
'End Function' )
:ExecuteStatement("StorePDFOptions")
![Very Happy :D](./images/smilies/icon_biggrin.gif)
estroy()
ENDWITH
WITH Printer
cDefaultPrinter :=
![Very Happy :D](./images/smilies/icon_biggrin.gif)
efault
:Active := cPDFPrinter
:ShowDialog := False
![Razz :P](./images/smilies/icon_razz.gif)
rint()
:Active := cDefaultPrinter
ENDWITH
Sleep( 4000 )
DO EVENTS
lResult := File( cDirectory + cFileName )
IF lResult THEN ShellExecute( 0, "open", cDirectory + cFileName,,, SW_SHOWMAXIMIZED )
oDlg:Destroy()
RETURN lResult
Saludos a todos (las dudas trataré de resolverlas)