wood burning stoves 2.0*
The moose likes General Computing and the fly likes Tiff to Pdf conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "Tiff to Pdf conversion" Watch "Tiff to Pdf conversion" New topic
Author

Tiff to Pdf conversion

ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 60
Hi,

how to convert tiff file to PDF file, the converted PDF should be a content searchable, please help me on this





Thanks,
Ramesh
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

I found a bunch of web sites that offer to do it for free. Have you looked at any of those?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 60


Thanks fred rosenberger ,

This is My code

RandomAccessFileOrArray myTifFile = new RandomAccessFileOrArray("D:/image.tiff");
int numberOfPages = TiffImage.getNumberOfPages(myTifFile);
FileOutputStream os=new FileOutputStream("D/image.pdf");
com.itextpdf.text.Document TifftoPDF=new com.itextpdf.text.Document();
PdfWriter writer =PdfWriter.getInstance(TifftoPDF, os);


writer.setStrictImageSequence(true);
TifftoPDF.open();

for(int tiffImageCounter = 1;tiffImageCounter <= numberOfPages;tiffImageCounter++) {
com.itextpdf.text.Image img = TiffImage.getTiffImage(myTifFile, tiffImageCounter);
Rectangle pageSize = new Rectangle(img.getWidth(),
img.getHeight());
TifftoPDF.setPageSize(pageSize);
TifftoPDF.newPage();
TifftoPDF.add(img);

}
TifftoPDF.close();
}


here the image(tiff file) converted to pdf successfully, but i am not able to do content search in pdf(tiff to pdf converted file). Please help me how to get the content search in pdf



Thanks,
Ramesh
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Sorry, could you clarify your question a bit? What's this "content search" that you want to use?

To me "content search" sounds like you want to search for instances of a particular text string, which of course doesn't apply since your TIFF file was an image.
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 60
yes exactly
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 60
i want search a string in pdf file, but pdf(converted pdf) is not allowing.. please help
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

You may have to do some kind of OCR conversion on it...I really don't know. My guess is that the conversion to pdf doesn't have any clue that there is text in the original image. After all, the original image could be a butterfly. It just converts the .tiff image into a .pdf image (and I'm kind of making a lot of assumptions).

So, i would start by googling OCR and seeing how to do that. It's something I have certainly never done, so I can't help you any more than that.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
You can't search text in an image ; why do you think you can search text in a PDF that contains nothing but an image?


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37891
    
  22
Not a “beginning” question: moving discussion.
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 60
my question is i have text in my tiff file.. after converting tiff to pdf. i should able to search a string. how it is possible through java code?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Like fred said, to get text out of an image you have to use OCR (that's Optical Character Recognition). You may also have to accept that converting the image to PDF wasn't the right solution.
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 60
hi paul,

please give me code


Thanks,
Ramesh
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37891
    
  22
We don't work like that.
ramesh poorella
Ranch Hand

Joined: Jul 19, 2011
Posts: 60
please suggest how to do in my code
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
ramesh poorella wrote:after converting tiff to pdf. i should able to search a string.

My question still is: Why do you think that? Searching for text is an operation that simply doesn't apply to images as present in files. Converting them to PDFs doesn't change that one bit; in fact, it makes image processing operations -like OCR, assuming that's what you have in mind, I can't tell from your previous posts because you have given so little detail- harder.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
please suggest how to do in my code

You should delete that code, because OCR -assuming that's what you intend to do- has nothing to do with PDFs. If OCR is in fact what you intend to do, use the Search functionality to search for "Tesseract", and you'll find some recent discussions about how to do OCR on images in Java.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tiff to Pdf conversion
 
Similar Threads
How to convert PDF file to an image files using java.
PDF to Tiff Conversion
iText: pdf conversion into other formats
Convert PDF files to Tiff files
Java API to convert PDF to tiff