Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
PDFCreator
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom Wall  
View profile  
 More options May 1 2008, 8:04 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Tom Wall" <tom@{deletethis}skwirel.com>
Date: Thu, 1 May 2008 13:04:56 +0100
Local: Thurs, May 1 2008 8:04 am
Subject: PDFCreator
Hi,

Is anyone using this opensource kit?

I have been trying to implement it in Delphi5 so I automate it via its COM
interface to print doc to pdf and send the output PDF to a file and folder
of my choice. I got it working once or twice, but then I assume I changed
one of the key paramaters and whilst it was adding the printjob it was no
longer putting it in the directory I chose (not sure where it was putting
it).

Also, I have noted that the print job sits in the pending print jobs for an
age before anything happens (2 minutes or more even though quite a small
file).

Has anyone managed to get this working successfully? If so, would they be
prepared to share their code.

I am more than happy to post my code to date to see if we can get the thing
working.

Regards


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Penny  
View profile  
 More options May 1 2008, 9:51 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Jason Penny" <jasonpen...@gmail.com>
Date: Thu, 1 May 2008 09:51:36 -0400
Local: Thurs, May 1 2008 9:51 am
Subject: Re: PDFCreator
I've used Delphi2006 to output MSWord Docs to PDF using PDFCreator 0.9.5

See code below.

Also, it is sometimes helpful to start PDFCreator before attempting to
connect to the COM interfaces.
------------------------------------------------------------------------

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ActiveX, ComObj;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    PDFCreator, MSWord: OleVariant;

    optUseAutosave, optUseAutoSaveDirectory, optAutosaveFormat,
optPDFColorsColorModel: Integer;
    optAutosaveDirectory, optAutosaveFilename: String;

    // Security Options
    optPDFUseSecurity, optPDFHighEncryption, optPDFOwnerPass: Integer;
    optPDFDisallowCopy, optPDFDisallowModifyAnnotations,
optPDFDisallowModifyContents, optPDFDisallowPrinting: Integer;
    optPDFAllowAssembly, optPDFAllowDegradedPrinting, optPDFAllowFillIn,
optPDFAllowScreenReaders: Integer;
    optPDFOwnerPasswordString: String;

    procedure StorePDFOptions;
    procedure SetPDFOptions(const filename, ownerpass: String);
    procedure RestorePDFOptions;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
const
   output_filename: String = 'D:\tmp\test.pdf';
   owner_password: String = 'ownerpass';
var
   c, printJobCount: Integer;
   optPrintBackground: Boolean;
begin
   PDFCreator := CreateOLEObject('PDFCreator.clsPDFCreator');

   PDFCreator.cStart('/NoProcessingAtStartup');

   StorePDFOptions;
   SetPDFOptions(output_filename, owner_password);

   MSWord := CreateOleObject('Word.Application');
   try
      MSWord.DisplayAlerts := 0;

      MSword.Documents.Open(Edit1.Text);

      MSWord.ActiveDocument.TrackRevisions := false;
      optPrintBackground := MSWord.Options.PrintBackground;
      if not optPrintBackground then
         MSWord.Options.PrintBackground := True;
      MSWord.ActiveWindow.View.ShowRevisionsAndComments := False;
      MSWord.Options.WarnBeforeSavingPrintingSendingMarkup := false;

      printJobCount := PDFCreator.cCountOfPrintJobs;
      /// ------------------------------------------
      ///   Have PDFCreator wait for pages
      PDFCreator.cPrinterStop := true;

      MSWord.ActiveDocument.PrintoutOld;

      ///   we don't want to continue on right after telling word to print,
because it can cause problems
      while MSWord.BackgroundPrintingStatus <> 0 do
      begin
         Sleep(10);
         Application.ProcessMessages;
      end;

      /// Tell PDFCreator we're done printing pages.
      PDFCreator.cPrinterStop := false;
      /// ------------------------------------------

      ///   now wait for PDFCreator to finish
      c := PDFCreator.cCountOfPrintJobs;
      while c > printJobCount do
      begin
         Sleep(10);
         Application.ProcessMessages;
         c := PDFCreator.cCountOfPrintJobs;
      end;

      MSword.ActiveDocument.Close(SaveChanges := 0);
   finally
      VarClear(MSWord);
   end;

   RestorePDFOptions;
   VarClear(PDFCreator);
end;

