I use Aspose Java Total family.
I know that there is an image load from an inputStream.
I known that there is a word document save into an outputStream
and a pdf process into an outputStream.
Is it possible
Once you have images from both documents, insert the images into Aspose.Words.Document (word document) and save the final document to TIFF using Aspose.Words. Please read the following article. Inserting an Image
I’m not going to extract images from documents and insert them into another,.
I’m going to convert a document into an image and than convert a pdf into another image
and than to merge 2 images into one.
I know how to do it somehow…
The question is as follows.
How to make those operations using inputstreams and outputstreams without files.
That is the question…
The following basic code example shows how to save the Word document into the stream (PDF), merge the PDF files with another or new PDF (using stream), and create a TIFF file (stream) from the final PDF:
com.aspose.words.Document doc = new com.aspose.words.Document(dataDir + "Sample_21.1.docx");
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
doc.save(dstStream, com.aspose.words.SaveFormat.PDF);
byte[] dataBytes = dstStream.toByteArray();
ByteArrayInputStream byteStream = new ByteArrayInputStream(dataBytes);
com.aspose.pdf.Document pdf1 = new com.aspose.pdf.Document(byteStream);
// You can initialize another existing PDF below using input stream as well
com.aspose.pdf.Document pdf2 = new com.aspose.pdf.Document();
pdf2.getPages().add();
pdf1.getPages().add(pdf2.getPages());
ByteArrayOutputStream pdfoutStream = new ByteArrayOutputStream();
pdf1.save(pdfoutStream);
byte[] pdfBytes = pdfoutStream.toByteArray();
ByteArrayInputStream pdfinStream = new ByteArrayInputStream(pdfBytes);
//Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(pdfinStream);
ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(300);
com.aspose.pdf.devices.TiffSettings tiffSettings = new com.aspose.pdf.devices.TiffSettings();
tiffSettings.setCompression(com.aspose.pdf.devices.CompressionType.CCITT4);
tiffSettings.setDepth(com.aspose.pdf.devices.ColorDepth.Format4bpp);
tiffSettings.setSkipBlankPages(true);
tiffSettings.setIndexedConversionType(com.aspose.pdf.devices.TiffSettings.IndexedConversionType.Pixelated);
com.aspose.pdf.devices.TiffDevice tiffDevice = new com.aspose.pdf.devices.TiffDevice(2480, 3508,resolution,tiffSettings);
tiffDevice.process(pdfDocument,1,1,imageStream);
Thank a lot for code.
So my origional question was as follows.
Is it possible somehow connect outputstreams into inputstreams without terminated operations like
byte[] pdfBytes = pdfoutStream.toByteArray();
or
byte[] dataBytes = dstStream.toByteArray();
We are about to find an answer…
Just one step more.
Thank you in advance.
Thank you.
There is another way to connect input and output streams.
Using PipedOutputStream and PipedInputStream without byte arrays and files.
I tried this way in my task.
But it did not work.
That is whey I asked the question.
It seems that I did it not in a proper way.
So correct question is as follows
Is it possible to solve my task with PipedOutputStream and PipedInputStream?
Thank you in advance
Please share a narrowed-down code snippet so that we may know how you are trying to use PipedInputStream and PipedOutputStream with Aspose APIs. We will test the scenario in our environment and share our feedback with you accordingly.
It seems like you are using Aspose.Words in your code snippet to generate TIFF image. We are testing the scenario from this perspective and will get back to you in a while.
We used the below code snippet according to your original work flow as described in your first post:
com.aspose.words.Document doc = new com.aspose.words.Document(dataDir + "Sample_21.1.docx");
PipedInputStream is = new PipedInputStream();
PipedOutputStream os = new PipedOutputStream(is);
doc.save(os, com.aspose.words.SaveFormat.PDF);
com.aspose.pdf.Document pdf1 = new com.aspose.pdf.Document(is);
// You can initialize another existing PDF below using input stream as well
com.aspose.pdf.Document pdf2 = new com.aspose.pdf.Document();
pdf2.getPages().add();
pdf1.getPages().add(pdf2.getPages());
pdf1.save(os);
//Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(is);
com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(300);
com.aspose.pdf.devices.TiffSettings tiffSettings = new com.aspose.pdf.devices.TiffSettings();
tiffSettings.setCompression(com.aspose.pdf.devices.CompressionType.CCITT4);
tiffSettings.setDepth(com.aspose.pdf.devices.ColorDepth.Format4bpp);
tiffSettings.setSkipBlankPages(true);
tiffSettings.setIndexedConversionType(com.aspose.pdf.devices.TiffSettings.IndexedConversionType.Pixelated);
com.aspose.pdf.devices.TiffDevice tiffDevice = new com.aspose.pdf.devices.TiffDevice(2480, 3508,resolution,tiffSettings);
tiffDevice.process(pdfDocument,1,1,os);
We noticed that the code kept running for more than 10 minutes and did not generate any output. We need to further investigate the scenario and for the purpose, an investigation ticket as PDFJAVA-40205 has been logged in our issue tracking system. We will further look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.