PDFLocker | Password Protected PDF | Encrypt PDF Files

Discussion in 'Free Source Codes' started by teja varma, May 2, 2020.

    
  1. teja varma

    teja varma Active Member


    **Highlights**

    1)Exports Ledger Statements and Sales Invoices to PDF with Password Protected

    2)There are two Kinds of Password - User password and Owner Password

    3)With user password, they can view the pdf but cannot alter

    4)Screen readers are allowed to read the content

    **Requirements**

    1)PdfLocker.dll - for password protection

    2)PdfLocker.txt(TDL) - for handling export and Invoking dll from tally

    3).Net Framework v4 or higher

    You can download from here: https://dotnet.microsoft.com/download/dotnet-framework/net40

    **Get Started**

    1)Download all the files (PdfLocker.dll,PdfLocker.txt,itextsharp.dll) from the below Link

    2)Register the dll - PdfLocker.dll (with below steps)

    3)Load the TCP in tally - PdfLocker.txt

    4)Export Ledger Statement or Sales Invoices by clicking on Encrypt PDF Button (Right Side)

    5)It will ask for user password and owner password

    6)After that Report will be exported and Encrypted with given passwords

    7)PDF's will be Stored in Encrypted PDF's folder in Tally working directory(Tally Folder)


    **Registering the DLL**

    1) Open CMD in administrator Mode (Elevated mode)

    For 64 Bit
    2) Type cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319 ;; change directory

    For 32 Bit
    3) Type cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 ;; change directory


    4) Type regasm PdfLocker.dll /codebase ;;Give Full path of the PdfLocker.dll file

    5) you will get a success message after it registered



    **You can extend the tdl as per your requirements**


    Link to Download Files - Project Repo :
    https://github.com/tejavarma-aln/Password-Protected-PDF-TDL

    Watch this video to get started

    Cheers,
    Varma.
     
    balajimg, Rohit Khedar, panam and 2 others like this.


  2. haejosh

    haejosh New Member


    Excellent Works ....:cool:
    with video tutorial.
    Keep it up.
     


  3. Rohit Khedar

    Rohit Khedar Member


    Sir Very Nice if Posible so add in this Watermark Type Option
     


  4. Vaidehi Joshi

    Vaidehi Joshi New Member


    I have written this tdl to call a dll mehod from .net,But it is giving error"Failed to find class COM INTERFACE"Please check if the COM SERVER IS REGISTERED OR NOT


    [COM Interface:ppushdata]

    Project:pprojectName.DAL
    Class:AdapterClass
    Interface:TDLCollection
    Parameters: p1 : Number : In
    Return:Number

    [#Form:Voucher]

    On:Form Accept:Yes:Call:ppushdata

    [Function:ppushdata]

    Variable : p1 : Number : 2

    01:Exec COM Interface :ppushdata:##p1
    02:Log:$$LastResult
     
    Last edited: Mar 20, 2021


  5. teja varma

    teja varma Active Member


    1)You have to register the DLL before calling it from tally(TDL)
    https://www.geeksengine.com/article/register-dll.html

    2)Make sure it is COM VISIBLE in assembly information under project properties, so it will expose the assembly information to other processes who want to use this DLL.
     


  6. Vaidehi Joshi

    Vaidehi Joshi New Member


    Thanks for the suggestion, I didn't follow the second point previously now I go through the second point. and then build the project added the dll file on specific path.
    Then registered a dll one more time. But Still the issue is there.Can you please help me to find out the what goes wrong?
    This is a method from .net
    public int TDLCollection(int CusMID)
    {

    return 10;
    }
     

    Attached Files:



  7. teja varma

    teja varma Active Member


    Check wether DLL is registered :
    goto->powershell->paste the following command and press enter
    Code:
    Get-ChildItem HKLM:\Software\Classes -ErrorAction SilentlyContinue | Where-Object {
    $_.PSChildName -match '^\w+\.\w+$' -and (Test-Path -Path "$($_.PSPath)\CLSID")
    } | Select-Object -ExpandProperty PSChildName
    
    It will list all the registered Com interfaces(DLL's)
    In that list search whether your DLL is listed.
    the name will be like this - 'ProjectName.ClassName'

    One more thing is:
    32bit applications cannot use 64bit DLL.
    As per your screenshot, you are registering for 64bit.
    So tally must be a 64bit application else register the DLL for 32bit.
    If you open the tally folder (where application exist) there will be an application named 'regodbc64' or 'regodbc32'
    if regodbc64 exist then the tally is 32bit
    if regodbc32 exist then the tally is 64bit
     

    Attached Files:



  8. Vaidehi Joshi

    Vaidehi Joshi New Member


    Thanks a lot, for this knowledge.In the power shell dll is not present with ProjectName.ClassName. May be it is not registered.
     


  9. teja varma

    teja varma Active Member


    Yes may project is not compiled properly
    or
    There is a chance that it is registered successfully because you got 'Types registered successfully' while registering using the Command prompt
    So it needs to troubleshoot step by step.
     


  10. Vaidehi Joshi

    Vaidehi Joshi New Member


    Hello,I run the below command in the shell, It gives a ID associated with the dll. Is it means registered?
    reg query HKLM\SOFTWARE\Classes /s /f ProjectName.dll
    output:
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{FFB75A02-E8EC-3918-8E9C-B22FA907DACA}\InprocServer32\1.0.0.0
    CodeBase REG_SZ file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/ProjectName.DLL
     


  11. teja varma

    teja varma Active Member


    Yes if that query returns any matches, then we can say that DLL is registered.
     


  12. Vaidehi Joshi

    Vaidehi Joshi New Member


    Hello, I made change in the tdl. Instead of a project name I put a Name space name in a project, and now the dll registration associated error was gone.But It is saying that "Failed to create an object of class COM Interface".Can you please guild me to find out the reason for this error?
     


  13. Vaidehi Joshi

    Vaidehi Joshi New Member


    Hello Sir, In an .net project Com interface method internally calling an API method which gives an error in tally calculator."Call to COM interface was made but an error occurred. This can because of wrong number of parameters or wrong type of parameters".
    After commenting API call method line, working fine.(API method is in another project reference is given)
    Please help me to solve this issue. Thanks
     


Share This Page