Hi,
We recently decided to go ahead and purchase the license for Aspose.PDF and everything appeared to be working just fine until recently noticing that one of the images on a form seems to move to different positions depending on the browser.
More specifically, we’ve noted the issue between IE 11 and Chrome. I have a TextFragment containing the following:
Signature: __________________________________________
Our client wanted the form to include someones e-signature on the signature line so to do this we acquired a png image from them containing the signature and then placed it on the form using code resembling this:
int lowerLeftX = 240;
int lowerLeftY = 325;
int upperRightX = 340;
int upperRightY = 278;
var imageName = @“C:\Sandbox\AsposePDF\esignature.png”;
//get the page where image needs to be added
Aspose.Pdf.Page page = pdfDocument.Pages[1];
FileStream imageStream = new FileStream(imageName, FileMode.Open);
page.Resources.Images.Add(imageStream);
//using GSave operator: this operator saves current graphics state
page.Contents.Add(new 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 Operator.ConcatenateMatrix(matrix));
XImage ximage = page.Resources.Images[page.Resources.Images.Count];
//using Do operator: this operator draws image
page.Contents.Add(new Operator.Do(ximage.Name));
//using GRestore operator: this operator restores graphics state
page.Contents.Add(new Operator.GRestore());
imageStream.Close();
imageStream.Dispose();
During testing, I was able to set the image perfectly aligned on top of the signature line by affirming the result in IE 11. But after deploying the solution out someone discovered that the image was positioned approximately 100 or more pixels above the line in Chrome.
I am accustomed to discrepancies within browsers; especially with the diverse interpretation for pixel widths. So although I wouldn’t have imagined this issue to be attributed to browser rendering as much as a feature within the Aspose API; even so, we are looking at more than a couple of pixel differences that we could otherwise accept.
Is there a more appropriate way to position the image on the TextFragment line that we should be using? How can we overcome this huge discrepancy?
Please help!
=========================
RECENT UPDATE
=========================
In the process of troubleshooting this issue we’ve found some new information. Apparently the issue is only prevalent after deployment to our Azure Cloud Server. Locally the graphical location is consistent between Chrome and IE after rendering.
Hopefully this new piece of information will provide some insight as to why this is occurring. Why the anomaly exists between browser platform only after deployment is still puzzling though.