You are not logged in.
Pages: 1
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
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
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
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
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
What I doing wrong?
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
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
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.
Now it works beautifully.
Offline
Pages: 1