How to compress and decompress a pdf file in java
I have a PDF file ,
what i want to do is I need a lossless compression technique to compress and decompress that file,
Please help me to do so,
I am always worried about this topic
Here is a simple program that does the compression bit.
static void compressFile(String compressedFilePath, String filePathTobeCompressed)
try
ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(compressedFilePath));
File file = new File(filePathTobeCompressed);
int iSize = (int) file.length();
byte[] readBuffer = new byte[iSize];
int bytesIn = 0;
FileInputStream fileInputStream = new FileInputStream(file);
ZipEntry zipEntry = new ZipEntry(file.getPath());
zipOutputStream.putNextEntry(zipEntry);
while((bytesIn = (fileInputStream.read(readBuffer))) != -1)
zipOutputStream.write(readBuffer, 0, bytesIn);
fileInputStream.close();
zipOutputStream.close();
catch (FileNotFoundException e)
catch (IOException e)
// TODO Auto-generated catch block
e.printStackTrace();
}
Similar Messages
-
Compressing and decompressing a PDF file
Dear Gurus,
Anyone who can assist with the code to compress and decompress PDF file so that I can send it in an email.
Thanks1) you should go to ABAP Printing forum where this problem has been discussed many times (for example remove the coloring to reduce the file size etc.). Just in case you would insist on working your way.
2) You can create some printing "device" like smartform etc. to print your data for you and then convert it to PDF, the result should be smaller then option 1)
3) the best one: if you want to send a PDF somewhere (or archive it etc.) you should start with Adobe forms, for you purpose Adobe print forms will be suffiscient. You only need to install and configure the ADS component to generate forms from the template for you. If you want to see a brief ovewrview about how to create this thing, start reading somewhere like here (this is not the most simple example!!):
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
Regards Otto -
How to compress a batch of pdf files in different sizes to a specific target (20 mb)
Hi,
How do I compress a batch of pdf files in different sizes (21-39 mb) to a specific target (20 mb)?
Thanks:)By endless trial and error.
-
Viewing and printing a PDF file from Java Swing Application
Hello,
I need to view and print PDF files from Java Swing Application.How do I do that?I appreciate your help.
Thank you
Sumana SomareddyIf you have a link to the URL pointing to the PDF file, you can allow the browser to open it. Then use the print function of the browser to print the PDF document.
Regards,
Tak. -
How to create and edit a .ini file using java
Hi All...
Pls help me in creating and editing an .ini file using java...
thanks in advance
Regards,
sathyaLet's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class Test {
private static Properties props;
public static void main(String[] args) throws IOException {
File file = new File("test.ini");//This is out ini file
props = new Properties();//Create the properties object
read(file);//Read the ini file
//Once we've populated the Properties object. set/add a property using the setProperty() method.
props.setProperty("testing", "value");
write(file);//Write to ini file
public static void read(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
props.load(fis);//load the ini to the Properties file
fis.close();//close
public static void write(File file) throws IOException {
FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
props.store(fos, "");//write the Properties object values to our ini file
fos.close();//close
} -
How to compare and edit Resource bundle file using java programe
Hi All
I have two resource bundle with key, value and some comments. I need to write a java code to compare both of the values of the keys and if the values are different then i want to replace the second value with the first value.
Its a programe which will udpate the second file with the first file values.
I tried using Properties class but it didnt worked because when i am saving the file using store method it removes all the comments and the order of text also got disturbed.
How I need to do this any help appriciated.
Please elt me know if someone needs more info.
Thanks in advance.Let's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class Test {
private static Properties props;
public static void main(String[] args) throws IOException {
File file = new File("test.ini");//This is out ini file
props = new Properties();//Create the properties object
read(file);//Read the ini file
//Once we've populated the Properties object. set/add a property using the setProperty() method.
props.setProperty("testing", "value");
write(file);//Write to ini file
public static void read(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
props.load(fis);//load the ini to the Properties file
fis.close();//close
public static void write(File file) throws IOException {
FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
props.store(fos, "");//write the Properties object values to our ini file
fos.close();//close
} -
How to create and attach a pdf file to an email
I am looking into the feasibility of using email system to send indentical notices along with data attachments to hundreds of companies simultaneously. Each data attachment is corresponding to its own company email.
Please advise how can I create this file. What tool(s) do I need?
Thanks in advance for your assistance.
MLuser627993,
First thing is that this forum is for OTN community feedback and suggestions as the forum header says. Second, you have not provided any background of scenario like platform, tools, business case etc, so its impossible to suggest where to post.
You can go to forum home page
http://forums.oracle.com/forums/categoryHome.jspa?categoryID=84 and check which one is suitable for your case.
--Shiv -
How can I transfer a big .pdf file e.g. 9 MB from my Macintosh Performa 5200 and its OS 8.1 to an USB flash drive? E.g. is there any adapter available in order to connect the SCSI with USB? Or is it better to use a compression software and transfer it to 10 3,5" floppy discs?
Thank you
EmanuelHello Emanuel,
The Performa 5200CD did not have built-in Ethernet as standard, so unless an Ethernet card (or an external SCSI or LocalTalk-to-Ethernet adapter) has been added, that method would not be available in this case.
Your suggestion involving compression software (such as an appropriate version of StuffIt) with segmenting capabilities could of course be one alternative.
If you have an internal or external modem for the Performa, another way could be to use the telephone lines for transfers. A communications program would have to be used on both sides (for example, ZTerm or the communications section of ClarisWorks on the Performa).
It is even possible to connect two serial modems directly. A simple line simulator (in principle, a 9 V battery in series with a 680 ohm resistor in one of the leads in an RJ-11 to RJ-11 cable), which can be built in a couple of minutes, is sometimes needed. Do NOT use a line simulator for units connected to the public telephone network.
Yet another solution could be a null-modem transfer to a PC with a (DB-9M) serial port. This would require a null-modem cable (can be designed by combining a Macintosh modem cable (MiniDIN-8M to DB-25M) with a normal PC-style (DB-25F to DB-9F) null-modem cable . HyperTerminal or another communications program can be used on the PC.
What do you have to work with (other computers/models/platforms)? Is this a one-time transfer, or do you plan to send additional files later? Is the intention to continue to use the Performa 5200?
Jan -
How to read the and Write the PDF file give me the solution
Hi all,
How to read the and Write the PDF file give me the solution
My coding is
import java.io.File;
import com.asprise.util.pdf.PDFImageWriter;
import com.asprise.util.pdf.PDFReader;
import java.io.*;
import java.io.FileOutputStream;
public class example {
// public example() {
public static void main(String a[])
try
PDFReader reader = new PDFReader(new File("C:\\AsprisePDF-DevGuide.pdf"));
reader.open(); // open the file.
int pages = reader.getNumberOfPages();
for(int i=0; i < pages; i++) {
String text = reader.extractTextFromPage(i);
System.out.println("Page " + i + ": " + text);
// perform other operations on pages.
PDFImageWriter writer = new PDFImageWriter(new FileOutputStream("c:\\new11.pdf"));
writer.open();
writer.addImage("C:\\sam.doc");
writer.close();
System.out.println("DONE.");
reader.close();
catch(Exception e){System.out.println("error:"+e);
e.printStackTrace();
I get the pdf content then it returns the string value but ther is no option to write the string to PDF, and we only add a image file to PDF,but i want to know how to wrote the string value to PDF file,
Please give response immtly
i am waiting for your reply.
thanks,
Suresh.GI have some question flow
How library to use this code.
I try runing but have not libary.
Please send me it'library
Thank you very much! -
How do I download and print a pdf file in osx mountain lion
How do I download and print a pdf file?
control click on your PDF to download option
Open it on your desktop Command-P is the short cut for print option. -
How to create a table with datatype blob and insert a pdf file (ravi)
how to create a table with datatype blob and insert a pdf file,
give me the explain asap
1.create the table?
2.insert the pdffiles into tables?
3.how to view the files?
Thanks & Regards
ravikumar.k
Edited by: 895044 on Dec 5, 2011 2:55 AM895044 wrote:
how to create a table with datatype blob and insert a pdf file,
give me the explain asapPerhaps you should read...
{message:id=9360002}
especially point 2.
We're not just sitting here waiting to answer your question as quickly as possible for you. -
How can I hide page thumbnails navigation bar at the start up of Adobe Reader and open a pdf file? I could not find this option under Preferences tab? Thanks
Hey there,
Thanks for your reply. That works for the files I do what you said. However, for files I have not done that, It still shows the navigation bar. Any idea, how to do it default for any files?
Thanks agian -
How to allow user to select pdf file on local machine and populate field with file name only
Folks,
I have a project requirement that I am stumped on. I am admittedly a novice, so forgive questions that may seem obvious.
My requirement is a form running on a client system where the user can click a button and select a PDF file name from a PDF on their local machine and then populate a form field with that file path & filename. The file names vary between all machines, so there is no static list. Note that the PDF is not embedded, nothing is executed, I simply need the file name.
There are several of these on a form (20+), so manual name entry is too error prone. I would like to use a 'browse' type dialog, but can not figure out how to implement it.
I've looked at app.browseForFile, but the users can not install a javascript file in their adobe folder or any other files; the functionality has to be integral with the original PDF.
Functionally, this is no different from the image object file browse, except that I need a PDF instead of an image file, so there doesn't seem like there should be a security issue that is any different from those surrounding the image object.
I've been stumped on this for the entire week, and I have a deadline rapidly approaching, so any examples or suggestions (please remember I'm a novice) would be greatly appreciated!Thanks for the reply Paul - do you have any sample code of how to attach the PDF? Or how the user can select a PDF to open? I might be able to attach it, retrieve the file name, and then un-attach it.
Alternatively, do you know how to retrieve the file name from the imagePath object? It will let you select PDF files, but I can't find info on how to retrieve the file name. It should be the way you would retrieve the file name for an image.
As a novice in this, thanks for your help and patience! -
I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.
Hi Frank ,
Please refer to the following link and see if this helps.
https://helpx.adobe.com/acrobat/kb/error-organizer-database-damaged-reset-1.html
Regards
Sukrit Dhingra -
How can I copy and paste a pdf file from my picture file and paste onto a document?
How can i copy and paste a pdf file onto a document. I am trying to place and article onto my
Reverbnation Press page. They only give you the option to either place a url link or paste a document. There
is no uploading for the Press page. thanks, elenaThe Digital Editions forum is here, in case this is what you are talking about:
http://forums.adobe.com/community/adobe_digital_editions
If you are not, I apologize for the misunderstanding.
Maybe you are looking for
-
SharePoint Foundation 2010 : Changing language settings
My employer would like to offer our clients the ability to specify a preferred language in-which to use our SharePoint solution. I.e. Clicking on a national flag on the dashboard will consequently display the system text within the associated languag
-
VoiceOver with iTunes 64 bit on Windows 7 64 bit problem
Is anyone using VoiceOver with iTunes 64 bit on Windows 7 64 bit? We cannot get it to work. I have followed Apple's guideance and uninstalled/reinstalled iTunes and the .dll has been moved from the root directory of C: to the iTunes program directory
-
How to change display name of the attachment item attribute.
Hello Experts I have a requirement to send a notification with attachment but attachment name should be attachment name, Is there any way to change the display name of the Attachment Please advise; Thanks Rajesh.
-
Oracle 8i Enterprise Edition Release2(8.1.6) On Windows Millennium
Hi! Can Oracle 8i Enterprise Edition Release2(8.1.6) for Windows/NT/2000 be installed on Windows Millennium. If anyone has been able to successfully install it please help me. Thanks null
-
Regarding "Error An SLD system has not been assigned to logical system "
Hi all, I am trying to connect SRM system to an XI system. All the settings are done (or I thought so). When I try to send a PO via XML/XI to the XI system in SRM Web UI, it gives me the following error: nformation Processing BBP_PO_SEND_XML Is Star