procedure TForm1.StorePDFOptions;
begin
   // save the current options to put back when we're finished.
   optUseAutosave := PDFCreator.cOption['UseAutosave'];
   optUseAutosaveDirectory := PDFCreator.cOption['UseAutosaveDirectory'];
   optAutosaveDirectory := PDFCreator.cOption['AutosaveDirectory'];
   optAutosaveFilename := PDFCreator.cOption['AutosaveFilename'];
   optAutosaveFormat := PDFCreator.cOption['AutosaveFormat'];
   optPDFColorsColorModel := PDFCreator.cOption['PDFColorsColorModel'];

   // security options
   optPDFUseSecurity := PDFCreator.cOption['PDFUseSecurity'];
   optPDFHighEncryption := PDFCreator.cOption['PDFHighEncryption'];
   optPDFOwnerPass := PDFCreator.cOption['PDFOwnerPass'];
   optPDFOwnerPasswordString :=
PDFCreator.cOption['PDFOwnerPasswordString'];
   optPDFDisallowCopy := PDFCreator.cOption['PDFDisallowCopy'];
   optPDFDisallowModifyAnnotations :=
PDFCreator.cOption['PDFDisallowModifyAnnotations'];
   optPDFDisallowModifyContents :=
PDFCreator.cOption['PDFDisallowModifyContents'];
   optPDFDisallowPrinting := PDFCreator.cOption['PDFDisallowPrinting'];
   optPDFAllowAssembly := PDFCreator.cOption['PDFAllowAssembly'];
   optPDFAllowDegradedPrinting :=
PDFCreator.cOption['PDFAllowDegradedPrinting'];
   optPDFAllowFillIn := PDFCreator.cOption['PDFAllowFillIn'];
   optPDFAllowScreenReaders := PDFCreator.cOption['PDFAllowScreenReaders'];
end;

procedure TForm1.SetPDFOptions(const filename, ownerpass: String);
begin
   // set the options we want, auto-save PDF with specific filename
   PDFCreator.cOption('UseAutosave') := 1;
   PDFCreator.cOption('UseAutosaveDirectory') := 1;
   PDFCreator.cOption('AutosaveDirectory') := ExtractFilePath(filename);
   PDFCreator.cOption('AutosaveFilename') := ExtractFileName(filename);
   PDFCreator.cOption('AutosaveFormat') := 0; // PDF format
   PDFCreator.cOption('PDFColorsColorModel') := 0; // RGB format

   if Trim(ownerpass) <> '' then
   begin
      PDFCreator.cOption('PDFUseSecurity') := 1;
      PDFCreator.cOption('PDFHighEncryption') := 1;
      PDFCreator.cOption('PDFOwnerPass') := 1;
      PDFCreator.cOption('PDFOwnerPasswordString') := ownerpass;
      PDFCreator.cOption('PDFDisallowCopy') := 0;
      PDFCreator.cOption('PDFDisallowModifyAnnotations') := 1;
      PDFCreator.cOption('PDFDisallowModifyContents') := 1;
      PDFCreator.cOption('PDFDisallowPrinting') := 0;
      PDFCreator.cOption('PDFAllowAssembly') := 0;
      PDFCreator.cOption('PDFAllowDegradedPrinting') := 0;
      PDFCreator.cOption('PDFAllowFillIn') := 0;
      PDFCreator.cOption('PDFAllowScreenReaders') := 0;
   end;
   PDFCreator.cSaveOptions;
end;

procedure TForm1.RestorePDFOptions;
begin
   // reset user's options
   PDFCreator.cOption('UseAutosave') := optUseAutosave;
   PDFCreator.cOption('UseAutosaveDirectory') := optUseAutosaveDirectory;
   PDFCreator.cOption('AutosaveDirectory') := optAutosaveDirectory;
   PDFCreator.cOption('AutosaveFilename') := optAutosaveFilename;
   PDFCreator.cOption('AutosaveFormat') := optAutosaveFormat;
   PDFCreator.cOption('PDFColorsColorModel') := optPDFColorsColorModel;

   // security options
   PDFCreator.cOption('PDFUseSecurity') := optPDFUseSecurity;
   PDFCreator.cOption('PDFHighEncryption') := optPDFHighEncryption;
   PDFCreator.cOption('PDFOwnerPass') := optPDFOwnerPass;
   PDFCreator.cOption('PDFOwnerPasswordString') :=
optPDFOwnerPasswordString;
   PDFCreator.cOption('PDFDisallowCopy') := optPDFDisallowCopy;
   PDFCreator.cOption('PDFDisallowModifyAnnotations') :=
optPDFDisallowModifyAnnotations;
   PDFCreator.cOption('PDFDisallowModifyContents') :=
