You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Александр Свиридов <oo...@mail.ru> on 2015/06/28 10:49:39 UTC
PdfBox - extra symbols when converting pdf page to image
I use apache pfdbox 1.8.9. I have one page pdf file which contains text and I want to convert this page to image. This pdf file I did via Libre Office. I use the following code:
PDDocument document =PDDocument.loadNonSeq(newFile(filename),null);
List<PDPage> pdPages = document.getDocumentCatalog().getAllPages();
int page =0;for(PDPage pdPage : pdPages){
++page;
BufferedImage bim = pdPage.convertToImage(BufferedImage.TYPE_INT_RGB,300);
ImageIOUtil.writeImage(bim,"png","/home/file"+"-"+ page,300);
}
document.close();
The code works, I get png image. The problem is that there are a lot of strange extra symbols which make it very difficult to read the text. How to fix it?
The image is here http://i.stack.imgur.com/OUyLO.png
--
Александр Свиридов
PdfBox 2.0 - printing using javafx printer job
Posted by Александр Свиридов <oo...@mail.ru>.
Is it possible to print pdf files using javafx.print.PrinterJob but not java.awt.print.PrinterJob?
Re: Re[2]: PDFBox 2.0 how to print certain page
Posted by John Hewson <jo...@jahewson.com>.
> On 28 Jun 2015, at 09:05, Alex Sviridov <oo...@mail.ru> wrote:
>
> Thank you for your help. I wrote new message to mailing list. I think that my mailing service is also a little buggy :)
>
> I can't understand why it became so complicated? Maybe there are simpler ways?
It certainly doesn't need to be so complicated, something like this should work:
HashPrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(new PageRanges(1));
printJob.print(new PDFPrinter(), attributes);
-- John
>
>
>
> Воскресенье, 28 июня 2015, 17:43 +02:00 от Tilman Hausherr <TH...@t-online.de>:
>>> Am 28.06.2015 um 16:02 schrieb Александр Свиридов:
>>> How can I print certain page using pdfbox 2.0?
>>
>>
>>
>> I don't do printing... I googled a bit and found this solution
>> http://www.java2s.com/Code/Java/2D-Graphics-GUI/Printingofamultipagebook.htm
>>
>> that extends Printable, and limits the page in the print() method.
>>
>> See also
>> http://www.javaworld.com/article/2076250/core-java/printing-in-java--part-2.html
>>
>>
>> Tilman
>>
>>
>>
>> (Sorry, now I accidentally sent this to you instead of to the mailing
>> list...aaargh!)
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> --
> Alex Sviridov
Re[2]: PDFBox 2.0 how to print certain page
Posted by Alex Sviridov <oo...@mail.ru>.
Thank you for your help. I wrote new message to mailing list. I think that my mailing service is also a little buggy :)
I can't understand why it became so complicated? Maybe there are simpler ways?
Воскресенье, 28 июня 2015, 17:43 +02:00 от Tilman Hausherr <TH...@t-online.de>:
>Am 28.06.2015 um 16:02 schrieb Александр Свиридов:
>> How can I print certain page using pdfbox 2.0?
>>
>>
>
>
>
>I don't do printing... I googled a bit and found this solution
>http://www.java2s.com/Code/Java/2D-Graphics-GUI/Printingofamultipagebook.htm
>
>that extends Printable, and limits the page in the print() method.
>
>See also
>http://www.javaworld.com/article/2076250/core-java/printing-in-java--part-2.html
>
>
>Tilman
>
>
>
>(Sorry, now I accidentally sent this to you instead of to the mailing
>list...aaargh!)
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>For additional commands, e-mail: users-help@pdfbox.apache.org
>
--
Alex Sviridov
Re: PDFBox 2.0 how to print certain page
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 28.06.2015 um 16:02 schrieb Александр Свиридов:
> How can I print certain page using pdfbox 2.0?
>
>
I don't do printing... I googled a bit and found this solution
http://www.java2s.com/Code/Java/2D-Graphics-GUI/Printingofamultipagebook.htm
that extends Printable, and limits the page in the print() method.
See also
http://www.javaworld.com/article/2076250/core-java/printing-in-java--part-2.html
Tilman
(Sorry, now I accidentally sent this to you instead of to the mailing
list...aaargh!)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
PDFBox 2.0 how to print certain page
Posted by Александр Свиридов <oo...@mail.ru>.
How can I print certain page using pdfbox 2.0?
Re: PdfBox - extra symbols when converting pdf page to image
Posted by Tilman Hausherr <TH...@t-online.de>.
Already answered in
https://stackoverflow.com/questions/31097691/extra-symbols-when-converting-pdf-to-image-with-pdfbox
feel free to ask additional questions about the 2.0 version. See also
https://pdfbox.apache.org/downloads.html#scm
and
https://pdfbox.apache.org/2.0/getting-started.html
Tilman
Am 28.06.2015 um 10:49 schrieb Александр Свиридов:
> I use apache pfdbox 1.8.9. I have one page pdf file which contains text and I want to convert this page to image. This pdf file I did via Libre Office. I use the following code:
> PDDocument document =PDDocument.loadNonSeq(newFile(filename),null);
> List<PDPage> pdPages = document.getDocumentCatalog().getAllPages();
> int page =0;for(PDPage pdPage : pdPages){
> ++page;
> BufferedImage bim = pdPage.convertToImage(BufferedImage.TYPE_INT_RGB,300);
> ImageIOUtil.writeImage(bim,"png","/home/file"+"-"+ page,300);
> }
> document.close();
> The code works, I get png image. The problem is that there are a lot of strange extra symbols which make it very difficult to read the text. How to fix it?
> The image is here http://i.stack.imgur.com/OUyLO.png
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org