You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Pepijn Schmitz <pd...@chaos.demon.nl> on 2008/09/07 15:45:04 UTC

How to determine aspect ratio of faxed TIFF

Hi everyone, 
 
I'm using PDFBox to receive faxes. Our fax service provider receives
them and emails them to us as PDF attachments. I'm reading the emails,
extracting the PDF attachments and then using PDFBox to extract the TIFF
images from the PDF's. 
 
This works great (after I found out I had to install the JAI ImageIO
Tools), but there is one problem: for some faxes the TIFF's are only
half-height. The whole page is there, but is is squashed in the vertical
direction. I imagine that these are faxes which were sent at some kind
of "coarse" setting.
 
The thing is, if I open these PDF's in Adobe Reader they are displayed
with the correct aspect ratio. So somewhere in the PDF there must be
information telling Adobe Reader to scale the image up in the vertical
direction, but I don't know how to get at this information.
 
Can someone here help me with this problem? Do you know how this
information is stored in the PDF, and how I could get at it with PDFBox?
Is it stored in the TIFF itself somehow? I could email interested
parties one of the PDF's if it would help.
 
Kind regards, 
Pepijn Schmitz

Re: How to determine aspect ratio of faxed TIFF

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Sat, Sep 20, 2008 at 11:44 AM, Pepijn Schmitz <pd...@chaos.demon.nl> wrote:
> I thought I might try again with this question, having received no
> replies at all the previous time. In fact I haven't seen any traffic on
> this list, is it even being read?

Sorry for the silence, we're still in progress of getting everything
and everyone migrated to Apache.

> The question is: how can I find out from a PDF at which aspect ratio to
> display an embedded fax-originated TIFF?

Unfortunately that's beyond my limits of knowledge. Does any of the
PDFBox experts here have an idea?

BR,

Jukka Zitting

Re: How to determine aspect ratio of faxed TIFF

Posted by Andreas Lehmkühler <an...@lehmi.de>.
Pepijn Schmitz schrieb:
> Andreas Lehmkühler wrote:
>> Pepijn Schmitz schrieb:
>>> The question is: how can I find out from a PDF at which aspect ratio to
>>> display an embedded fax-originated TIFF?
>> Pictures are saved in their original format. The scaling is done by
>> the pdf. If you insert a graphic as PDXObject to a page you have to
>> mention the starting coordinates and the scaling of both axes relative
>> to their original size.
>> This means that you have to extract the picture and you have to get
>> the scalingfacros from the corresponding XObject.
> Thanks for the info! I have some more questions now:
> 
> How do I get the scaling factors for the image? The image in question is
> contained in a PDXObjectImage object, and that class has a width and a
> height property, is that what you are referring to? Unfortunately the
I have a look at the sourcecode and I realized that I was wrong. You 
don't have to put in the scaling factors, you have to use the width and 
the height. The image is automatically scaled from its original size to 
that one you put into the method PDPageContentStream.drawXObject
Sorry for that mistake.
But now it's clear what you have to do. Just get the width and the 
height from the XObject and you have all you're looking for.

> Javadoc fails to mention in what units the width and height are
> specified, do you happen to know the units of these properties?
The unit is pixel based on the size of the pdf-page.


Andreas
-- 
Auf der Verpackung stand "benötigt Windows 9x/2000/XP oder BESSER", also 
habe ich Linux installiert.

Re: How to determine aspect ratio of faxed TIFF

Posted by Pepijn Schmitz <pd...@chaos.demon.nl>.
Andreas Lehmkühler wrote:
> Pepijn Schmitz schrieb:
>> The question is: how can I find out from a PDF at which aspect ratio to
>> display an embedded fax-originated TIFF?
> Pictures are saved in their original format. The scaling is done by
> the pdf. If you insert a graphic as PDXObject to a page you have to
> mention the starting coordinates and the scaling of both axes relative
> to their original size.
> This means that you have to extract the picture and you have to get
> the scalingfacros from the corresponding XObject.
Thanks for the info! I have some more questions now:

How do I get the scaling factors for the image? The image in question is
contained in a PDXObjectImage object, and that class has a width and a
height property, is that what you are referring to? Unfortunately the
Javadoc fails to mention in what units the width and height are
specified, do you happen to know the units of these properties?

