What is llx, lly , yrx and ury in rectangle coordinates. When i passed llx as x-axis value, lly as y-axis, urx as width, ury as height. For example am passing 887, 515, 106, 446 in a pdf but it is cropping some other zone.
Document document = new Document(myDir + “CNI_1958_01_01_FE_01_MN.pdf”);<o:p></o:p>
com.aspose.pdf.Rectangle rect = document.getPages().get_Item(1).getRect();
com.aspose.pdf.Rectangle pageRect = new com.aspose.pdf.Rectangle(889.92, 927.36, 990, 1065);
document.save(myDir + "crop_java.pdf");
can you provide the calculation formula
Old but always needed for many I guess
In fact your answer was not 100% correct imho. Here is my code that solves the requirements to give x,y, width and height based on the idea that 0,0 for x,y is top-left of a document.
private readonly float _mm2Pt = Convert.ToSingle(0.352777778); var pdfDocument = new Document(fs); var currentPage = pdfDocument.Pages[pageNumber]; var pHeight = currentPage.Rect.Height; var bX = (x / _mm2Pt); var bY = pHeight - (y / _mm2Pt) - (h / _mm2Pt); var bW = bX + (w / _mm2Pt); var bH = bY + (h / _mm2Pt); var appearance = new DefaultAppearance(font, fontSize, System.Drawing.Color.FromName(fontColor)); var rectangle = new Rectangle(bX, bY, bW, bH);
And btw, I made x,y,w,h values given in mm, easier for me as euro…
Thanks for sharing these details.
It is good to know that you have managed to get the desired results. Your shared code snippet would definitely help others facing similar issue. Please keep using our API and in case of any further assistance, please feel free to let us know.