Jump to content


Photo

Error al imprimir en PDFCreator


  • Please log in to reply
6 replies to this topic

#1 cannabis

cannabis

    Advanced Member

  • Miembro Platino
  • PipPipPip
  • 257 posts
  • LocationMéxico

Posted 09 June 2016 - 09:38 AM

Hola, foronautas.
 
Estoy tratanto de imprimir directamente a PDFCreator sin intervención del usuario.

delphi
  1. var
  2.   PdfCreator: OleVariant;
  3.  
  4. begin
  5.   ...
  6.   ...
  7.  
  8.   PdfCreator := CreateOLEOBject('PDFCreator.clsPDFCreator'); //<--- Línea que provoca el error.
  9.  
  10.   ...
  11.   ...
  12. end;
  13.  

 
Mensaje de error: Project abc.exe raised exception class EOleSysError with message "Cadena clase no válida" 
 
 
Cualquier ayuda será bienvenida.
 
 
 
Hasta pronto.
  • 0

#2 giulichajari

giulichajari

    Advanced Member

  • Miembros
  • PipPipPip
  • 477 posts

Posted 09 June 2016 - 10:19 AM

has incluido la libreria comObj? en los uses?


  • 0

#3 cannabis

cannabis

    Advanced Member

  • Miembro Platino
  • PipPipPip
  • 257 posts
  • LocationMéxico

Posted 09 June 2016 - 10:44 AM

Así es, giulichajari, está incluida.


  • 0

#4 virtualmx

virtualmx

    Newbie

  • Miembro Platino
  • Pip
  • 3 posts
  • LocationMéxico

Posted 09 June 2016 - 08:56 PM

Hola colegas,
 
Yo lo he implementado con partes como las siguientes:
 


delphi
  1. uses
  2.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  3.   Dialogs, DB, Menus, StdCtrls, Buttons, ComCtrls, Grids, DBGrids,
  4.   ExtCtrls, Printers, WordXP, XPMan, OleServer, ComObj, ActiveX....
  5.   private
  6.     { Private declarations }
  7.     PDFCreator: OleVariant;
  8.   public
  9.     { Public declarations }
  10.   end;
  11.  
  12. var
  13.  
  14. procedure...
  15. begin
  16. .
  17.   CoInitialize(nil);
  18.   try
  19.     PDFCreator := CreateOLEObject('PDFCreator.clsPDFCreator');
  20.     PDFCreator.cStart('/NoProcessingAtStartup');
  21.     PDFCreator.cOption('UseAutosave') := 1;
  22.     PDFCreator.cOption('UseAutosaveDirectory') := 1;
  23.     PDFCreator.cOption('AutosaveDirectory') := ExtractFilePath(output_filename);
  24.     PDFCreator.cOption('AutosaveFilename') := ExtractFileName(output_filename);
  25.     PDFCreator.cOption('AutosaveFormat') := 0; // PDF format
  26.     PDFCreator.cOption('PDFColorsColorModel') := 0; // RGB format
  27.     if Trim(owner_password) <> '' then
  28.     begin
  29.       PDFCreator.cOption('PDFUseSecurity') := 1;
  30.       PDFCreator.cOption('PDFHighEncryption') := 1;
  31.       PDFCreator.cOption('PDFOwnerPass') := 1;
  32.       PDFCreator.cOption('PDFOwnerPasswordString') := owner_password;
  33.       PDFCreator.cOption('PDFDisallowCopy') := 1;
  34.       PDFCreator.cOption('PDFDisallowModifyAnnotations') := 1;
  35.       PDFCreator.cOption('PDFDisallowModifyContents') := 1;
  36.       PDFCreator.cOption('PDFDisallowPrinting') := 0;
  37.       PDFCreator.cOption('PDFAllowAssembly') := 0;
  38.       PDFCreator.cOption('PDFAllowDegradedPrinting') := 0;
  39.       PDFCreator.cOption('PDFAllowFillIn') := 0;
  40.       PDFCreator.cOption('PDFAllowScreenReaders') := 0;
  41.     end;
  42.     PDFCreator.cSaveOptions;
  43.     PDFCreator.cClose;
  44.     VarClear(PDFCreator);
  45.   except
  46.     PDFCreator.cClose;
  47.     VarClear(PDFCreator);
  48.   end;
  49.   CoUnInitialize;
  50. .
  51. end;

 
  Espero algo de esto pueda ayudar.
 
  Saludos.


  • 2

#5 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4107 posts
  • LocationMadrid - España

Posted 11 June 2016 - 06:19 AM

Una solución simple es cambiar la impresora por defecto, imprimir y restaurar la impresora por defecto:
 

delphi
  1. var
  2.   Default, n: integer;
  3. begin
  4.   Default:= Printer.PrinterIndex;  // guardamos la impresora por defecto.
  5.   n:= Printer.Printers.IndexOf('PDFCreator');  // buscamos PDFCreator
  6.   if n>0 then Printer.PrinterIndex:=// La asignamos como impresora por defecto
  7.   else exit; // No tenemos esa impresora instalada...
  8.   //......
  9.   // Imprimimos
  10.   //.....
  11.   // Restauramos la impresora por defecto.
  12.   Printer.PrinterIndex:= Default;
  13. end;

Saludos.
  • 1

#6 cannabis

cannabis

    Advanced Member

  • Miembro Platino
  • PipPipPip
  • 257 posts
  • LocationMéxico

Posted 13 June 2016 - 03:38 PM

Hola.

 

He resuelto el problema usando QuickReport y la exportación a PDF. Gracias por sus comentarios.

 

 

 

Hasta pronto.


  • 0

#7 ShirleyCC

ShirleyCC

    Newbie

  • Miembros
  • Pip
  • 1 posts

Posted 29 June 2016 - 04:55 AM

Hola.

 

A partir de la versión PDFCreator 1.7.3 falla la clase PDFCreator.clsPDFCreator, por ello el fallo en la línea.

 

PDFCreator := CreateOLEObject('PDFCreator.clsPDFCreator');

 

Aquí tenéis el acceso a esta versión más antigua: https://docs.google....ew?pref=2&pli=1


  • 1




IP.Board spam blocked by CleanTalk.