How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net

HI all

I have a urgent requirement i want to convert .tiff image to .pdf file 

Thanks in advance


Regards
Ravi
Please click "mark as answer" if this post helped you.
0
ravi2k7
11/14/2008 5:49:38 AM
asp.net.drawinggdi 1803 articles. 0 followers. Follow

7 Replies
6199 Views

Similar Articles

[PageSpeed] 45

I dont think its possible without doing a lot of code or using third party tools, but if you  are looking for a free tool you can try a combination of

http://blog.codebeach.com/2008/02/convert-multipage-tiff-to-pdf-in-net.html

and  

http://www.codeproject.com/KB/aspnet/Creating_PDF_documents_in.aspx

 


Thanks and Regards

S.K.Vignesh
----------------------
Do remember to "Mark as answer" for this post or the post that helped you solve the issue
0
skvignesh
11/14/2008 11:33:05 AM

Download the Open Source Library called as PDFSharp then put this code in, for creating, drawing and saving the pdf file.

 PdfDocument doc = new PdfDocument();
     doc.Pages.Add(new PdfPage());
     XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
     XImage img = XImage.FromFile(source);

     xgr.DrawImage(img, 0, 0);
     doc.Save(destinaton);
     doc.Close();

 I hope this works.. If you get any other solution pls do post.

Best Wishes

$r!.. 

 

0
Srikanth
11/21/2008 12:09:00 PM

This was not working for tiff files.Then I had to generate a jpeg and import to the pdf and delete the jpeg.Here is my class code.Waiting for your comments.This works.Thank you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using WebsiteThumbnail;
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using System.IO;

/// <summary>
/// Summary description for cls_pdf
/// </summary>
public class cls_pdf
{
    public cls_pdf()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public void PdfGen(string URL, string pageWidth, string pageHeight, string savingPath, string fileName)
    {
        string address = URL; //"http://" + txtWebsiteAddress.Text;
        int width = Int32.Parse(pageWidth);
        int height = Int32.Parse(pageHeight);
        //Bitmap bmp = WebsiteThumbnailImageGenerator.GetWebSiteThumbnail(address, 800, 600, width, height);
        Bitmap bmp = WebsiteThumbnailImageGenerator.GetWebSiteThumbnail(address, width, height, width, height);

        string jpegSource = savingPath + "/ " + fileName + ".jpg";
        string pdfSource =  savingPath + "/ " + fileName + ".pdf";
        bmp.Save(jpegSource);//bmp.Save(Server.MapPath("~") + "/thumbnail.tif");

        PdfDocument doc = new PdfDocument();
        doc.Pages.Add(new PdfPage());
        XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
        XImage img = XImage.FromFile(jpegSource);

        xgr.DrawImage(img, 0, 0, width, height);
        doc.Save(pdfSource);
        doc.Close();

        FileInfo delimg = new FileInfo(jpegSource);
        delimg.Delete();
    }
}

 

0
maduranga001
1/6/2009 1:44:47 PM
Do remember to "Mark as answer" for above post or the post that helped you solve the issue like my issue.
0
maduranga001
1/7/2009 3:21:08 AM

 You will need to use a 3rd party tool to get the job done easily. There is a very good open source library called itextSharp. Try it out, it is real good, fast and reliable. I've used it in many projects.


Please click "Mark as Answer" if you think this post answers your question
0
doknek
1/19/2009 12:05:02 AM

 There is no a direct method to use iTextSharp.PdfSharp is an opensource .dll. Look at my previouse thread using PdfSharp codings.I have tested it.

 

0
maduranga001
1/19/2009 3:41:23 AM

Thanks to Srikanth Kasturi. PDFSharp code worked fine for me. Here is the code.

using PdfSharp.Pdf;
using PdfSharp.Drawing;
TiffImageSplitter tiff = new TiffImageSplitter(); 
 public void tiff2PDF(string fileName)
{
PdfDocument doc = new PdfDocument();

int pageCount = tiff.getPageCount(fileName);

for (int i = 0; i < pageCount; i++)
{
PdfPage page = new PdfPage();

Image tiffImg = tiff.getTiffImage(fileName, i);

XImage img = XImage.FromGdiPlusImage(tiffImg);

page.Width = img.PointWidth;
page.Height = img.PointHeight;
doc.Pages.Add(page);

XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[i]);

xgr.DrawImage(img, 0, 0);
}

