pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hewson <j...@jahewson.com>
Subject Re: How to print PDF without magnifiying them ?
Date Tue, 03 May 2016 19:04:59 GMT

> On 2 May 2016, at 06:59, Tilman Hausherr <THausherr@t-online.de> wrote:
> 
> Please extend the PDFPageable class, and override getPrintable(). The current code is:
> 
>    @Override
>    public Printable getPrintable(int i)
>    {
>        if (i >= getNumberOfPages())
>        {
>            throw new IndexOutOfBoundsException(i + " >= " + getNumberOfPages());
>        }
>        return new PDFPrintable(document, Scaling.ACTUAL_SIZE, showPageBorder, dpi);
>    }
> 
> Have a look at the parameters for PDFPrintable() and use the ones that are best for you.
I suspect you want Scaling.SCALE_TO_FIT.

No, don’t do that! The concept of a Pageable in the Java printing API is something which
appears at its natural dimensions on the page, i.e. the document controls the page, not the
user.

If the user wants to control the page, use a Printable directly, don’t use a Pageable at
all.

— John

> Tilman
> 
> 
> Am 02.05.2016 um 15:32 schrieb Pierre Antoine Guillaume:
>> I'm using pdfbox 2.0.1 and awt.print / javax.print
>> 
>> http://pastebin.com/PNwT5RK4
>> 
>> 2016-05-02 15:25 GMT+02:00 Tilman Hausherr <THausherr@t-online.de>:
>> 
>>> Please mention what version you are using, and post the code you have been
>>> using to print.
>>> 
>>> Tilman
>>> 
>>> 
>>> Am 02.05.2016 um 15:14 schrieb Pierre Antoine Guillaume:
>>> 
>>>> Hello, i'm new to using pdfbox and when I try to print (with a real
>>>> printer), the pdf is kind of magnified (every margin of the page is
>>>> smaller).
>>>> 
>>>> When I print into a virtual printer (pdfcreator) the newly generated pdf
>>>> seems to be the same. (I get the right page)
>>>> 
>>>> And when I print the PDF directly, I get the right page.
>>>> 
>>>> Have you any idea on how to correct this issue ?
>>>> 
>>>> I've tried to set the format to A4 through
>>>> 
>>>>              PrintRequestAttributeSet attr_set = new
>>>> HashPrintRequestAttributeSet();
>>>> 
>>>>              attr_set.add(MediaSizeName.ISO_A4);
>>>>              attr_set.add(Sides.ONE_SIDED);
>>>> 
>>>> But it won't change anything.
>>>> 
>>>> Thank you for reading.
>>>> 
>>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message