PDA

Ver la Versión Completa : ¿como Generar pdf en delphi 2010 sin componentes de Terceros?


JXJ
09-09-2010, 17:08:08
esta es mi duda.

estoy con delphi 2010 y quiero generar un archio pdf
con informacion que saco de una bse de datos.
¿como puedo Generar un pdf en delphi 2010 sin componentes de Terceros?

me falto decir que el archivo pdf sera un reporte.
y aparte de los datos obtenido de la base de datos, le voy a poner otros datos a mano.
com quien dice usar una plantilla con datos variables a rellenar y
poder usar imagenes..

FGarcia
09-09-2010, 17:32:29
Indiscutiblemente debera ser con componentes de terceros, Delphi cuenta con Rave Reports que te permite exportar a diversos formatos entre ellos pdf.

Se que se puede hacer por codigo desde delphi pero no tengo a la mano el documento donde lo explica.

Te recomiendo una lectura a Delphi 2006 de Ivan Hladni (Anaya)

Neftali [Germán.Estévez]
09-09-2010, 18:50:42
Otra opción, sin componentes de terceros, sería utilizar una impresora virtual. No se si has contemplado esa opción y si te sería posible.

JXJ
09-09-2010, 21:01:12
yo he estado pensando en usar un archivo HTML.
que sera mi plantilla. ahi acomodar los graficos las descripcion y marcadores
de la informacion que se jala desde la base de datos.
una ve creado el html. procesarlo y que se convierta en un archivo pdf.

con impresoras virtuales es necesario instalarlas.
he visto software de pago. nada freeware o opensource.
no lo veo como opcion.

FGarcia
09-09-2010, 22:51:18
Ah Caray!

