#1 2011-01-21 11:34:54

dmartib
Member
Registered: 2011-01-21
Posts: 2

Document info is not saved

Hi,

I'm using your component with preview component from Delphi Area. It's fantastic, a very good job! but I have a problem: document info (Author, Title ...) is not saved to the PDF file.

I've downloaded the last version (1.12) from your repository, without success.

Thanks in advance for your help.

Offline

#2 2011-01-21 11:43:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Document info is not saved

How do you set document info?

Here is a typical use (extracted from the source code repository of SQLite3Pages unit):

  PDF := TPDFDocument.Create(UseOutlines);
  try
    try
      with PDF.Info do begin
        Title := SysUtils.Trim(Caption);
        if ExportPDFApplication='' then
          Name := Application.Title else
          Name := ExportPDFApplication;
        Creator := Name;
        Author := ExportPDFAuthor;
        Subject := ExportPDFSubject;
        Keywords := ExportPDFKeywords;
      end;
      PDF.EmbeddedTTF := ExportPDFEmbeddedTTF;
      {$ifndef NO_USE_UNISCRIBE}
      PDF.UseUniscribe := ExportPDFUseUniscribe;
      {$endif}
      if PDF.DefaultPaperSize<>PaperSize then  // same page size
        PDF.DefaultPaperSize := PaperSize;
      if Orientation=poLandscape then begin // same orientation
        i := PDF.DefaultPageWidth;
        PDF.DefaultPageWidth :=  PDF.DefaultPageHeight;
        PDF.DefaultPageHeight := i;
      end;
      PDF.ForceJPEGCompression := ExportPDFForceJPEGCompression;
      for i := 0 to PageCount-1 do begin
        // this loop will do all the magic :)
        PDF.AddPage;
        PDF.Canvas.RenderMetaFile(TMetaFile(fPages.Objects[i]),Scale);
      end;
      PDF.SaveToFile(PDFFileName);
    finally
      PDF.Free;
    end;

And this is working as expected...

So I guess there is something wrong with your code.
If you are using TGDIPages as preview component, you must set the ExportPDFAuthor/ExportPDFKeywords and such properties, then use either the right click menu "PDF Export", either a call to the TGDIPages.ExportPDF method from a custom button on your preview UI.

Offline

#3 2011-01-21 12:03:59

dmartib
Member
Registered: 2011-01-21
Posts: 2

Re: Document info is not saved

Thanks for your reply and thanks for this sample code, it helped a lot to identify the problem on preview.pas. They was calling PDF.Newdoc before rendering the pages.

Now all document information is saved correctly.

Thanks again!

Offline

#4 2011-01-21 12:39:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Document info is not saved

You're welcome!

Thanks for your interest!

smile

Offline

#5 2011-01-21 18:56:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Document info is not saved

Perhaps it could be worth giving some feedback to the Delphi Area, so that they could fix their source?

Could you do that?

Offline

#6 2011-10-18 07:46:14

Crowbar
Member
From: Germany
Registered: 2011-10-18
Posts: 3

Re: Document info is not saved

Hi,

i've downloaded the last version (1.15).

When I add the option PdfDocument.PDFA1:=true (or false!) then the document info (Author, Title, Creator...) not saved to the PDF file.

...
PdfDocument:=TPdfDocument.Create;
PdfDocument.Info.Author :='Author';
PdfDocument.Info.Creator:='Creator';
PdfDocument.Info.Subject:='Subject';
PdfDocument.Info.Title  :='Title';
PdfDocument.PDFA1:=true; // or :=false
PdfDocument.AddPage;
...

But when I not add this option then the document info saved to the PDF file.

Thanks in advance for your help.

Offline

#7 2011-10-18 09:04:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Document info is not saved

I was not able to reproduce the issue.

With the current version, it works as expected, with both PDF/A mode enabled or disabled.
Document / Properties displays the corresponding document info in Acrobat Reader.

Offline

#8 2011-10-18 10:05:01

Crowbar
Member
From: Germany
Registered: 2011-10-18
Posts: 3

Re: Document info is not saved

What I doing wrong? sad

I create a PDF file with "PdfDocument.Canvas.RenderMetaFile (Metafile)".
This works wonderfully!
Only, it is not saved the document info to the PDF file (when "PdfDocument.PDFA1" is set).

Last edited by Crowbar (2011-10-18 10:05:24)

Offline

#9 2011-10-18 11:31:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Document info is not saved

You set PDFA1 to TRUE AFTER the info fields.
So your document information is reset.

Setting the PDFA1 property will flush the current document.
It is even preferred to specify it at the constructor level.

Code it as such:

PdfDocument:=TPdfDocument.Create;
PdfDocument.PDFA1:=true; // or :=false SHOULD BE FIRST
PdfDocument.Info.Author :='Author';
PdfDocument.Info.Creator:='Creator';
PdfDocument.Info.Subject:='Subject';
PdfDocument.Info.Title  :='Title';
PdfDocument.AddPage;

or

PdfDocument:=TPdfDocument.Create(false,0,true);  // APDFA1=true here
PdfDocument.Info.Author :='Author';
PdfDocument.Info.Creator:='Creator';
PdfDocument.Info.Subject:='Subject';
PdfDocument.Info.Title  :='Title';
PdfDocument.AddPage;

Offline

#10 2011-10-18 11:46:21

Crowbar
Member
From: Germany
Registered: 2011-10-18
Posts: 3

Re: Document info is not saved

ab wrote:

You set PDFA1 to TRUE AFTER the info fields.
So your document information is reset.

Setting the PDFA1 property will flush the current document.
It is even preferred to specify it at the constructor level.
...

Many thanks, this was (my) error. roll
Now it works beautifully. smile

Offline

Board footer

Powered by FluxBB