Export to PDF with password (fastreport & vb6)

edited 6:17PM in FastReport 4.0
I use vb6 and fastreport 4.0.1..
My application need to export fastreport to pdf file.
I have no problem to export the fastreport to pdf.
But i don't know how to set password for exported pdf.

My export source code :

Dim WithEvents frx As FastReport.TfrxReport
Dim frxExport As IfrxBuiltinExports

Set frx = CreateObject("FastReport.TfrxReport")
Set frxExport = frx

frx.PrepareReport (True)
frxExport.ExportToPDF ("\test.pdf", True, True, True)

Anyone have idea?

Comments

  • keturpatelketurpatel India
    edited 6:17PM
    No need to declare frxExport. You can directly write -
    Dim WithEvents frx As FastReport.TfrxReport
    Set frx = CreateObject("FastReport.TfrxReport")
    
    ....
    ....
    ....
    
    frx.PrepareReport (True)
    
    Call frx.Exports.ExportToPDF("\test.pdf", True, True, True, False, "UserPass", "Ownerpass")
    
    Set frx = Nothing
    

    If you want to declare frxExport, declare it as
    dim frxExport as TfrxDispatchableExports
  • edited 6:17PM
    Thanks for your reply.

    I try your code, but i got this error.. "Object doesn't support this property or method"

    My TfrxReport, doesn't have the ".Exports" only have this member "ExportReport"

    Sorry, i'm not really understand using vb with fastreport.
  • keturpatelketurpatel India
    edited 6:17PM
    Only reason for not finding property in report object is because your version of fast-report don't have it.
    All you can do is replace it with latest version of fast-report.

    Or check if you can find TfrxDispatchableExports object and use second solution i have provided in last post.

Leave a Comment