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

Free Support Forum - aspose.com

Rotated Page and object coordinates

I have documents that are rotated (90, 180 and 270) and I’ve been having several issues positioning objects properly as the coordinates system is inconsistent and some cases, the element even disappear.

In short, I need to draw a rectangle (opaque) where there is a label and an icon on the top right corner of it.

The sample code below highlights the two main issues I’ve been facing:

  1. When I rotate the text fragment, the text disappear as the inner rectangle is not rotating along with it (even if I update the rectangle coordinates manually).
  2. The image coordinate system is completely different from the floating box with text coordinates, somehow the position 0x0 is out of the page.
package com.csdisco.publications.pdf.decorate;

import com.aspose.pdf.*;
import com.csdisco.publications.pdf.decorate.util.Licenser;
import com.csdisco.shared.pdf.aspose.processing.ProcessingEngine;
import com.csdisco.shared.pdf.aspose.processing.doc.impl.PdfProcessingDocument;

import javax.imageio.ImageIO;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
import java.io.*;
import java.util.Locale;

public class Main2 {
    public static void main(String[] args) throws IOException {
        var doc = new PdfProcessingDocument("Ferrari 308 Quattrovalvole, 328 GTB, 328 GTS Workshop Manual.pdf");

        var image = new Image();
        var floatingBox = new FloatingBox(50, 50);
        doc.getPage(3).getPageInfo().setMargin(new MarginInfo(0,0,0,0));

        var floatingBox2 = new FloatingBox();
        var textFragment = new TextFragment("Description");


    private static InputStream createImage() throws IOException {
        try (InputStream is = Spike4.class.getClassLoader().getResourceAsStream("annotation-multiple.png");
             InputStream imageStream = new ByteArrayInputStream(is.readAllBytes());
             ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
            BufferedImage originalImage = ImageIO.read(imageStream);
            BufferedImage argbImage = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(),
            Graphics2D createGraphics = argbImage.createGraphics();
            createGraphics.drawImage(originalImage, 0, 0, originalImage.getWidth(), originalImage.getHeight(), null);
            // Preserve the RGB, just change opacity (Alpha).
            RescaleOp r = new RescaleOp(new float[]{1f, 1f, 1f, 255}, new float[]{0, 0, 0, 0}, null);
            BufferedImage transparentImage = r.filter(argbImage, null);

            // GIF or PNG are the formats that support transparency. PNG has higher definition overall, so using it.
            ImageIO.write(transparentImage, "png", baos);
            return new ByteArrayInputStream(baos.toByteArray());

Document being used can be found here: https://www.manualslib.com/manual/453076/Ferrari-328-Gtb.html

Can you please clarify how does the coordinate system works? Additionally, is there a way to “discard” the rotation, preserving the content as-is?


Can you please provide all the input files so I can try to replicate the problem?

Please find it attached.annotation-multiple.jpg (90.9 KB)
Ferrari 308 Quattrovalvole, 328 GTB, 328 GTS Workshop Manual.pdf (7.3 MB)


I was able to recreate the issue. I will be create a ticket for the dev team.


To eliminate the rotation of a page you can use:

foreach (var page in doc.Pages)
   page.Rotate = Rotation.None; 

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-53769

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.