unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.47k stars 250 forks source link

[BUG] A rotated PDF cannot be rotated again #475

Closed leep-frog closed 2 years ago

leep-frog commented 2 years ago

Description

A file can only be rotated once

Expected Behavior

Upon a second rotation attempt, I expected the pdf to either be rotated again or for an error to be returned.

Actual Behavior

Using this example on the same file twice in a row only changes the file once:

go run pdf_rotate.go simple.pdf simple.pdf 90 # rotates the file by 90 degrees successfully
go run pdf_rotate.go simple.pdf simple.pdf 180 # nothing happens, and no error is returned
github-actions[bot] commented 2 years ago

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

gunnsth commented 2 years ago

The problem was with the example as it had hardcoded 90 degrees, fixed in https://github.com/unidoc/unipdf-examples/pull/172

leep-frog commented 2 years ago

The issue is still not fixed. Try rotating the pdf twice (one 90 degrees and once 180 degrees) and the second rotation still won't work. I don't think it's merely an issue with the example. The underlying implementation appears to be unable to rotate an already rotated image.

gunnsth commented 2 years ago

It sets the rotation flag, so if you set it to 90 it goes to 90, if you set it to 180. If you want it to add to the current rotation setting, then you need to simply get the current rotation and add to it. The Rotate field goes in 90 degree increments.

leep-frog commented 2 years ago

Right. I basically do the following things though:

set rotation 90 myPdf.pdf # works
set rotation 180 myPdf.pdf # does not work

It seems like there is an issue when the rotation is already set.