doc.Save("C:/CJT/PDF/34326.pdf");

doc.Close();

}

 To make this work you need Tiff related code also. Here is the Tiff Image Splitter code.

  

 class TiffImageSplitter
    {
        // Retrive PageCount of a multi-page tiff image
        public int getPageCount(String fileName)
        {
            int pageCount = -1;
            try
            {
                Image img = Bitmap.FromFile(fileName);
                pageCount = img.GetFrameCount(FrameDimension.Page);
                img.Dispose();

            }
            catch (Exception ex)
            {
                pageCount = 0;
            }
            return pageCount;
        }

        public int getPageCount(Image img)
        {
            int pageCount = -1;
            try
            {
                pageCount = img.GetFrameCount(FrameDimension.Page);
            }
            catch (Exception ex)
            {
                pageCount = 0;                
            }
            return pageCount;
        }

// Retrive a specific Page from a multi-page tiff image
        public Image getTiffImage(String sourceFile, int pageNumber)
        {
            Image returnImage = null;

            try
            {
                Image sourceIamge = Bitmap.FromFile(sourceFile);
                returnImage = getTiffImage(sourceIamge, pageNumber);
                sourceIamge.Dispose();
            }
            catch (Exception ex)
            {
                returnImage = null;                
            }

            //       String splittedImageSavePath = "X:\\CJT\\CJT-Docs\\CJT-Images\\result001.tif";
            //       returnImage.Save(splittedImageSavePath);

            return returnImage;
        }

        public Image getTiffImage(Image sourceImage, int pageNumber)
        {
            MemoryStream ms = null;
            Image returnImage = null;

            try
            {
                ms = new MemoryStream();
                Guid objGuid = sourceImage.FrameDimensionsList[0];
                FrameDimension objDimension = new FrameDimension(objGuid);
                sourceImage.SelectActiveFrame(objDimension, pageNumber);
                sourceImage.Save(ms, ImageFormat.Tiff);
                returnImage = Image.FromStream(ms);
            }
            catch (Exception ex)
            {
                returnImage = null;                   
            }
            return returnImage;
        }
} 

 

Hope this helps.

2
sowji250
2/23/2009 7:52:44 PM
Reply:

Similar Artilces:

COnverting image file into PDF file in C#.NET
hi friends, i have a problem in creating a PDF file from an image file. first of all pls clarify what is the internal concept in converting to PDF file. if nay one knows pls mail me the related code if you find any solution pls mail me at spend5mins@yahoo.com thank u all hari babu...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

How to convert a Color tiff file to Black and white tiff file using vb/C# code?
  Hi ,    I have a lot of TIFF file in Color format. Now I want to convert into Black and White TIFF file because color is taking lot of memory.  one color file is 5 MB. How to convert a Color tiff file to Black and white tiff file using vb.net code?  Please any one reply. Here is the code you need !use the ConvertToBitonal function to conver your color tiff file to black & white one. using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Text; ...

How to Create .mdb file from Excel file using C#.net
Hi all I want to create .mdb file that i have created excel feel from MS jet Database... through code behind Help me in this..  Regards RaviPlease click "mark as answer" if this post helped you. How to create an mdb file programmtically:http://support.microsoft.com/kb/317881How to import Excel data into it: http://www.mikesdotnetting.com/Article.aspx?ArticleID=79 Regards Mike [MVP - ASP/ASP.NET]My site...

Generating a PDF file using c#.net
Hello,  I' m having to create  a pdf file at the click of a button. I' m new to this can you please suggest a procedure I could follow or a tutorial I could read. thanks Mythili You would be best advised to use a component to help you with this. It's going to be very hard to do by hand. Google should be able to find you alternatives fairly easily.  check this 3rd party control  HTML to PDF converter. The conversion can be done with only a few lines of code.  and also check this linkMy Blog"Don't be afraid to be wrong; otherwise you'l...

