Free Support Forum - groupdocs.com

GroupDocs.Signature

GroupDocs.Signature throwing error like GroupDocs.Signature.GroupDocsSignatureException: ‘Could not load file or assembly ‘Aspose.PDF, Version=19.11.0.0, Culture=neutral, PublicKeyToken=f0262d67fe233d63’ or one of its dependencies. The system cannot find the file specified.’
please help, as we planed buy license for same

1 Like

@anil.kumar1994,

In order to investigate this at our end, we need following details:

  • API platform (Java or .NET)
  • API version that you are evaluating (e.g. 19.8, 19.9)
  • Sample code or application using that issue could be reproduced

@atirtahir3
API platform : .Net
Please find below for the details

  1. We actually trying to sign the pdf through Groupdocs.Signature, and it is perfectly works
    fine.
  2. When i add Groupdocs.WaterMark dll in the same project to add watermark on signed
    pdf(through Groupdocs.Signature) then i am getting this issue.

Please note that both GroupDocs.Signatue and Groupdocs.Watermark both work fine in different solution , this issue only occurs when we add both dll in same project

Groupdocs.Signature version : v19.10.0 (downloaded from nuget)
Groupdocs.WaterMark version :v19.11.0 ((downloaded from nuget))

1 Like

sample code
public static void Run()
{
string filePath = Constants.SAMPLE_PDF;
string fileName = Path.GetFileName(filePath);
string outputFilePath = Path.Combine(Constants.OutputPath, “SignPdfWithCustomMetadata”, fileName);
using (Signature signature = new Signature(filePath))
{
// setup options with text of signature
MetadataSignOptions options = new MetadataSignOptions();
// create custom object
DocumentSignatureData documentSignature = new DocumentSignatureData()
{
ID = Guid.NewGuid().ToString(),
Author = Environment.UserName,
Signed = DateTime.Now,
DataFactor = 11.22M,
IPAddress = “107.21.106.63”,
};
IDataEncryption encryption = new CustomXOREncryptionAttribute();

            // Specify different Metadata Signatures and add them to options signature collection
            // for this metadata encryption will be used from class attribute
            PdfMetadataSignature mdDocument = new PdfMetadataSignature("DocumentSignature", documentSignature);

            // setup Author property
            PdfMetadataSignature mdAuthor = new PdfMetadataSignature("Author", "Mr.Scherlock Holmes");
            // set encryption
            mdAuthor.DataEncryption = encryption;

            // setup data of document id
            PdfMetadataSignature mdDocId = new PdfMetadataSignature("DocumentId", Guid.NewGuid().ToString());
            // set encryption
            mdDocId.DataEncryption = encryption;

            // add signatures to options
            options.Signatures.Add(mdDocument);
            options.Signatures.Add(mdAuthor);
            options.Signatures.Add(mdDocId);

            // sign document to file
            signature.Sign(outputFilePath, options);
            AddWaterMark();
        }
    }
    public static void AddWaterMark()
    {
        string filePath = Constants.SAMPLE_PDF;
        string fileName = Path.GetFileName(filePath);
        string outputFilePath = Path.Combine("../../Output/", "AddWaterMark", "image"+fileName);
        PdfLoadOptions loadOptions = new PdfLoadOptions();
        // Constants.InDocumentPdf is an absolute or relative path to your document. Ex: @"C:\Docs\document.pdf"
        using (Watermarker watermarker = new Watermarker(filePath, loadOptions))
        {
            // Add text watermark to the first page
            GroupDocs.Watermark.Watermarks.TextWatermark textWatermark = new GroupDocs.Watermark.Watermarks.TextWatermark("No need of signature,file is electornically signed", new GroupDocs.Watermark.Watermarks.Font("Arial", 21));
            PdfArtifactWatermarkOptions textWatermarkOptions = new PdfArtifactWatermarkOptions();
            textWatermarkOptions.PageIndex = 0;
            textWatermark.ForegroundColor = Color.Red;
            textWatermark.X = 75;
            textWatermark.Y = 25;
            watermarker.Add(textWatermark, textWatermarkOptions);
            watermarker.Save(outputFilePath);
        }
1 Like

@anil.kumar1994,

Thanks for sharing the details. We are not able to reproduce this issue at our end using code below:

public static void signature()
{
    using (Signature signature = new Signature(@"D:\Samples\s.pdf"))
    {
        TextSignOptions options = new TextSignOptions("John Smith")
        {
            // set signature position
            Left = 100,
            Top = 100,
            // set signature rectangle
            Width = 100,
            Height = 30,                   
            Font = new SignatureFont { Size = 12, FamilyName = "Comic Sans MS" }
        };
        // sign document to file
        signature.Sign(@"D:\Samples\sample_signed.pdf", options);
    }
    AddWaterMark();
}

This is how we are adding watermark:

public static void AddWaterMark()
{
    string filePath = @"D:\Samples\sample_signed.pdf";
    string fileName = Path.GetFileName(filePath);
    string outputFilePath = Path.Combine(@"D:\Samples\", "image"+fileName);
    GroupDocs.Watermark.Options.Pdf.PdfLoadOptions loadOptions = new GroupDocs.Watermark.Options.Pdf.PdfLoadOptions();
    using (Watermarker watermarker = new Watermarker(filePath, loadOptions))
    {
        // Add text watermark to the first page
        GroupDocs.Watermark.Watermarks.TextWatermark textWatermark = new GroupDocs.Watermark.Watermarks.TextWatermark("No need of signature,file is electornically signed", new GroupDocs.Watermark.Watermarks.Font("Arial", 21));
        PdfArtifactWatermarkOptions textWatermarkOptions = new PdfArtifactWatermarkOptions();
        textWatermarkOptions.PageIndex = 0;
        textWatermark.ForegroundColor = Color.Red;
        textWatermark.X = 75;
        textWatermark.Y = 25;
        watermarker.Add(textWatermark, textWatermarkOptions);
        watermarker.Save(outputFilePath);
    }
}

This is the output (195.9 KB) we got. Can you please test this code at your end. Also, if you can share your sample project (a simple console based application using that issue could be reproduced), we’ll investigate that.

@atirtahir3
Thanks for reply , I am doing my poc by cloning your github project. Let me check once again and will get back to you .

Let me know how you want to share my project .

@atirtahir3
I have created new console application and added your code , but still no luck

image.png (121.5 KB)

1 Like

@anil.kumar1994,

Please share project here (in this same thread). You can remove DLLs in order to reduce project size. Moreover, please don’t add license file in the project.

@atirtahir3
MyPoc.zip (178.4 KB)
Please take a look

1 Like

@anil.kumar1994,

This issue is reproduced at our end using the provided project. Hence, its been logged in our internal issue tracking system with ID : SIGNATURENET-2471. We are now investigating it. As there is any update, you’ll be notified.

Any update @atirtahir3 ? , Thank you

1 Like

@anil.kumar1994,

This issue is still under investigation. We’ll notify you as there’s any update.

@anil.kumar1994,

We have an update on SIGNATURENET-2471. Please go to the project properties and mark flag [Auto-generate binding redirects] to unchecked state. See this screenshot.png (8.6 KB). Actually the best way would be to set this flag to false and reinstall packages.
The other way is, if there is no app.config file in the project, it’ll work fine. Please let us know if it works for you.

1 Like

It did work for me , thanks for the solution . Appreciated
@atirtahir3

1 Like

@anil.kumar1994,

Glad to hear. You’re welcome.