Convert Tiff image Byte Arrayto PDF file Byte Array

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  Convert Tiff image Byte Arrayto PDF file Byte Array

DynamicPDF CoreSuite for .NET (v5) Forum

I am using Dynamic PDF dll "Cete.DynamicPDF.11.dll version 5.1.2.11". I am still using the .Net1.1.
 
My requiremnt is I have multi page Tiff Image in Byte Array[] and I want to convert into multi page PDF file in Byte Array[]. Can you please provide the code snippet for this requirement ???
 
I tested through the Dynamic PDF tool by using the option "Tiff to PDF example" and I am getting the PDF by selecting the Tiff file.
 
Note: It is quiet urgent. I struggled a lot, I found that there is a way to convert Tiff image file to PDF file. But I need for taking the argument as Byte Array[].
 
Your help on this regard will be highly appreciated. Please let me know if you need any further clarification or Information

Thanks & Regards,
VJ
Posted by a ceTe Software moderator
Hello VJ,

Yes, you can achieve your requirements without any problem using our DynamicPDF Generator for .NET product API. You will need to use the overloaded TiffFile class constructor which takes byte array as argument. Then you can make PDF out of Tiff using GetDocument method of TiffFile class. You can either save the generated PDF to disk or draw it in the form of byte array. Below is the sample code for it.

            Document document = new Document();
            Byte[] byteData = File.ReadAllBytes(@"C:\Good.tif");
            TiffFile tiffFileObj = new TiffFile(byteData);
            document = tiffFileObj.GetDocument();
            //Drawing PDF in the form of Byte Array.
            Byte[] PdfByteData = document.Draw();
            //Saving PDF to disk.
            document.Draw(@"C:\MyDocument.pdf");

Thanks,
ceTe Software Support Team.
hi

can i convert pdf byte array to tiff byte array using asp.net ?
Posted by a ceTe Software moderator
Hello,

It is not possible to get Tiff image out of PDF using DynamicPDF Generator API but you can achieve your requirements using DynamicPDF Rasterizer for .NET product which allows you to convert PDF to supported image formats. You can refer to the supported output image formats here.

You can load the PDF byte array  using overloaded InputPdf class constructor and use this object to create PdfRasterizer class object . Then output the tiff image in the form of byte array using overloaded DrawToMultiPageTiff method of PdfRasterizer class. Below is the code sample for it.

            byte[] byteData = File.ReadAllBytes(@"C:\Temp\Test.pdf");
            //Loading PDF byte array using InputPdf class.
            InputPdf pdf = new InputPdf(byteData);
            PdfRasterizer rastObj = new PdfRasterizer(pdf);
            //Outputting tiff image in the form of byte array.
            byte[] tiffImageData = rastObj.DrawToMultiPageTiff(TiffImageFormat.TiffWithLzw, ImageSize.Dpi72);

You can download evaluation edition of DynamicPDF Rasterizer for .NET product from our website here. Also refer to the code samples included with the evaluation download.

Thanks,
ceTe Software Support Team.
Hey there.

need some help. can i achieve the other way around? I want to get a pdf byte array from an image byte array (jpg).
Also is it possible to get a pdf byte array from a word doc array byte?

thnx in advance
Suli

Posted by a ceTe Software moderator
Hello Suli,

Yes, you can output the PDF in the form of a byte array by adding the image which is in the form of a byte array using DynamicPDF Generator for .NET product. You will need to use the ImageData class to load the image byte array and then add it to the PDF using Image page element. Please refer to the documentation on Image page element here. Then draw the PDF using draw method. You can refer to the documentation on document output here. Also below is the code sample for it.

            Document document = new Document();
            Page page = new Page();
            byte[] imagebyteData = File.ReadAllBytes(@"C:\temp\Images\Winter.jpg");
            ImageData imageDataObj = ImageData.GetImage(imagebyteData);
            Image image = new Image(imageDataObj, 0, 0, 1);
            page.Elements.Add(image);
            document.Pages.Add(page);
            //drawing the PDF into byte array.
            byte[] pdfbyteData= document.Draw();

It is not possible to convert the Word document to PDF using DynamicPDF Generator API but we have another product called DynamicPDF Converter for .NET using which you can convert Word document to PDF. Please refer to the documentation on supported file types and software requirements here and also documentation on operating system requirements here. Below is the code sample to convert the word document to PDF byte array.

            byte[] wordDocByteData = File.ReadAllBytes(@"D:\temporary\ConverterIssues\Document1.docx");
            byte[] pdfByteData = Converter.Convert(wordDocByteData, "Document1.docx");

You can download evaluation edition of DynamicPDF Converter for .NET product from our website here. Also refer to the code samples included with the evaluation download.

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 3:41 AM.