How to change the coordinates of a text in a pdf page from lower left to upper left

前端 未结 2 1279
既然无缘
既然无缘 2021-01-25 15:03

I am using PDFBOX and itextsharp dll and processing a pdf. so that I get the text coordinates of the text within a rectangle. the rectangle coordinates are extracted using the i

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-25 15:20

              if ((mediabox.Top - mediabox.Height) != 0)
                {
                    topY = mediabox.Top;
                    heightY = mediabox.Height;
                    diffY = topY - heightY;
                    lly_adjust = (topY - ury) + diffY;
                    ury_adjust = (topY - lly) + diffY;
                }
                else if ((cropbox.Top - cropbox.Height) != 0)
                {
                    topY = mediabox.Top;
                    heightY = cropbox.Top;
                    diffY = topY - heightY;
                    lly_adjust = (topY - ury) - diffY;
                    ury_adjust = (topY - lly) - diffY;
    
                }
                else
                {
    
                    lly_adjust = mediabox.Top - ury;
                    ury_adjust = mediabox.Top - lly;
    
                }
    

    These are final adjustment done

提交回复
热议问题