Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jan 31, 2025 11:45 am

I'm adding an image to a PDF signature. For some reason the quality of the image is lost and it becomes distorted.

I'm using .Net 6(C#) with the code below:

Code: Select all
    RectangleF rectangleF = new RectangleF(x, y, width, height);
    signature.Bounds = rectangleF;
    signature.Certificated = true;
    //Set the graphics mode
    signature.GraphicsMode = imageSignatureAsBase64 != null ? GraphicMode.SignImageAndSignDetail : GraphicMode.SignDetail;
    //Timezone Sao_Paulo UTC-3
    signature.DateLabel = $"{locationInfoLabel}, {DateTime.UtcNow.AddHours(-3).ToString("dd/MM/yyyy HH:mm:ss")}";
    signature.ContactInfoLabel = contactInfoLabel;
    signature.DistinguishedNameLabel = "Assinado digitalmente por Orizon";
    signature.ReasonLabel = $"Certificado: {cert.GetNameInfo(X509NameType.SimpleName, false)}";

    //Set the signature content
    if (imageSignatureAsBase64 != null)
    {
      MemoryStream msImageSignature = new MemoryStream(Convert.FromBase64String(imageSignatureAsBase64));
      signature.SignImageSource = PdfImage.FromStream(msImageSignature);
    }
   
    //Save to another stream file
    MemoryStream msResult = new();
    doc.SaveToStream(msResult);
    doc.Close();


Does anyone know what I can do to fix this problem?

Thanks!

emirdeliz
 
Posts: 1
Joined: Fri Jan 31, 2025 11:30 am

Tue Feb 04, 2025 8:11 am

Hello,

Thanks for your inquiry.
For your issue, please first check if the image itself is clear. If there is no problem with the image itself, please provide us with your image and the current input pdf file to help us further investigate. Thank you in advance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF