Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Generar archivos PDF en tus aplicaciones (https://www.clubdelphi.com/foros/showthread.php?t=80657)

dec 01-07-2006 00:08:16

Generar archivos PDF en tus aplicaciones
 
Primero que nada, tres consideraciones:

1. Tener instalado Adobe Acrobat completo (no el Adobe Acrobat Reader), esto lo he probado con Adobe Acrobat 4.0<br>
2. Haber instalado el Control ActiveX de Adobe Acrobat.<br>
2. Incluir en la clausula uses la biblioteca ComObj.<br>

Notas:

Esta funcion convierte los siguientes tipos archivos (probado con Delphi 5):

Código Delphi [-]
  Imagenes BMP (*.bmp)
  Imagenes JPG (*.jpg)
  Imagenes TIF (*.tif)
  Imagenes GIF (*.gif)

Modo de uso:

Código Delphi [-]
if not(ImgToPDF('C:\imagen.tif', 'C:\Imagen_PDF.pdf')) then
  ShowMessage('No se pudo convertir el Archivo');

function ImgToPDF(ImgArchivo, PDFArchivo: string): boolean;
var
  AcroApp : variant;
  AVDoc : variant;
  PDDoc : variant;
begin
  if not fileexists(ImgArchivo) then
    result := false
  else
  begin
    try
      AcroApp := CreateOleObject('AcroExch.App');
      AVDoc := CreateOleObject('AcroExch.AVDoc');

      AVDoc.Open(ImgArchivo, '');
      AVDoc := AcroApp.GetActiveDoc;

      if AVDoc.IsValid then
      begin
        PDDoc := AVDoc.GetPDDoc;

        PDDoc.SetInfo ('Title', '');
        PDDoc.SetInfo ('Author', '');
        PDDoc.SetInfo ('Subject', '');
        PDDoc.SetInfo ('Keywords', '');

        Result := PDDoc.Save(1 or 4 or 32, PDFArchivo);

        PDDoc.Close;
      end;

      AVDoc.Close(True);
      AcroApp.Exit;

    finally
      VarClear(PDDoc);
      VarClear(AVDoc);
      VarClear(AcroApp);
    end;
  end;
end;

aledieb 03-07-2006 22:46:33

Una alternativa economica es utilizar el PDFCreator, que básicamente es una impresora en windows.

[HTML]
http://sourceforge.net/projects/pdfcreator/
[HTML]

aledieb 03-07-2006 22:47:23

Perdon falto el Link http://sourceforge.net/projects/pdfcreator/

Chris 16-04-2007 17:55:39

Sería mejor llamar de una sola vez a la impresora (imprimir el documento).


La franja horaria es GMT +2. Ahora son las 08:00:35.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi