#1 2020-04-30 12:14:24

fs999
Member
Registered: 2014-06-25
Posts: 7

Stack overflow with encrypted pdfs

I have a stack overflow error when saving when I try to encrypt a pdf.
The error appears in TPdfRawText.InternalWriteTo

Here is my code :

        p := TMemoryStream.Create;
        Pdf := TPdfDocumentGDI.Create(false, 0, false, TPdfEncryption.New(elRC4_40, '1234', '1234',  [epPrinting]));
        Pdf.GeneratePDF15File := True;
        Pdf.PDFA1 := False;
        Pdf.Info.Title := 'Title';
        Pdf.Info.Author := 'Author';
        Pdf.Info.Creator := 'Creator';
        try
          for i := 1 to QuickReport.QRPrinter.PageCount do
          begin
            aMeta := QuickReport.QRPrinter.GetPage(i);
            try
              Pdf.DefaultPageWidth := MulDiv(aMeta.Width,72,Pdf.ScreenLogPixels);
              Pdf.DefaultPageHeight := MulDiv(aMeta.Height,72,Pdf.ScreenLogPixels);
              Pdf.AddPage;
              Pdf.Canvas.RenderMetaFile(aMeta,1,0,0,0, tpSetTextJustification,99,101,tcNeverClip);
            finally
              aMeta.Free;
            end;
          end;
          Pdf.SaveToStream(p);     <<--- Error appears here
        finally
          FreeAndNil(Pdf);
          FreeAndNil(p);
        end;

Offline

Board footer

Powered by FluxBB