Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Determining a PDF's orientation

by friedo (Prior)
on Aug 22, 2005 at 07:13 UTC ( [id://485627]=note: print w/replies, xml ) Need Help??


in reply to Re: Determining a PDF's orientation
in thread Determining a PDF's orientation

Thanks, JamesNC++! I really appreciate you taking the time to post that. You clearly have a lot of experience with PDFs. My condolences.

Unfortunately your script is reporting R:0 for every PDF I try it on, even though some are clearly rotated. Perhaps I'm missing something. FWIW, these particular PDFs all have exactly one page (they came from various pdftk burst operations.)

Is there a particular reason why you are only buffering 256 bytes? I increased the buffer size to 65536 as it was taking several minutes to run on some of my PDFs.

Replies are listed 'Best First'.
Re^3: Determining a PDF's orientation
by JamesNC (Chaplain) on Aug 22, 2005 at 21:29 UTC
    That is a pretty big buffer size and I think 1024 would do just as well because it just gets chopped up anyway. R:0 means that the optional /Rotate entry is missing. If you know the page is in landscape mode, then the page MediaBox should match the page ie 0 0 792 612 would be 792 wide by 612 high ( 11 x 8 1/2 inches ). Now, if the text is rotated and it is not due to the /Rotate option in the viewer, then the reason is because the user space has been tranformed. In pdf speak:
    my $angle = 90; my $cos = sprintf("%.4f",cos( $angle*PI/180 )); my $sin = sprintf("%.4f",sin( $angle*PI/180 )); my $sin2 = -$sin; $rotate = "$cos $sin $sin2 $cos 0 0 cm ";
    the rotate scalar entry is applied to the contents of the page and then everything in that space still operates as if x and y are still the same.... but the page is just rotated.
    The page contents are often LZW or deflate encoded and you would have to decompress the contents to see if that were the case... kind of messy to do by hand if that is the case. I know how to do it... but that may not be the best solution for you. I would just try to infer from the page size and go from there. That is part of the challenge of trying to decode a Pdf... if the user space is tranlated or transformed then the consumer application needs to be aware of that. Perhaps you should send the author of that Pdf module a message to alert them about your problem, he might have overlooked something.
    Wish I could be more helpful.
    JamesNC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://485627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found