optPDFDisallowModifyContents;
   PDFCreator.cOption('PDFDisallowPrinting') := optPDFDisallowPrinting;
   PDFCreator.cOption('PDFAllowAssembly') := optPDFAllowAssembly;
   PDFCreator.cOption('PDFAllowDegradedPrinting') :=
optPDFAllowDegradedPrinting;
   PDFCreator.cOption('PDFAllowFillIn') := optPDFAllowFillIn;
   PDFCreator.cOption('PDFAllowScreenReaders') := optPDFAllowScreenReaders;

   PDFCreator.cSaveOptions;

   Sleep(100);
end;

end.

"Tom Wall" <tom@{deletethis}skwirel.com> wrote in message

news:4819b273$1@newsgroups.borland.com...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Wall  
View profile  
 More options May 1 2008, 12:52 pm
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Tom Wall" <tom@{deletethis}skwirel.com>
Date: Thu, 1 May 2008 17:52:55 +0100
Local: Thurs, May 1 2008 12:52 pm
Subject: Re: PDFCreator
Hi Jason,

Many thanks for the code. I will have a play around. BTW, do you notice the
delay in printing the document to pdf that I mentioned in my post?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Wall  
View profile  
 More options May 2 2008, 7:54 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Tom Wall" <tom@{deletethis}skwirel.com>
Date: Fri, 2 May 2008 12:54:30 +0100
Local: Fri, May 2 2008 7:54 am
Subject: Re: PDFCreator
Hi Jason,

Have tested your code and it certainly works. Just 2 things:

1    You need to call PDFCreator.cClose prior to clearing the PDFCreator
variant otherwise PDFCreator does not seem to close.
2     I am still having a real issue with a time delay when the print job
enters the printer queue. Seems to sit there for 30 secs or so doing
nothing. Do you experience this problem?

Finally, if and when I get this working satisfactorily re the time delay,
would you have any objections if I post the code to PDFCreator (with due
credit for your work) so they can make it available hopefully in their
samples.

Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Penny  
View profile  
 More options May 2 2008, 9:19 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Jason Penny" <jasonpen...@gmail.com>
Date: Fri, 2 May 2008 09:19:34 -0400
Local: Fri, May 2 2008 9:19 am
Subject: Re: PDFCreator
2. It takes only about 5 seconds for me, and most of that seems to be
starting MSWord, loading the file, and telling MSWord to print.  Watching
the PDFCreator window, the print job shows up and disappears almost right
away.

I don't mind you posting the code as a sample, the actual code should
restore any options changed in MSWord, though.

"Tom Wall" <tom@{deletethis}skwirel.com> wrote in message

news:481b0181$1@newsgroups.borland.com...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matthias muntwiler  
View profile  
 More options May 2 2008, 10:15 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: matthias muntwiler <muntwi...@ll.net>
Date: Fri, 02 May 2008 09:15:13 -0500
Local: Fri, May 2 2008 10:15 am
Subject: Re: PDFCreator

> 2     I am still having a real issue with a time delay when the print job
> enters the printer queue. Seems to sit there for 30 secs or so doing
> nothing. Do you experience this problem?

sounds like a network timeout. did you set up any network printer (even
if totally unrelated to the pdf jobs)?

i noticed that windows explorer completely blocks while waiting for a
network share that is not connected. could be the same for shared printers.

--matthias


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Wall  
View profile  
 More options May 2 2008, 10:50 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Tom Wall" <tom@{deletethis}skwirel.com>
Date: Fri, 2 May 2008 15:50:31 +0100
Local: Fri, May 2 2008 10:50 am
Subject: Re: PDFCreator
Hi Matthias,

That sounds interesting. I will have a look into that and see if it helps at
all.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Wall  
View profile  
 More options May 2 2008, 10:51 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Tom Wall" <tom@{deletethis}skwirel.com>
Date: Fri, 2 May 2008 15:51:37 +0100
Local: Fri, May 2 2008 10:51 am
Subject: Re: PDFCreator
Hi Jason,

I have put in code to restore word. If the PDFCreator world is interested in
the Delphi side of things I will provide them with a working project.

Regards and thanks again for your help.

Mark.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Wall  
View profile  
 More options May 2 2008, 11:40 am
Newsgroups: borland.public.delphi.thirdpartytools.general
From: "Tom Wall" <tom@{deletethis}skwirel.com>
Date: Fri, 2 May 2008 16:40:56 +0100
Local: Fri, May 2 2008 11:40 am
Subject: Re: PDFCreator
You're a genius. Now works lightning fast.

However, it's not just printers that are a problem. If there are any
disconnected network drives etc these all have to be removed. Bit of a faff,
but at least got to the bottom of it.

Many thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »