Rotating pdf image resluts in distorted image

Discussions about PDF management.
Post Reply
thogal44
Posts: 4
Joined: Mon Jun 25, 2012 4:30 pm

Pdf rotation

Post by thogal44 » Tue Jun 26, 2012 2:14 pm

Hi all

i have a problem with the rotation.

What i have :

- GdViewer
- GdPicturePDF

What i do :

- i draw on the pdf page plenty of AnnotationRubberStamps ( a fill ellispe with a number inside) (=>OK)
- I rotate the pdf page : (90°)

Code: Select all

 m_NativePDF.RotatePage(90)
GdViewer1.RotateAnnotations(90)
'code to rotate the annotations in the good way of reading :
 Me.MesPages(Me.GdViewer1.CurrentPage - 1).RotationPage = m_NativePDF.GetPageRotation
        For i As Integer = 0 To GdViewer1.GetAnnotationCount - 1
            Dim myannot As GdPicture.AnnotationRubberStamp = CType(GdViewer1.GetAnnotationFromIdx(i), GdPicture.AnnotationRubberStamp)
            myannot.Rotation = 360 - Me.MesPages(Me.GdViewer1.CurrentPage - 1).RotationPage
        Next
=>OK the page and the annotations are rotated and each annotation are in the good position.

BUT if i add more annotation on this rotated page ... i am not abble to set the good rotation of this one ..
i have tried many things ( reset rotation of all before adding, find the good rotation,.. ) but i failed.

Thanks for helping.

fs051268
Posts: 25
Joined: Wed May 22, 2013 4:00 pm

Rotating pdf image resluts in distorted image

Post by fs051268 » Wed Mar 23, 2016 1:32 pm

Hi,

I am trying to rotate an image on a pdf page (see attached 90-degrees.pdf)
The outcome is test.pdf which is distorted.

The way I am doing it is:
- get the image form the page using ExtractPageImage function
- then I am saving the image to a file using SaveAsTIFF function
- I am running an external rotation detection function (which currently only works file based, that's why I have to save it to file)
- after detection of the rotation, I reload the tiff file using CreateGdPictureImageFromFile()
- then I call the function RotateAngle() to rotate the tiff (rotated.tif is also attached in zip)
- now I call ReplaceImage() to replace the image on the page with the rotated one

the outcome is the distorted image.
What am I doing wrong?

Thanks for your support.
Attachments
test.zip
(344 KiB) Downloaded 276 times

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Rotating pdf image resluts in distorted image

Post by Cedric » Thu Mar 24, 2016 4:52 pm

Hello,

The approach is not good, you should either rotate the PDF page or create a new page with the new content to replace the old one.
You are altering the image dimensions by applying the rotation, the width become the height and the height become the new width.
The issue is that the images properties stay the same in the PDF so the aspect ratio is wrong because it still applies the old width and height.

fs051268
Posts: 25
Joined: Wed May 22, 2013 4:00 pm

Re: Rotating pdf image resluts in distorted image

Post by fs051268 » Fri Mar 25, 2016 12:07 pm

Thanks for your support. Using the suggested way and it works fine.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests