Sitemap

Amicuk Programming Answers

Pdf file handling

-0001-11-30   Views:0

Advertisement

Hi, I am trying to read pdf file in String, process the string and then put the string back in a new pdf file. The code I am using is as follows: Reading pdf file: String readFile() throws Exception      InputStream istr = getClass().getResourceAsStr

Hi,
I am trying to read pdf file in String, process the string and then put the string back in a new pdf file. The code I am using is as follows:
Reading pdf file:
String readFile() throws Exception
     InputStream istr = getClass().getResourceAsStream("26-1880.pdf");
     StringBuffer buff = new StringBuffer();
int someByte=0;
     for(int i=0 ; ; i++)
          try
               someByte = istr.read();
          catch(IOException ioe)
               ioe.printStackTrace();
          if(someByte == -1)
          break;
          buff.append((char)someByte);
return (buff.toString());
Writing string to pdf:
void writeFile(String file) throws Exception
     OutputStream ostr = new FileOutputStream(new File("VALoan.pdf"));
     byte[] someByte=file.getBytes();
     ostr.write(someByte);
     ostr.flush();
     ostr.close();
But the new file that I generate does not become valid pdf file.
Also right now, I am not even processing the string that I get from a pdf file. I just get and put it back.
Can anyone find out what could be the problem?
Thanks,
-Stan

The replay answer
Advertisement
Hi Vanilla,
I want to process the string that I get from the pdf.What do you mean "process"? What are you planning to do with it?
And it is NOT a String. If you want a String representation (e.g., just the text, with no layout, font, etc. info), then you'd need to interpret the BYTES first and then build a String from the results.
I can not process the bytes. So I think, I have to
convert the bytes into string.Then you need to either learn the PDF spec and write code to interpret those bytes, or you need to find a 3rd party library that does this. You can't just expect to read the bytes into a Java String and have it work.

Go to See the other 7 answers

PDF file handling through BPEL

Category:DefaultRelease time:2015-10-11Views:130

Hi, We are exploring BPEL as an option to handle PDF files generated by Oracle EBS (BI Publisher). Basically we want to achieve following: Pick up PDF files from certain location on UNIX box and then a. Spliting the PDF file into two or more files (d[More]

Pdf file handling

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I am trying to read pdf file in String, process the string and then put the string back in a new pdf file. The code I am using is as follows: Reading pdf file: String readFile() throws Exception      InputStream istr = getClass().getResourceAsStr[More]

Raise without Handler error when printing pdf files in Outlook

Category:DefaultRelease time:2015-10-11Views:130

At work sometimes I'm asked to print emails with tons of attachments, but when I attempt to print the email with the attachments through outlook, anytime there is a PDF attached, I get the "Raise without Handler!" error and also the following wi[More]

Handle the "No matches were found." when doing a search in Adobe Acrobat PDF file.

Category:DefaultRelease time:2015-10-11Views:130

I have written an Excel spread sheet and using visual basic coding in my macro can open an as needed PDF file, search for a paragraph number as copied from the spread sheet, capture the page in the PDF file it is found on and paste the "pagefound&quo[More]

Acrobat 4.0 possible patch to handle newer .pdf files?

Category:DefaultRelease time:2015-10-11Views:130

I am currently at a small printing company that uses a Heidelberg Prosetter and interconnected software programs for platemaking in our pre-press department. We currently have an outdated Heidelberg meta dimension system that I was told will only han[More]

Unable to make Acrobat X the default handler/opener of PDF files on a Windows 8 laptop with Acrobat Reader also installed.

Category:DefaultRelease time:2015-10-11Views:130

I have a user with a Windows 8 Sony Vaio laptop with Microsoft Office 2013 Professional, Acrobat X Standard, and Acrobat Reader installed. Another program on his system requires Acrobat Reader so we cannot just remove that and keep it off the system.[More]

XMP Standard - Is there a tool for non-professionals to handle PDF files for free?

Category:DefaultRelease time:2015-10-11Views:130

I'd like to start organising my various files and I wonder if I could include PDF files into the process (it seems easier with graphics), possibly also some video or audio files in the future. I hope there's a tool, not onle for IT specialists to han[More]

PDF Preview Handler will not open 1 file

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have Office 2013 and Acrobat XI, the PDF Handler works fine on all my files except one. Through our online ordering, I get a confirmation email with E-Order.pdf with every confirmation, worked for a while and now gives me the "This file cannot[More]

How to open PDF file generated by some ashx handler using POST parameters in Internet Explorer for W

Category:DefaultRelease time:-0001-11-30Views:130

I need to print content of pdf file by JavaScript. To do this used HTML like this: <OBJECT id = "Pdf" data = 'http://someurl.com/getpdf.ashx' name="Pdf2" WIDTH="300" HEIGHT="300"></OBJECT> <a onclick=[More]

How to open report.pdf file? getting error message file cannot be previewed pdf preview handler

Category:DefaultRelease time:2015-10-11Views:130

how can I open a report.pdf file that shows error: file cannot be previewed because of an error w/ pdf preview handlerHi pfmercerville, If you are running the 64-bit version of Windows 7 (or Vista), you will find that your PDF files do not preview in[More]

File handles don't close when the pdf is closed?

Category:DefaultRelease time:2015-10-11Views:130

Using Acrobat X on Windows 7 Pro in a networked environment. Once I open a PDF file in Acrobat, as long as I have acrobat running, (even after I have closed the file and moved on) I cannot change/move/rename the file. Since I spend a lot of time revi[More]

Hot
Hi User is cancelling a SD Credit memo using VF11.  However, the accounting document will not be cancelled automatically when doing VF11.  Is there any option to cancel the accounting document simulateneously and automatically at the time of VF11 its [More]
Hi Gurus, I have a very genuine scenario but not getting any SAP standard solution. Scenario is, my plant A (power plant) is producing material POWER as FERT  and my another plant B  consuming ELECTRICITY as pipe line material. So having two plants ( [More]
Hi Maybe this is a newbie's problem but can anybody help me? I do some xml-transformation in my javaclass. in my case i also need the apache FOP besides some other packages like jaxp etc. now: if i load the library from my harddisk, everything works [More]
how do i make an object array to have a size ,that of the result set,after the query is executed?And consider the remarks made by sjasja and others in this zombie newly arisen from its slumber http://forum.java.sun.com/thread.jspa?threadID=680177Read [More]
In addition to sell your book on iTunes is a huge exercise, requiring US taxation file numbers that you have to apply directly to the tax office in the US. Once you have done that you then have to jump through several other hoops in iTunes system to [More]
Anyone using an X-Rite ColorChecker Passport for adjusting color, or creating profiles? I'd like to do this for important shots, or shooting sessions with consistent light. It is very useful to shoot a test shot of the ColorChecker Passport and use i [More]
Hi All, I am using hyperion 11.1.1.1.0.0 . When I am starting Hyperion Financial Reporting Web Application server service from the services list it is showing started and after some time it is getting stopped by its own. And even I am not getting the [More]
I've got a five-year old Indesign file (book) that I've been working on for months in the latest Creative Cloud version. This morning Indesign suddenly crashed and now when I try to open my file Indesign says it's "damaged" and when I try to rep [More]
Why do i get a tear thru my video when playing on my lcd? I have tryed 60mhz monitors & 120's but I still get a single thin  tear moving through the image. It happens mainly with HD footage when there is a lot of camera movement. I have an invidia gt [More]
i was in the middle of doing the software upgrade when my internet cut out. the pone and itunes froze at the stage they were at. i have tried rebooting the iphone but it keeps telling me to conect to itunes and itunes is sayin i need to restore to fa [More]