You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Albie Janse van Rensburg <al...@gmail.com> on 2009/10/15 19:57:17 UTC

PDF Printing doesn't work at all

Hi

I am trying to write a PDF printer applet.  The applet is fed a URL of
the PDF, which it must query for the document, and then I want it to
print to a selected printer (drop-down list of
PrintServiceLookup.lookupPrintServices).  My applet's jar (and the
pdfbox jar) are signed, which got me around some initial permission issues.

I have used the PDDocument object's load(url) method to get the file. 
When I call PDDocument.print(), I get a popup dialog to select a
printer, but when I click the Print button, a whole lot of nothing
happens!  That's right - nothing.  No printer job queued, no error, the
dialog disappears, and that is all she wrote.

My code:

====code====
    private PDDocument pdfDocument;
    private String url = "http://localhost/test.pdf";
... (snip) ...

                    if (pdfLoaded == false) {
                        pdfDocument = new PDDocument ();
                        pdfDocument.load(new URL (url));
                        pdfLoaded = true;
                    }
                    pdfDocument.print();
====code====

Is there something obvious I'm missing here?

Thank you for reading
Albie

-- 

[ Albie Janse van Rensburg ~ http://morph.telspace.co.za ]

All is fear in love and war.


Re: PDF Printing doesn't work at all

Posted by Albie Janse van Rensburg <al...@gmail.com>.
Andreas Lehmkühler wrote on 15/10/2009 10:00 PM:
> Hi,
>
> Albie Janse van Rensburg schrieb:
>   
>> My code:
>>
>> ====code====
>>     private PDDocument pdfDocument;
>>     private String url = "http://localhost/test.pdf";
>> ... (snip) ...
>>
>>                     if (pdfLoaded == false) {
>>                         pdfDocument = new PDDocument ();
>>                         pdfDocument.load(new URL (url));
>>                         pdfLoaded = true;
>>                     }
>>                     pdfDocument.print();
>> ====code====
>>
>> Is there something obvious I'm missing here?
>>     
> The load-method is static and delivers the document you have to use for
> further usage. Try sometjing like this:
>
> PDDocument pdfDocument = PDDocument.load(new URL (url));
> pdfDocument.print();

Great, thanks!  I had to add the fontbox jar to get around an error, and
now I have made a printout. 

Problem: instead of letters, I only see little blocks!  I would guess
there's an encoding of some sort needed.

I've attached a PDF copy of the printout. 

Is there a guide for me to refer to?  The documentation seems sparse - I
am basically reading source + comments for help at the moment.

Thanks for the help.

-- 

[ Albie Janse van Rensburg ~ http://morph.telspace.co.za ]

Look before you leap.
		-- Samuel Butler


Re: PDF Printing doesn't work at all

Posted by Andreas Lehmkühler <an...@lehmi.de>.
Hi,

Albie Janse van Rensburg schrieb:
> Hi
> 
> I am trying to write a PDF printer applet.  The applet is fed a URL of
> the PDF, which it must query for the document, and then I want it to
> print to a selected printer (drop-down list of
> PrintServiceLookup.lookupPrintServices).  My applet's jar (and the
> pdfbox jar) are signed, which got me around some initial permission issues.
> 
> I have used the PDDocument object's load(url) method to get the file. 
> When I call PDDocument.print(), I get a popup dialog to select a
> printer, but when I click the Print button, a whole lot of nothing
> happens!  That's right - nothing.  No printer job queued, no error, the
> dialog disappears, and that is all she wrote.
> 
> My code:
> 
> ====code====
>     private PDDocument pdfDocument;
>     private String url = "http://localhost/test.pdf";
> ... (snip) ...
> 
>                     if (pdfLoaded == false) {
>                         pdfDocument = new PDDocument ();
>                         pdfDocument.load(new URL (url));
>                         pdfLoaded = true;
>                     }
>                     pdfDocument.print();
> ====code====
> 
> Is there something obvious I'm missing here?
The load-method is static and delivers the document you have to use for
further usage. Try sometjing like this:

PDDocument pdfDocument = PDDocument.load(new URL (url));
pdfDocument.print();


BR
Andreas Lehmkühler