#1 2014-08-08 17:06:52

stefanti
Member
Registered: 2014-08-08
Posts: 7

How to export from QuickReport in a pdf file encrypted?

I need to export to a pdf encrypted by QuickReport: I can create the pdf file is not encrypted using ExportToFilter but do not know how to export it directly encrypted.
How to ?
Thanks,
Tiziano

Offline

#2 2014-08-08 17:38:02

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

Re: How to export from QuickReport in a pdf file encrypted?

This QuickReport filter is not part of our library, nor supported by us.

But SynPDF by itself (in its latest revision) is able to encrypt the generated pdf file.
See http://blog.synopse.info/post/2013/06/1 … t-security

So you will have to update the QR filter to add the encryption settings at TPdfDocument creation:

NewPdfDoc := TPdfDocument.Create(false,0,false,
   TPdfEncryption.New(elRC4_128,'','toto',PDF_PERMISSION_NOCOPYNORPRINT));

Offline

#3 2014-08-09 08:12:46

stefanti
Member
Registered: 2014-08-08
Posts: 7

Re: How to export from QuickReport in a pdf file encrypted?

procedure TForm1.test;
var
   spdf : TQRSynPDFDocumentFilter;
   doc: TPDFDocument;

begin
// 1) This creates a empty pdf file encrypted

Doc := TPdfDocument.Create(false,0,false,TPdfEncryption.New(elRC4_128,'','toto',PDF_PERMISSION_ALL));

// 2) This creates and saves a pdf file is not encrypted by QuicReport

spdf := TQRSynPDFDocumentFilter.Create('C:\test.pdf');
spdf.HideMenubar := true;
spdf.CompressionOn := true;
spdf.HideToolbar := true;
spdf.FontHandling := AutoEmbed;
form1.QuickRep1.ExportToFilter(spdf);
spdf.Free;
.....
?????
.....
end;

How do I connect the 1) with 2) in order to create and save a pdf file from QuickReport encrypted?

Thanks
Tiziano

Offline

#4 2014-08-09 10:09:58

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

Re: How to export from QuickReport in a pdf file encrypted?

I do not know.
We do not support TQRSynPDFDocumentFilter.
You should ask in the QuickReport forums instead.

Offline

#5 2014-08-09 10:16:10

stefanti
Member
Registered: 2014-08-08
Posts: 7

Re: How to export from QuickReport in a pdf file encrypted?

The solution you have provided to me in reading this:
http://synopse.info/forum/viewtopic.php?id=138

......

try
  Doc := TPdfDocument.Create(false,0,false,TPdfEncryption.New(elRC4_128,'','toto',PDF_PERMISSION_NOCOPYNORPRINT));

  Doc.DefaultPaperSize := psA4;
  form2.QuickRep1.prepare;
    for p := 1 to form2.QuickRep1.QRPrinter.PageCount do
    begin
      Doc.AddPage;
      pagemeta := form2.QuickRep1.QRPrinter.PageList.GetPage(p);
        try
        Doc.Canvas.RenderMetaFile(pagemeta,1,0,0);
        finally
        pagemeta.free;
        end;
    end;
   //This saves a pdf file encrypted by QuicReport
    doc.SaveToFile('prova.pdf');

  finally
  doc.Free;
  end;

Thanks !!!
Tiziano

Last edited by stefanti (2014-08-09 10:19:43)

Offline

#6 2014-08-09 10:22:25

stefanti
Member
Registered: 2014-08-08
Posts: 7

Re: How to export from QuickReport in a pdf file encrypted?

Last question: how do you put password permission to the opening of the pdf?
Tiz.

Offline

#7 2014-08-09 11:10:39

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

Re: How to export from QuickReport in a pdf file encrypted?

See the TPdfEncryption.New() doc:

    // - aUserPassword will be asked at file opening: to be set to '' for not
    // blocking display, but optional permission

Offline

#8 2014-08-11 08:17:28

stefanti
Member
Registered: 2014-08-08
Posts: 7

Re: How to export from QuickReport in a pdf file encrypted?

Doc := TPdfDocument.Create(false,0,false,TPdfEncryption.New(elRC4_128,'password.open','password.protection',PDF_PERMISSION_NOCOPYNORPRINT));

Very well!
Thanks,
Tiziano

Offline

Board footer

Powered by FluxBB