We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pdf version 11.5

I’m facing the problem when upgrade pdf from 11.4 to 11.5, the merge image function won’t work, I have now downgrade to 11.4 already and it keeps work fine,I have included the needed input in the attached file, please check what’s happening for me. Thanks.

private string MergeIdPhotosDocument(string p_Content, IDPhotoImages p_IdP, out byte[] p_IDFront, out byte[] p_IDRear, out byte[] p_IdFileContent)
byte[] _Content = Convert.FromBase64String(p_Content);
string _RStr = “”;
//byte[] _Buffer;
byte[] _BufferF = null;
byte[] _BufferB = null;
byte[] _BufferFile = null;
[//System.IO.File.WriteAllBytes](https://system.io.file.writeallbytes/)(@“c:\temp\IDTemplae.pdf”, _Content);
//string _IDTemplateName = GV.RootPath + @“System\Documents\身分證套表單.pdf”;
//if (System.IO.File.Exists(_IDTemplateName))
if(_Content != null)
[//Aspose.Pdf.Document](https://aspose.pdf.document/) pdfDocument = new Aspose.Pdf.Document(_IDTemplateName);
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(new MemoryStream( _Content));
// Get the page where image needs to be added
Aspose.Pdf.Page page = pdfDocument.Pages[1];

// Load image into stream
//FileStream imageStream = new FileStream(dataDir + “[//IDNF.jpg](https://idnf.jpg/)”, FileMode.Open);
_BufferF = Convert.FromBase64String(p_IdP.NormalFront);
MemoryStream imageStream = new MemoryStream(_BufferF);
AddImageToPdf(page, imageStream, 70, 450, 270, 570);

if (p_IdP.NormalBack != “”)
_BufferB = Convert.FromBase64String(p_IdP.NormalBack);
imageStream = new MemoryStream(_BufferB);
AddImageToPdf(page, imageStream, 320, 450, 520, 570);

if (p_IdP.UVFront != “”)
imageStream = new MemoryStream(Convert.FromBase64String(p_IdP.UVFront));
AddImageToPdf(page, imageStream, 70, 200, 270, 320);

if (p_IdP.UVBack != “”)
imageStream = new MemoryStream(Convert.FromBase64String(p_IdP.UVBack));
AddImageToPdf(page, imageStream, 320, 200, 520, 320);
// Save updated document
MemoryStream _Ms = new MemoryStream();
[//pdfDocument.Save](https://pdfdocument.save/)(@“c:\temp\MarkResult.pdf”, SaveFormat.Pdf);
_BufferFile = _Ms.ToArray();
_RStr = “ok”;
catch (Exception ex)
LogUtility.Log(m_Context, LogLevel.Error, CN, “MergeIdPhotosDocument”, “”, ex.ToString());

_RStr = CN + “MergeIdPhotosDocument” + ex.ToString();
_RStr = “ID Template not found” ;

p_IDFront = _BufferF;
p_IDRear = _BufferB;
p_IdFileContent = _BufferFile;
[//System.IO.File.WriteAllBytes](https://system.io.file.writeallbytes/)(@“c:\temp\IDFront.jpg”, _BufferF);
[//System.IO.File.WriteAllBytes](https://system.io.file.writeallbytes/)(@“c:\temp\IFRear.jpg”, _BufferB);
[//System.IO.File.WriteAllBytes](https://system.io.file.writeallbytes/)(@“c:\temp\IDResult.pdf”, _BufferFile);

return _RStr;

private void AddImageToPdf(Aspose.Pdf.Page page, MemoryStream imageStream, int lowerLeftX, int lowerLeftY, int upperRightX, int upperRightY)
// Add image to Images collection of Page Resources

// Using GSave operator: this operator saves current graphics state
page.Contents.Add(new Aspose.Pdf.Operator.GSave());

// Create Rectangle and Matrix objects
Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY);
Aspose.Pdf.DOM.Matrix matrix = new Aspose.Pdf.DOM.Matrix(new double[] { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY });

// Using ConcatenateMatrix (concatenate matrix) operator: defines how image must be placed
page.Contents.Add(new Aspose.Pdf.Operator.ConcatenateMatrix(matrix));
Aspose.Pdf.XImage ximage = page.Resources.Images[page.Resources.Images.Count];

// Using Do operator: this operator draws image
page.Contents.Add(new Aspose.Pdf.Operator.Do(ximage.Name));

// Using GRestore operator: this operator restores graphics state
page.Contents.Add(new Aspose.Pdf.Operator.GRestore());

Hi Mark,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 11.5.0 and have managed to reproduce the same issue. However when using latest release of Aspose.Pdf for .NET 11.6.0, the problem seems to be fixed. For your reference, I have also attached the output generated over my end. Can you please try using the latest release and in case you still face the same problem or you have any further query, please feel free to contact.

We are sorry for this inconvenience.