Export to PDF with password (fastreport & vb6)

edited 1:40AM 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 1:40AM
    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 1:40AM
    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 1:40AM
    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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.