Read a PDF file using C#.Net
 Hi,    Is there any way to read a PDF file using C#.net?I have already used third party tools like itextsharp and its dlls. But it is not worthy.Is there any alternative third party dlls?If any body tell means it would be a great help.Thanks in advance!    Have a look at the following - they are C# projects that include a read of PDF's Parsing PDF files in .NET using PDFBox and IKVM.NET (managed code). http://www.codeproject.com/KB/string/pdf2text.aspxA Windows Service that indexes DOC, PDF, XLS, PPT, RTF, HTML, TXT, XML, and other file formats http:...

Converting images to a video file using .net
 Hai All,Please let me know the procedure for converting images to a video file using .net......... Thanking You.........    Maybe this will help http://www.codeproject.com/cs/media/avifilewrapper.asp   http://www.codeproject.com/csharp/steganodotnet4.aspSilverlight-helpVb TipsSpace Coast .Net User Group Hai Mr.Ken Tucker,Thanks for sending useful information,but those two aplications are for converting BMP images two a video file.I need to convert jpg images to a video file.Please let me know the convertion of jpg images to a video file. Thanking you......

How can I edit a pdf file using C#.net
 How can I edit a pdf file using C#.netRegards Anu Palavila I think you need to look for a good API.I found this one. I don't know if there is an opensource API. Try Googling Edit PDF .NET APIJef Claes~~~~~~~~~~Visit my blog  Hi,U may use itextsharphttp://sourceforge.net/projects/itextsharp/http://csharpdotnetfreak.blogspot.com/2008/12/export-gridview-to-pdf-using-itextsharp.htmlHope It helpsThanksAvinash TiwariRemember to click “Mark as Answer” on the post, if it helps you.  Hi anupalavila,You can use pdftotext to convert pdf to plain text file and iTextSharp  ...

How to convert a pdf file to text format using .net
Hi all, I want to convert a PDF format file to a text format file(i.e., Wordpad or Notepad).For this i have to use .Net only. Plz send replies urgently. tnx ramesh...

how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET
how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET Now am converting using how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET  tool. But the dynamicaly loading images are not showing in the pdf .     Are you using 3rd party tool or you are using iTextSharp free utility? If it is 3rd party tool, it's always suggested to ask the company which built the tool. Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti Hi vishnusekhar, As to convert images/douments to pdf files in asp.net , have you read this article? http://www.colorpilot.com/pdfsample_aspnet.html It's a Step by Step tutorial, very clear to follow, so take a try. This may also help since the project source code is shared and attached: http://www.codeproject.com/aspnet/HTML2PDF.asp I hope my suggestion can help  This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving...

How to use VB.Net Files in C# Project and Compile All project to Only One Assembly File.?
Hi all,I have a Library of Useful Functions and procedures But in VB.Net Language(*.vb not *.dll).All the time i have to Add additional Project to my current Project and add that VB.Net Library to it ,Then Compile it and Reference it to  my C# project and use it .so as a consequence,After Compilation in the "Bin" directory i have additional assembly Related to that VB.Net Class Library rather than one.I want to know is there any way to Achieve only One Assembly Not Two. Thanks In Advance.Regards.Nothing Is Quite Impossible !!!...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of developing. The trick is to use the "Src" attribute of the @Page directive. Check out the link if you are inclined. You are welcome to download the code if you are interested further, found at the same link. (Note that the reason that I looked for a way to do this is because I wanted to have the option to include some VB.NET-based demos at my site. Since my site is a C#.NET ASP.NET, I was told that there was no want to do this. Therefore, I looked for a workaround and just happened to find one.) Enjoy (and then get back to work!) http://www.NetBrainer.com you are right !!!mixing languages could cause unknow and uncontrolled problems !!! if a developer has to mix ....the practical way is to create a new project with different language and what will be absolutely fine !!!thanks mkamoski for raising this issue !!Fadil Alnassar www.fadilalnassar.com | FREE Nodil Tab Controlhttp://www.mefranchisi...