Kind regards,
Pepijn Schmitz
>
>
> Andreas
>
>
>>
>> Cheers,
>> Pepijn
>>
>> Pepijn Schmitz wrote:
>>> Hi everyone,  
>>> I'm using PDFBox to receive faxes. Our fax service provider receives
>>> them and emails them to us as PDF attachments. I'm reading the emails,
>>> extracting the PDF attachments and then using PDFBox to extract the
>>> TIFF
>>> images from the PDF's.  
>>> This works great (after I found out I had to install the JAI ImageIO
>>> Tools), but there is one problem: for some faxes the TIFF's are only
>>> half-height. The whole page is there, but is is squashed in the
>>> vertical
>>> direction. I imagine that these are faxes which were sent at some kind
>>> of "coarse" setting.
>>>  
>>> The thing is, if I open these PDF's in Adobe Reader they are displayed
>>> with the correct aspect ratio. So somewhere in the PDF there must be
>>> information telling Adobe Reader to scale the image up in the vertical
>>> direction, but I don't know how to get at this information.
>>>  
>>> Can someone here help me with this problem? Do you know how this
>>> information is stored in the PDF, and how I could get at it with
>>> PDFBox?
>>> Is it stored in the TIFF itself somehow? I could email interested
>>> parties one of the PDF's if it would help.
>>>  
>>> Kind regards, Pepijn Schmitz
>>>
>
>


Re: How to determine aspect ratio of faxed TIFF

Posted by Andreas Lehmkühler <an...@lehmi.de>.
Pepijn Schmitz schrieb:
> *BUMP*
> 
> I thought I might try again with this question, having received no
> replies at all the previous time. In fact I haven't seen any traffic on
> this list, is it even being read?
> 
> The question is: how can I find out from a PDF at which aspect ratio to
> display an embedded fax-originated TIFF?
Pictures are saved in their original format. The scaling is done by the 
pdf. If you insert a graphic as PDXObject to a page you have to mention 
the starting coordinates and the scaling of both axes relative to their 
original size.
This means that you have to extract the picture and you have to get the 
scalingfacros from the corresponding XObject.


Andreas


> 
> Cheers,
> Pepijn
> 
> Pepijn Schmitz wrote:
>> Hi everyone, 
>>  
>> I'm using PDFBox to receive faxes. Our fax service provider receives
>> them and emails them to us as PDF attachments. I'm reading the emails,
>> extracting the PDF attachments and then using PDFBox to extract the TIFF
>> images from the PDF's. 
>>  
>> This works great (after I found out I had to install the JAI ImageIO
>> Tools), but there is one problem: for some faxes the TIFF's are only
>> half-height. The whole page is there, but is is squashed in the vertical
>> direction. I imagine that these are faxes which were sent at some kind
>> of "coarse" setting.
>>  
>> The thing is, if I open these PDF's in Adobe Reader they are displayed
>> with the correct aspect ratio. So somewhere in the PDF there must be
>> information telling Adobe Reader to scale the image up in the vertical
>> direction, but I don't know how to get at this information.
>>  
>> Can someone here help me with this problem? Do you know how this
>> information is stored in the PDF, and how I could get at it with PDFBox?
>> Is it stored in the TIFF itself somehow? I could email interested
>> parties one of the PDF's if it would help.
>>  
>> Kind regards, 
>> Pepijn Schmitz
>>


-- 
Auf der Verpackung stand "benötigt Windows 9x/2000/XP oder BESSER", also 
habe ich Linux installiert.

Re: How to determine aspect ratio of faxed TIFF

Posted by Pepijn Schmitz <pd...@chaos.demon.nl>.
*BUMP*

I thought I might try again with this question, having received no
replies at all the previous time. In fact I haven't seen any traffic on
this list, is it even being read?

The question is: how can I find out from a PDF at which aspect ratio to
display an embedded fax-originated TIFF?

Cheers,
Pepijn

Pepijn Schmitz wrote:
> Hi everyone, 
>  
> I'm using PDFBox to receive faxes. Our fax service provider receives
> them and emails them to us as PDF attachments. I'm reading the emails,
> extracting the PDF attachments and then using PDFBox to extract the TIFF
> images from the PDF's. 
>  
> This works great (after I found out I had to install the JAI ImageIO
> Tools), but there is one problem: for some faxes the TIFF's are only
> half-height. The whole page is there, but is is squashed in the vertical
> direction. I imagine that these are faxes which were sent at some kind
> of "coarse" setting.
>  
> The thing is, if I open these PDF's in Adobe Reader they are displayed
> with the correct aspect ratio. So somewhere in the PDF there must be
> information telling Adobe Reader to scale the image up in the vertical
> direction, but I don't know how to get at this information.
>  
> Can someone here help me with this problem? Do you know how this
> information is stored in the PDF, and how I could get at it with PDFBox?
> Is it stored in the TIFF itself somehow? I could email interested
> parties one of the PDF's if it would help.
>  
> Kind regards, 
> Pepijn Schmitz
>
>