PDFCreator (http://sourceforge.net/projects/pdfcreator/) es una impresora virtual y es gratis (Free) e instalarla es de risa.

No entiendo cual es la dificultad.

Neftali [Germán.Estévez]
09-09-2010, 23:57:31
con impresoras virtuales es necesario instalarlas.
he visto software de pago. nada freeware o opensource.
no lo veo como opcion.

Sí es cierto que hay que instalarlas; En cuando a que son de pago, me suena haber leído sobre más de una Free; FGarcía comenta una, pero hay algunas más; doPDF (http://www.dopdf.com/es/), BullZIP (http://www.bullzip.com/products/pdf/info.php), CutePDF (http://www.acrosoftware.com/), PrimoPDF (http://www.primopdf.com/),...

Casimiro Notevi
10-09-2010, 00:26:58
Yo llevo años usando pdfcreator en los windows de los clientes y va perfecta.

JXJ
10-09-2010, 01:54:51
que bien.. yo busque y todas eran de pago..

que raro. ?:S

ecfisa
10-09-2010, 02:01:10
Hola JXJ.

Hay una que nombró Neftali que yo uso: doPDF.

No sé si es la mejor, pero dado el uso que le doy , digamos que me queda grande... :)

La podés descargar gratis de ACA (http://www.dopdf.com/).


Saludos.

Casimiro Notevi
10-09-2010, 02:12:43
pdfCreator (http://sourceforge.net/projects/pdfcreator/), libre, gratis y funciona de maravilla :)

Neftali [Germán.Estévez]
10-09-2010, 10:08:57
Una pregunta; En el trabajo usan FinePrinter+pdfFactory que son de pago; Son muy asequible y funcionan muy bien.

Tiene características para poder utilizarla y generar los ficheros de forma transparente al usuario; Es decir, que desde programa puedes generar un PDF sin que el usuario intervenga, pero el sistema que posee no es muy ágil, pues funciona a través del registro de Windows.

Hace tiempo miré si las que había gratuitas (que por aquella época eran pocas -1 o 2-) poseían esta característica, pero ninguna la tenía.
Ahora hay bastantes más opciones, como se ha visto en este hilo.

¿Alguna de las que utilizáis posee esta caractrística y que sea fácil de utilizar?
¿Que se pueda generar el PDF y abrirlo desde Delphi sin tener que pedirle al usuario el nombre del fichero (por ejemplo)?

Casimiro Notevi
10-09-2010, 10:39:57
El pdfcreator puede ser usado por línea de comandos con parámetros, creo que se puede hacer lo que comentas, aquí van:


Setup Command Line Parameters



Edito: me equivoqué en el copia->pega, el bueno es el del post de abajo. Disculpas.

Neftali [Germán.Estévez]
10-09-2010, 11:37:20
El pdfcreator puede ser usado por línea de comandos con parámetros, creo que se puede hacer lo que comentas, aquí van:

Estos son parámetros parece de Instalación. Yo me refiero a parametrizar la impresión desde programa. Cuando desde un programa mandas imprimir.

Imagina que el usuario le da a un botón para <Generar PDF>, eso provoca que en tu programa Delphi lances la impresión a la impresora PDF (que puede ser la que hay por defecto o no), para que se genere.

En ese momento lo normal es que al usuario le aparezca un ventana solicitándole el "Nombre del fichero" (y otras opciones); Eso es lo que me gustaría poder parametrizar de forma sencilla (y que no apareciera).
En el caso de pdfFactory, puedes (antes de lanzar la impresión) generar unos valores en el registro de Windows, y si la impresora al generar la impresión detecta que están (y si son correctos) los coge y no le pregunta al usuario.
de esta forma has generado un fichero PDF sin intervención del usuario utilizando la impresora virtual.

Casimiro Notevi
10-09-2010, 11:46:11
Me equivoqué de fichero al hacer el copia->pega, perdón, el que quería poner es este:


Command Line Parameters
PDFCreator enables you to create documents via the command line interface. Here are the different commands that PDFCreator supports:
/AddWindowsExplorerIntegration
Whith this switch PDFCreator integrates itself with the Windows shell. When you right-click on selected documents in Windows Explorer a new menu item will appear called "Create PDF with PDFCreator". This enables the user to quickly convert documents to PDF without having to open the document. Note that this functionality requires PDFCreator to be temporarily assigned the default printer status.
Example: PDFCreator.exe /AddWindowsExplorerIntegration
/CheckInstance
If you use this switch PDFCreaor shows a message box with the information about running instances of PDFCreator, PDFSpooler and Transtool. You can combine this parameter with the switch /NoStart. If you see the property "Local" there exists a local instance. Please check the desktop, Systray or the Task Manager to find the local instance. If you see only the property "Global" than there exists at least one instance in one of your terminal server sessions. This switch is usefull for debugging and for administrators to check if there is a running instance of PDFCreator on a terminal server.
Example: PDFCreator.exe /CheckInstance
/ClearCache
Clears all PDFCreator temporary files. This is useful if PDFCreator will not start because of a corrupt temp file.
Example: pdfcreator.exe /ClearCache
/DeleteIF
Delete the input file after converting. This parameter can only be used in conjunction with the /IF parameter.
Example: pdfcreator.exe /IF"C:\description.ps" /OF"C:\description.pdf" /DeleteIF
/IF<input-filename> /OF<output-filename>
Convert a postscript file or a bitmap file (JPEG, BM) to a PDF or bitmap. The /OF parameter must be used in conjunction with the /IF parameter. To set the output file format, include the file extension in the output file name. There is NO space between the parameters and the file names. The parameter /OutputSubFormat defines the subformat. Currently "PDF/A-1b" and ""PDF/X" can be used for the PDF format.
Examples:
pdfcreator.exe /IF"C:\description.ps" /OF"C:\description.pdf" /OutputSubFormat"PDF/A-1b"
pdfcreator.exe /IF"C:\description.ps" /OF"C:\description.tif"
pdfcreator.exe /IF"C:\image1.jpg" /OF"C:\image1.pdf"
pdfcreator.exe /IF"C:\image1.bmp" /OF"C:\image1.png"
/NoAbortIfRunning
Opens a new instance of PDFCreator without checking if the program is already running. It is useful to combine this parameter with the /NoProcessing parameter.
Example: pdfcreator.exe /NoAbortIfRunning
/NoProcessing
When PDFCreator is opened with the /NoProcessing option, all documents that are sent to PDFCreator are not processed immediately. They are stored in the print queue until PDFCreator is opened without the /NoProcessing option.
Example: pdfcreator.exe /NoProcessing
/NoProcessingAtStartup: When you use this parameter, PDFCreator will start without processing any documents. You can manually start processing by going to the Document menu and selecting Print or by unchecking the Printer Stop option in the Printer menu. The setting is useful if you want collect some files first, then combine the files into one and create a pdf.
Properties:
0 - Off (Default)
1 - On
/NoStart
When you use the /PF parameter, PDFCreator stays open after it's done its task. The /NoStart parameter automatically closes PDFCreator after it is done.
Example: pdfcreator.exe /NOSTART /PF"C:\help.doc"
/OpenOF
Open the output file after converting. This parameter can only be used in conjunction with the /IF and the /OF parameter.
Example: pdfcreator.exe /IF"C:\description.ps" /OF"C:\description.pdf" /OpenOF
/OptionsFile<option-filename>
Specifies the particular options file PDFCreator should use.
Examples: pdfcreator.exe /OptionsFile"C:\MyPDFCreator.ini"
(Hint: With this parameter (and a work around) you can use more than one printer on a machine.)
/PF<filename>
Print a file with the standard program linking with the extension of the file. In general, this option is useful in connection with Auto-Save mode. It is not possible to use this parameter in conjunction with the /OF parameter. There is NO space between the parameter and the file name.
Example: pdfcreator.exe /PF"C:\help.doc"
You can also use wildcards to create PDF's of all documents in a specified folder.
Example: pdfcreator.exe /PF"C:\*.doc"
/RemoveWindowsExplorerIntegration
Whith this switch you remove the PDFCreator Windows shell integration.
Example: PDFCreator.exe /RemoveWindowsExplorerIntegration
/ShowOnlyLogfile
Opens PDFCreator in the log file. No other windows are opened.
Example: pdfcreator.exe /ShowOnlyLogfile
/ShowOnlyOptions
Opens PDFCreator in the Options Panel. No other windows are opened.
Example: pdfcreator.exe /ShowOnlyOptions



Además:


Features

* Create PDF's from just about any program that prints using Windows printers.
* Create documents in the following formats: Portable Document Format (PDF, PDF/A, PDF/X), PNG, JPEG, BMP, PCX, TIFF, Postscript (PS), Encapsulated Postscript (EPS), Text, Adobe Photoshop (PSD), PCL, RAW and SVG (experimental).
* Combine multiple documents into one PDF.
* Password protect and apply up to 128 bit encryption to your PDF documents.
* Automatically save PDF documents with current settings without being prompted for information
* And much more!

Neftali [Germán.Estévez]
10-09-2010, 12:12:45
El que quería poner es este:


Este sí. ;)

Gracias Casimiro.

yapt
10-09-2010, 17:24:17
PDFCreator usa GhostScript para generar el .ps que luego genera el .pdf.

Puedes usar GhostScript (es una DLL) para conseguir esto. Que conste que yo no lo he hecho nunca así que solo es una idea. Una busqueda en San Google por: delphi GhostScript te dará unos cuantos resultados.

Y si consigues hacerlo funcionar, estaría bien poner aquí un ejemplo para el futuro. :D

Salu2.

Neftali [Germán.Estévez]
10-09-2010, 17:57:10
Bueno, aquí hay un ejemplo en Delphi (http://pages.cs.wisc.edu/%7Eghost/doc/gsapi.htm) (mirrors) con la susodicha DLL; El problema es que yo no poseo la versión correcta para probarlo.

Waldo
31-01-2013, 02:42:06
Me equivoqué de fichero al hacer el copia->pega, perdón, el que quería poner es este:



Además:

como ejecuto esos comandos, =) en delphi.