Ravi Bhatt

Hi,

I am sending PDF as fax from my application.It works fine bt the only issue is, Adobe Acrobat's new instance gets opened automatically.The solutions I got is to fax TIFF files rather than PDF.

Can anyone do let meknow how to convert PDF to TIFF through C#

Thanks,

Ravi Bhatt




Re: Visual C# General How to convert PDF to TIFF through C#?

Martin Xie - MSFT

Hi Ravi,

Currently I don't find a class in the .NET Framework to convert PDF to TIFF file.

However, you can use an external library PDF4NET to achieve your goal, which can handle very large files (30000+ pages in a PDF).

See this threa Convert to TIFF image for detail.

Another approach is checking this article including good samples and illustrations.

100% .NET component for rendering PDF documents

PDFRasterizer.NET is a component for rendering PDF documents and is written entirely in C#.

This article describes how to use the PDFRasterizer.NET component to:

  1. Convert PDF documents to raster images such as BMP, GIF, PNG, TIFF etc.
  2. Display PDF documents in your WinForms application (with and without an EMF)
  3. Programmatically print PDF documents

Hope that helps!






Re: Visual C# General How to convert PDF to TIFF through C#?

dotnetideas

NOTE:

The following code is for converting TIFF files to other image files. NOT for converting PDF to TIFF. Sorry.

Code Snippet

public static byte[] ConvertImage(byte[] fromImage, string mimeType)

{
// Read the image from the byte variable into a bitmap variable
MemoryStream fromImageStream = new MemoryStream();
fromImageStream.Write(fromImage, 0, fromImage.Length);
Image image = Image.FromStream( fromImageStream, true ) ;
Bitmap bitmap = (Bitmap) image;
// Instantiate the encoder
EncoderParameters encoderParams = new EncoderParameters();
encoderParams.Param[0] = new EncoderParameter( Encoder.Quality, 50L );
ImageCodecInfo codecInfo = GetEncoderInfo( mimeType );
MemoryStream newImage = new MemoryStream();
// Convert the image to the new format
bitmap.Save( newImage, codecInfo, encoderParams );
// Read the new image into a byte variable
byte[] data = newImage.ToArray();

if (Logger.LogSwitch.LogInfo)
{
Logger.Write("ImageUtility", "EXITING ConvertImage method");
}

return data;

}

private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}






Re: Visual C# General How to convert PDF to TIFF through C#?

Jason Zhao

i also have the same problem, when fax pdf file\

anyone can solve, can share with me

email:

hajor#msn.com






Re: Visual C# General How to convert PDF to TIFF through C#?

Jason Zhao

good




Re: Visual C# General How to convert PDF to TIFF through C#?

Jerry Maple CTS

DId you find a solution if so can you send me some info




Re: Visual C# General How to convert PDF to TIFF through C#?

Jason Zhao

i didn't solove it ,

now I try Ghostscript






Re: Visual C# General How to convert PDF to TIFF through C#?

lfernandez6

I tried using your code but received an error on the

Image image = Image.FromStream.....

"Parameter is not valid"

Only happens when I open a PDF. I tried with .tif and it worked.

Any ideas





Re: Visual C# General How to convert PDF to TIFF through C#?

dotnetideas

I am not sure. It may has something to do with how you read the PDF into the byte[]

Here is how I did it.

Code Snippet

byte[] data = null;

FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
// Read the image into the byte variable
data = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();

Then I passed the "data" to the method in my previous post. It worked fine for me.

--------------------------------------------------------------------------------------------------------------------------------

www.dotnetideas.com






Re: Visual C# General How to convert PDF to TIFF through C#?

tesseraltyme

Try this free online service to convert PDF files to TIFF or up to 117 other file formats. www.freepdfconvert.com To incorporate this service directly into your website or application, refer to http://www.freepdfconvert.com/service_integration.asp . This service is free with limitations and for a nomonal membership fee you can unlock the limitations.



Re: Visual C# General How to convert PDF to TIFF through C#?

Jason Zhao

i also happen the same problem

Image image = Image.FromStream.....

"Parameter is not valid"






Re: Visual C# General How to convert PDF to TIFF through C#?

DevxZA

I seem to be getting the invalid parameter error as well. Is there other objects that need referencing

Thanks





Re: Visual C# General How to convert PDF to TIFF through C#?

Ravi Bhatt

Hi,

I got it solved.I was wble to send text and .jpeg successfully.Only the problwem came when i needed to send the pdf.So i convertedt it to tiff and treid to send it as a fax.Yest i sent it sucessfully and problem with the pdf got solved. No adobe instance gets open now.Big Relief to me.

I used ABCPdf's professional edition to convert pdf to tiff. And that worked for me.

Regards,

Ravi bhatt.






Re: Visual C# General How to convert PDF to TIFF through C#?

Deecke

I'm getting this "Parameter is not valid" exception, as well.

It's not only PDF, using RTF files causes the same exception.

Actually, I cannot imagine that it's possible to instanciate an Image with the data of an arbitray file without any previous conversion.

But I'm still interested in any solution of this problem.





Re: Visual C# General How to convert PDF to TIFF through C#?

Jason Zhao

Hi, great work

can you say details

thanks