Hi Imran, Scaling.ACTUAL_SIZE is probably not what you want, it prints using the PDF’s built-in size, which may be bigger or smaller than your current printer settings allow. Depending on the configuration of the local printer driver and printer, the document can be too large or too small. Note that it is not just paper size which causes this, some printer drivers can configure margins or their own headers and footers which can reduce the printable area of the page.
SHRINK_TO_FIT is usually what you want, as it will shrink the image if it is too big for the current printer, so any image which is too big for the page will be scaled down. Don’t forget that the system’s print dialog is in control of things like the paper size and the margins, and PDFBox can only work within those bounds. -- John > On 20 Nov 2014, at 08:00, Imran Akbar <[email protected]> wrote: > > Hi John, > > The new code had a huge impact on the alignment, previously the Footer was > not displaying after implementing it with pdfbox 2.0 the Header and footers > text are not getting displayed. > > I tried with the below code, still the results are same. > > PDFPrinter pdf = new PDFPrinter(this.document, Scaling.ACTUAL_SIZE, > Orientation.AUTO); > > One more thing i noticed, am loading the component as an applet i see the > behavior is different on each machine, in some machines i see all the > details gets printed but shrinked. and in some it stretches removing the > headers and footers. > > ~Imran > > On Thu, Nov 13, 2014 at 9:28 AM, John Hewson <[email protected]> wrote: > >> Yes, we could do with an example, there are multiple ways in which you can >> use PDFPrinter, it’s pretty flexible. For now here’s some code for simple >> usage: >> >> PDFPrinter printer = new PDFPrinter(document); >> PrinterJob job = PrinterJob.getPrinterJob(); >> printer.silentPrint(job); >> >> -- John >> >>> On 11 Nov 2014, at 21:49, Imran Akbar <[email protected]> wrote: >>> >>> John, >>> >>> it would be great if you could provide an example implementing it. >>> >>> Thanks, >>> Imran >>> >>> On Tue, Nov 11, 2014 at 9:15 PM, John Hewson <[email protected]> wrote: >>> >>>> Sorry, I should have mentioned, we moved this functionality to the >>>> PDFPrinter class in 2.0. >>>> >>>> -- John >>>> >>>>> On 11 Nov 2014, at 08:13, Imran Akbar <[email protected]> wrote: >>>>> >>>>> Tilman, >>>>> >>>>> I tried viewing the pdf from commandline the pdf displayed correctly. >>>>> >>>>> John, >>>>> >>>>> I downloaded 2.0 from the link [ >>>>> >>>> >> http://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/2.0.0-SNAPSHOT/ >>>> ] >>>>> but i couldnt find the silentprint method available :( >>>>> >>>>> >>>>> Thanks, >>>>> Imran >>>>> >>>>> >>>>> >>>>> On Sun, Nov 9, 2014 at 8:11 PM, John Hewson <[email protected]> wrote: >>>>> >>>>>> Printing in 1.8 has a number of bugs and limitations which have been >>>> fixed >>>>>> in the 2.0 trunk on SVN, so you might want to try that. >>>>>> >>>>>> -- John >>>>>> >>>>>>> On 9 Nov 2014, at 00:12, Imran Akbar <[email protected]> wrote: >>>>>>> >>>>>>> Hi all, >>>>>>> >>>>>>> I am trying to load a pdf from URL/FIle and do a silent print by >>>> choosing >>>>>>> the default printer. it prints but the printed output is having >> issues >>>> in >>>>>>> the alignment, if documents contains Footers, they are getting >> stripped >>>>>> off >>>>>>> and not getting printed. is there a way to set the printing >> properties >>>>>>> before we print the document when loading an existing document. >> Please >>>>>> find >>>>>>> my below code, >>>>>>> >>>>>>> ****** >>>>>>> >>>>>>> public class PrintPdf { >>>>>>> >>>>>>> public static PrintService choosePrinter() { >>>>>>> PrinterJob printJob = PrinterJob.getPrinterJob(); >>>>>>> if (printJob.printDialog()) { >>>>>>> return printJob.getPrintService(); >>>>>>> } else { >>>>>>> return null; >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> public static void printPDF(String fileName, PrintService printer) >>>>>>> throws IOException, PrinterException { >>>>>>> PrinterJob job = PrinterJob.getPrinterJob(); >>>>>>> job.setPrintService(printer); >>>>>>> >>>>>>> PDDocument doc = PDDocument.load(fileName); >>>>>>> >>>>>>> doc.silentPrint(job); >>>>>>> } >>>>>>> >>>>>>> public static void main(String[] args) throws IOException, >>>>>>> PrinterException { >>>>>>> >>>>>>> printPDF("http://localhost/IS1330900025_3705.pdf", >>>>>> choosePrinter()); >>>>>>> } >>>>>>> >>>>>>> } >>>>>>> >>>>>>> **** >>>>>>> >>>>>>> - Imran >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> -- Imran Akbar >>>> >>>> >>> >>> >>> -- >>> -- Imran Akbar >> >> > > > -- > -- Imran Akbar