Smart Device Application for file transfer to a remote server in .Net Compact Framework (Using Visual Studio.Net 2003,C# code)
Dear all, We are developing a smart device application (using C# code) for .Net Compact Framework where we need to write a programme in C# code to transfer a file from mobile device to remote server/machine.Can anyony help us regarding this aaplication.If you have already done this or you find any article/link regarding to this application then please let me know about that. My mail id : anirbandas.ju@gmail.com Looking forward for your reply soon. Regards Anirban   hi hav u got any solution , becoz i too need. plz share with me...

Create PDF file using .NET
Hello List, Can someone tell me how can I create PDF file using .NET? Thanks in advance, Peter, Hi, Tale a look @ ABCpd HTH K B ShajudeenAreYaar.comDubai, United Arab Emirates. Also, Siberix PDF Library for .NET is available as a trial download. I had the trial up and running in minutes. Couldn't have been easier ...Alister Below post has some related info http://asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=380008Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti...

how to convert html file (with tables) to pdf file using iTextSharp.
hello, i searched a lot and also look at iTextsharp tutorials but didn't find any solutions. i have a html file which contains a table. and i try to convert it into pdf using iTextSharp but it doesn't work. here is my code:string inputFile =@"C:\Try.htm";string outputfile =@"C:\try.pdf";            try            {                // step 1: creation of a document-object                Document document = new Document(PageSize.A4, 80, 50, 30, 65);                // step 2:                // we create a writer that listens to the document                // and directs a XML-stream to a file                PdfWriter.GetInstance(document, new FileStream(outputfile, FileMode.Create));                // step 3: we parse the document                HtmlPars...

web services used to convert Word files to PDF files
My professor asked me to design a web services which convert Microsoft's word files to PDF files. by use VS.NET and Windows Server 2003. After I installe Adode Acrobat 6.0 Professional, I can find some Acrobat components, Acrobat Distiller, Acrobat Web Capture 1.0 Type Library, etc. Please tell me which one can be used for my project and how to use it. Or please tell me popular free components of third parts. Thanks!...

outlook file DBX file extract using vb.net
hi i want to read email in dbx file using vb.net plase help me .... Dear, U can see the below link: http://groups.google.de/group/microsoft.public.dotnet.languages.vb/browse_frm/thread/1d037d2c7bc46a98/Kind Regards,Saurabh Sharmaonly dead fish swim along the flow of river, learn to make your own way.Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread...

Using Dot Net Nuke to maintain a site developed in VS.NET using C#
Hi,Does anyone know if there is a way to create a site using C# and Visual Studio.NET 2003, but then use Dot Net Nuke to allow non-technical users to add content to the site.  The current state of the site must be accessible in both VS.NET and DNN regardless of which application saved it last.  Also preferably I would like the language used to remain C# even when edited by the marketing staff, so that I can still maintain it myself using VS.NET.  Hope you understand what I mean. If this is not possible, I wonder if anyone knows what solution I am after.   Thanks in adv...

Convert Visio Files To Other Formats Using .NET
Have you ever wondered how to convert Visio files to other formats using .NET? The following article explains how to convert a Visio file into a .jpg image. Visit http://www.aspalliance.com/377Jason N. GaylordASPInsider and Microsoft MVPhttp://jasongaylord.com...

writing data on files using c#.net
Hello all,  I am creating a rich text document file and writing some data.using c#.net This is fine but i want to present data using style(eg. bold,font-size,etc). How is this possible? the code used is System.IO.Directory.CreateDirectory("C:/Receipt"); TextWriter tw = new StreamWriter("C:/Receipt/Receipt-" + ShipId + "-" + OrderNumber + ".rtf"); tw.WriteLine("This is the text to be bold but couldn't be bold"); tw.WriteLine("\r\n" Any help would be appreciable hi,you can try something like that  FileStream sw = File.Open(Server.MapPath("Sample1.doc"),FileMode.Trun...

Using Class files without VS.NET
Hi, I have written some class files for different purpose and I want to include them to my page files. For one class file i use this code below. visit.aspx ---------------- <%@ page language="vb" src="visit.vb" inherits="vismain.viscustom" %> visit.vb -------------------- namespace vismain public class viscustom public sub additem(byval visID as string) ........ End Sub End Class End Namespace what I need to use more then one class file in one aspx file !! Just like in Starterkit.Commerce project in login....

uploading files in Email using c#.net
I have a c#.net ASP webpage. Please let me if anyone can provide with a code for Attaching files.Thanking you.ABAK. Hi here is some code. MailMessage msgMail = new MailMessage();msgMail.To = sender address;msgMail.From = recepient address;msgMail.Subject = mail subject;msgMail.Body = body text;msgMail.Attachments.Add(new MailAttachment(your file path));SmtpMail.Send(msgMail); Hope it will help. try using the fileupload html control and change it to html webserver control. dim fileArr() as string = FileUpload.PostedFile.FileName.split("\") ' to create an array with items o...

How can I read the HTTP file use c#? subject: image file.
The server have internet but the client can't link to internet. I want use the server to read HTTP file and show it to client.Thanks for your help.Weboy B.Wan---------------------------------------MSN: weboy.wan"at"msn.comE-Mail: weboy.wan"at"gmail.com private void Page_Load(object sender, System.EventArgs e) { Response.Buffer = true; System.Net.WebRequest req = System.Net.WebRequest.Create("http://www.microsoft.com/"); System.Net.WebResponse res = req.GetResponse(); System.IO.Stream stream = res.GetResponseStream(); System.IO.StreamReader reader = new System.IO.StreamReader(...

unintelligible file name when using Response to download a file. VB.net
I have a website that shows a list of files stored in the server. Here is the code:Dim ObjFileinfo As New FileInfo(strRootPath) Response.Clear() Response.AddHeader("Content-Disposition", "attachement;filename=" & strFileName) 'NOTE: strFile Name contains the name in Russian, if I Response.Write(strFileName)'I get the proper Russian name displayed on the page so I am sure that I am passing the right oneResponse.AddHeader("Content_Length", ObjFileinfo.Length.ToString()) Response.ContentType = "application/octet-stream" Response.Transm...

Web resources about - How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net - asp.net.drawinggdi

List of converts to Buddhism - Wikipedia, the free encyclopedia
Ajahn Brahm (born 1951), Religious teacher and student of the late Thai monk Ajahn Chah . Currently he is the abbot of the Bodhinyana Monastery, ...

Facebook Timeline For Pages: 8 Million Converts, 29 Million To Go
... reach to 98 percent of users who liked its page, as well as to double its engagement rate, during a 28-day period. Dr. Pepper hasn’t yet converted ...

Facebook stock roundup: Execs offload more stock, directors convert shares
... Bowles, the former co-chair of the now-defunct National Commission on Fiscal Responsibility and Reform, and Reed Hastings, Netflix CEO, converted ...

How to Convert Leads Into Buying Customers - The 9 Step Sales Process EVERYONE Should Use
... School of Business in Toronto on the topics of Sales and Entrepreneurship. I shared with them the sales process that I find How to Convert Leads ...

Bitcoin : Should I convert my savings to Bitcoin?
Answer (1 of 7): You should think of this question as "Should I invest all my savings in Bitcoin?", and not "Should I have my savings denominated ...

Coordinates - Calculate and Convert a Position on the App Store on iTunes
Get Coordinates - Calculate and Convert a Position on the App Store. See screenshots and ratings, and read customer reviews.

Coca-Cola made packaging that converts into a free Google Cardboard-style VR viewer [Video]
... if the above experiment turns into reality. The project envisions packaging for a 12-pack of Cokes and other products that is easily converted ...

Coca-Cola made packaging that converts into a free Google Cardboard-style VR viewer for iPhone
... if the above experiment turns into reality. The project envisions packaging for a 12-pack of Cokes and other products that is easily converted ...

The Galaxy S7 Edge may have just made me a Samsung convert
Historically, I've had a begrudging respect for Samsung flagships. I can objectively acknowledge the company makes very good, extremely popular ...

This modular robot tank converts into a tracked hoverboard
Filed under: Etc. , Videos , Autonomous , Military , Off-Road The unmanned vehicle is equal parts hoverboard and tank.

Resources last updated: 3/8/2016 12:59:43 AM