Hi Team ,
We are using java sdk of aspose. We are inserting image into existing pdf at particular coordinates. But after inserting image , the image get rotates. It is not happening with every pdf.
Below is code sample
Document pdfDocument = new com.aspose.pdf.Document("<<<>>>>>>>>");
String pathOfImage = “image1.jpg”
double xAxisCustom = 248;
double pdfCoord = 30;
Page pdfPage = pdfDocument.getPages().get_Item(1);
FileInputStream imageStream = new FileInputStream(pathOfImage);
pdfPage.getResources().getImages().add(imageStream);
pdfPage.getContents().add(new GSave());
Rectangle rectangle = new Rectangle(xAxisCustom as double, pdfCoord, xAxisCustom as double, pdfCoord);
Double[] db = [100, 0, 0, 40, xAxisCustom as double, pdfCoord] as Double[]
Matrix matrix = new Matrix(db);
pdfPage.getContents().add(new ConcatenateMatrix(matrix));
XImage ximage = pdfPage.getResources().getImages().get_Item(pdfPage.getResources().getImages().size());
pdfPage.getContents().add(new Do(ximage.getName()));
pdfPage.getContents().add(new GRestore());
imageStream.close();
I am also attaching pdfs and images
original_issue.pdf -> it is original pdf that has issue
image1.png ->using this image on original_issue.pdf
original_issue_insert_image.pdf ->updated pdf with rotated image
original.pdf -> it is the pdf which has no issue
image2.png ->using this image on original.pdf
original_insert_image.pdf -> update pdf after inserting image on pdf, it has no issue
Please help me on this topic
image1.png (1.6 KB)
image2.png (1.6 KB)
original.pdf (49.4 KB)
original_insert_image.pdf (51.4 KB)
original_issue.pdf (110.7 KB)
original_issue_insert_image.pdf (108.3 KB)