Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

converting PDF files saved in a Stream Array to Tiff files

$
0
0
Hi,
I have a stream array that is holding 4 PDF Files as memorystreams.  How do I read and convert the contents of the stream array and output 1 tiff file?

Here is my code that is not working currently.

Thank you
Tad

 Aspose.Pdf.Generator.Pdf pdf2 = new Aspose.Pdf.Generator.Pdf();
            for (int i = 0; i < count; i++)
            {
                ///read the source text file
                //System.IO.TextReader tr = new StreamReader(pdfStreams[i]);

                ////Create a new section in the Pdf object
                Aspose.Pdf.Generator.Section sec2 = pdf2.Sections.Add();

                ////Create a new text paragraph and pass the text to its constructor as argument
                //Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text(tr.ReadToEnd());
                //sec1.Paragraphs.Add(t2);

                //Create an image object in the section
                Aspose.Pdf.Generator.Image image2 = new Aspose.Pdf.Generator.Image(sec2);

                //create new Bite Array 
                byte[] biteArray = new byte[pdfStreams.Length];
                //Read the entire stream 
                pdfStreams[i].Read(biteArray, 0, biteArray.Length);

                MemoryStream ms = new MemoryStream(biteArray);

                image2.ImageInfo.ImageStream = ms;
                //string location = pdfStreams[i].ToString();

                //Set the type of image using ImageFileType enumeration
                image2.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;

                //Add image object into the Paragraphs collection of the section
                sec2.Paragraphs.Add(image2);
              }


            Resolution resolution1 = new Resolution(300);

            // Create TiffSettings object
            TiffSettings tiffSettings = new TiffSettings();
            tiffSettings.Compression = CompressionType.None;
            tiffSettings.Depth = ColorDepth.Default;
            tiffSettings.Shape = ShapeType.Landscape;
            tiffSettings.SkipBlankPages = false;

            // Create TIFF device
            TiffDevice tiffDevice = new TiffDevice(resolution1, tiffSettings);

            Aspose.Pdf.Document pdffile = new Aspose.Pdf.Document(pdf2);
            tiffDevice.Process(pdffile, destfilepath + "output.tiff");

Viewing all articles
Browse latest Browse all 3131

Trending Articles