Signature invalid after signing a PDF created with Aspose.PDF

After signing a PDF that was created using Aspose.Pdf, it shows that the signature is invalid.
We use the following code to create the pdf (Note: We are rasterizing a PDF document into images and then creating a new PDF with those images).
We have tried using Aspose.Pdf v 10.6, 10.8 and 11. All give the signature invalid when opening the document in adobe reader.
I have attached the documents as well as screenshots.
The code we are using is below (Please use your own .pfx as the one in the sample is for production ):

static void Main(string[] args)
{
try
{
string inputDocument = @“E:\Aspose\input.pdf”;
string OutputDirectory = @“E:\Aspose”;
byte[] licenceBytes = File.ReadAllBytes(@“E:\Aspose\Aspose.Total.lic”);
MemoryStream msPdfLic = new MemoryStream(licenceBytes);
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense(msPdfLic);
//1 - convert to images
byte[] inputPdf = File.ReadAllBytes(inputDocument);
MemoryStream memStr = new MemoryStream(inputPdf);
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(memStr);
List<byte[]> imagesCreated = new List<byte[]>();
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
MemoryStream imageStream = new MemoryStream();
Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(150);
// where Quality [0-100], 100 is Maximum
Aspose.Pdf.Devices.JpegDevice jpegDevice = new Aspose.Pdf.Devices.JpegDevice(resolution, 100);
jpegDevice.Process(pdfDocument.Pages[pageCount], imageStream);
imagesCreated.Add(imageStream.ToArray());
imageStream.Close();
}
//1 - complete
//2 - convert images to pdf
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
foreach (byte[] imageBytes in imagesCreated)
{
Page page = doc.Pages.Add();
MemoryStream imageStream = new MemoryStream(imageBytes);
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Right = 0;
using (System.Drawing.Bitmap myimage = new System.Drawing.Bitmap(imageStream))
{
page.PageInfo.Height = myimage.Height;
page.PageInfo.Width = myimage.Width;
}
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
//Global.log.Debug("[ConvertImagesToPdf] - \tAdding image to page");
image1.ImageStream = imageStream;
page.Paragraphs.Add(image1);
}
MemoryStream ms = new MemoryStream();
byte[] outputDocument = null;
try
{
doc.Save(ms);
outputDocument = ms.ToArray();
}
catch (Exception ex)
{
Console.Out.WriteLine("Exception : " + ex.Message);
}
ms.Close();
//saving rasterized Pdf for debug
File.WriteAllBytes(OutputDirectory + “output_rasterized.pdf”, outputDocument);
//2 - complete
//3 - sign
using (Document document = new Document(OutputDirectory + “output_rasterized.pdf”))
{
using (PdfFileSignature signature = new PdfFileSignature(document))
{
PKCS7 pkcs = new PKCS7(@“C:\certstore\GPAPI.pfx”, “PasswordGoesHere”); // Use PKCS7/PKCS7Detached objects
DocMDPSignature docMdpSignature = new DocMDPSignature(pkcs, DocMDPAccessPermissions.FillingInForms);
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);
signature.Certify(1, “Signature Reason”, “Contact”, “Location”, true, rect, docMdpSignature);
//save output PDF file
signature.Save(OutputDirectory + “output_signed.pdf”);
}
}
}
catch (Exception ex)
{
Console.Out.WriteLine("Exception : " + ex.Message);
}
Console.ReadLine();
}

Hi Rendu,


Thanks
for using our API’s.
<o:p></o:p>

I
have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWNET-39732 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.

Do you have an estimate on how long it will take before this is fixed?

We purchased a licence in order to use this functionality and now we cannot move forward in our deployment because of this issue.

Kind regards,
Tim

Hi Tim,


Thanks for your inquiry. I am afraid we have recently noticed the issue and it is pending for investigation in the queue with other issues, reported earlier. We can not share an ETA unless investigation of the issue is completed. We will notify you as soon as we made some significant progress towards issue resolution.

We are sorry for the inconvenience.

Best Regards,
Has the issue been resolved?
We have not received any feedback.
It's been almost 3 months.

Hi Tim,


Thanks for your patience.

The issue reported earlier is still pending for review and is not yet resolved. Though its been 3 months but as the team has been busy fixing other previously reported high priority issues, this problem is not yet resolved. Nevertheless, the team will start investigating this issue as per their schedule and as soon as we have some further updates, we will let you know.

We are sorry for this delay and inconvenience.

Hi Support Team,


Please can you give this customer an update on this issue.

Many thanks,

John

Hi Tim,


We are sorry for the inconvenience. The issue is still not resolved as product team is busy in resolving other high priority issues. However we have raised issue priority of your ticket and requested our team to analyse the issue and share an ETA/update as soon as possible. We will notify you as soon as we get any further update.

Thanks for your patience and cooperation.

Best Regards,

The issues you have found earlier (filed as PDFNET-39732) have been fixed in Aspose.PDF for .NET 21.8.