How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.nethttp://forums.asp.net/t/1348035.aspx/1?How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netThu, 09 Jun 2011 07:35:52 -040013480352744907http://forums.asp.net/p/1348035/2744907.aspx/1?How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netHow to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>HI all</p> <p>I have a urgent requirement i want to convert .tiff image to .pdf file&nbsp;</p> <p>Thanks in advance <br> </p> 2008-11-14T04:49:38-05:002745540http://forums.asp.net/p/1348035/2745540.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>I dont think its possible without doing a lot of code or using third party tools, but if you&nbsp; are looking for a free tool you can try a combination of </p> <p>http://blog.codebeach.com/2008/02/convert-multipage-tiff-to-pdf-in-net.html</p> <p>and &nbsp;</p> <p>http://www.codeproject.com/KB/aspnet/Creating_PDF_documents_in.aspx</p> <p>&nbsp;</p> 2008-11-14T10:33:05-05:002760089http://forums.asp.net/p/1348035/2760089.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>Download the Open Source Library called as PDFSharp then put this code in, for creating, drawing and saving the pdf file.</p> <p>&nbsp;PdfDocument doc = <span class="code-keyword">new</span> PdfDocument();<br> &nbsp;&nbsp;&nbsp;&nbsp; doc.Pages.Add(<span class="code-keyword">new</span> PdfPage());<br> &nbsp;&nbsp;&nbsp;&nbsp; XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[<span class="code-digit">0</span>]);<br> &nbsp;&nbsp;&nbsp;&nbsp; XImage img = XImage.FromFile(source);<br> <br> &nbsp;&nbsp;&nbsp;&nbsp; xgr.DrawImage(img, <span class="code-digit">0</span>, <span class="code-digit"> 0</span>);<br> &nbsp;&nbsp;&nbsp;&nbsp; doc.Save(destinaton);<br> &nbsp;&nbsp;&nbsp;&nbsp; doc.Close();</p> <p>&nbsp;I hope this works.. If you get any other solution pls do post.</p> <p>Best Wishes</p> <p>&#36;r!..&nbsp;</p> <p>&nbsp;</p> 2008-11-21T11:09:00-05:002849666http://forums.asp.net/p/1348035/2849666.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>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.</p> <p><b>using System;<br> using System.Collections.Generic;<br> using System.Linq;<br> using System.Web;<br> using System.Drawing;<br> using WebsiteThumbnail;<br> using PdfSharp.Pdf;<br> using PdfSharp.Drawing;<br> using System.IO;<br> <br> /// &lt;summary&gt;<br> /// Summary description for cls_pdf<br> /// &lt;/summary&gt;<br> public class cls_pdf<br> {<br> &nbsp;&nbsp;&nbsp; public cls_pdf()<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // TODO: Add constructor logic here<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //<br> &nbsp;&nbsp;&nbsp; }<br> <br> &nbsp;&nbsp;&nbsp; public void PdfGen(string URL, string pageWidth, string pageHeight, string savingPath, string fileName)<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string address = URL; //&quot;http://&quot; &#43; txtWebsiteAddress.Text;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int width = Int32.Parse(pageWidth);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int height = Int32.Parse(pageHeight);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Bitmap bmp = WebsiteThumbnailImageGenerator.GetWebSiteThumbnail(address, 800, 600, width, height);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bitmap bmp = WebsiteThumbnailImageGenerator.GetWebSiteThumbnail(address, width, height, width, height);<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string jpegSource = savingPath &#43; &quot;/ &quot; &#43; fileName &#43; &quot;.jpg&quot;;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string pdfSource =&nbsp; savingPath &#43; &quot;/ &quot; &#43; fileName &#43; &quot;.pdf&quot;;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bmp.Save(jpegSource);//bmp.Save(Server.MapPath(&quot;~&quot;) &#43; &quot;/thumbnail.tif&quot;);<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PdfDocument doc = new PdfDocument();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Pages.Add(new PdfPage());<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XImage img = XImage.FromFile(jpegSource);<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xgr.DrawImage(img, 0, 0, width, height);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Save(pdfSource);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Close();<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileInfo delimg = new FileInfo(jpegSource);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delimg.Delete();<br> &nbsp;&nbsp;&nbsp; }<br> }</b><br> &nbsp;</p> 2009-01-06T12:44:47-05:002850986http://forums.asp.net/p/1348035/2850986.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net Do remember to &quot;Mark as answer&quot; for above post or the post that helped you solve the issue like my issue.<br> 2009-01-07T02:21:08-05:002875123http://forums.asp.net/p/1348035/2875123.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>&nbsp;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.<br> </p> 2009-01-18T23:05:02-05:002875388http://forums.asp.net/p/1348035/2875388.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>&nbsp;There is no a direct method to use iTextSharp.<b>PdfSharp</b> is an opensource .dll. Look at my previouse thread using <b>PdfSharp </b>codings.I have tested it.</p> <p>&nbsp;</p> 2009-01-19T02:41:23-05:002961259http://forums.asp.net/p/1348035/2961259.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>Thanks to Srikanth Kasturi. PDFSharp code worked fine for me. Here is the code. <br> </p> <pre class="prettyprint">using PdfSharp.Pdf; using PdfSharp.Drawing;</pre><pre class="prettyprint">TiffImageSplitter tiff = new TiffImageSplitter(); <br></pre><pre class="prettyprint">&nbsp;<span class="kwd">public void</span> tiff2PDF(<span class="kwd">string</span> fileName)<br> {<br> PdfDocument doc = <span class="kwd">new</span> PdfDocument();<br><br> <span class="kwd">int</span> pageCount = tiff.getPageCount(fileName);<br><br> <span class="kwd">for</span> (<span class="kwd">int</span> i = 0; i &lt; pageCount; i++)<br> {<br> PdfPage page = <span class="kwd">new</span> PdfPage();<br> <br> Image tiffImg = tiff.getTiffImage(fileName, i);<br> <br> XImage img = XImage.FromGdiPlusImage(tiffImg);<br> <br> page.Width = img.PointWidth;<br> page.Height = img.PointHeight;<br> doc.Pages.Add(page);<br> <br> XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[i]);<br><br> xgr.DrawImage(img, 0, 0);<br> }<br><br> doc.Save(<span class="st">"C:/CJT/PDF/34326.pdf"</span>);<br><br> doc.Close();<br> <br> }</pre><p>&nbsp;To make this work you need Tiff related code also. Here is the Tiff Image Splitter code.<br></p><p>&nbsp;&nbsp;</p><pre class="prettyprint"> <span class="kwd">class</span> TiffImageSplitter { <span class="cmt">// Retrive PageCount of a multi-page tiff image</span> <span class="kwd">public int</span> getPageCount(String fileName) { <span class="kwd">int</span> pageCount = -1; <span class="kwd">try</span> { Image img = Bitmap.FromFile(fileName); pageCount = img.GetFrameCount(FrameDimension.Page); img.Dispose(); } <span class="kwd">catch</span> (Exception ex) { pageCount = 0; } <span class="kwd">return</span> pageCount; } <span class="kwd">public int</span> getPageCount(Image img) { <span class="kwd">int</span> pageCount = -1; <span class="kwd">try</span> { pageCount = img.GetFrameCount(FrameDimension.Page); } <span class="kwd">catch</span> (Exception ex) { pageCount = 0; } <span class="kwd">return</span> pageCount; } <span class="cmt">// Retrive a specific Page from a multi-page tiff image</span> <span class="kwd">public</span> Image getTiffImage(String sourceFile, <span class="kwd">int</span> pageNumber) { Image returnImage = <span class="kwd">null</span>; <span class="kwd">try</span> { Image sourceIamge = Bitmap.FromFile(sourceFile); returnImage = getTiffImage(sourceIamge, pageNumber); sourceIamge.Dispose(); } <span class="kwd">catch</span> (Exception ex) { returnImage = <span class="kwd">null</span>; } <span class="cmt">// String splittedImageSavePath = "X:\\CJT\\CJT-Docs\\CJT-Images\\result001.tif"; // returnImage.Save(splittedImageSavePath);</span> <span class="kwd">return</span> returnImage; } <span class="kwd">public</span> Image getTiffImage(Image sourceImage, <span class="kwd">int</span> pageNumber) { MemoryStream ms = <span class="kwd">null</span>; Image returnImage = <span class="kwd">null</span>; <span class="kwd">try</span> { ms = <span class="kwd">new</span> MemoryStream(); Guid objGuid = sourceImage.FrameDimensionsList[0]; FrameDimension objDimension = <span class="kwd">new</span> FrameDimension(objGuid); sourceImage.SelectActiveFrame(objDimension, pageNumber); sourceImage.Save(ms, ImageFormat.Tiff); returnImage = Image.FromStream(ms); } <span class="kwd">catch</span> (Exception ex) { returnImage = <span class="kwd">null</span>; } <span class="kwd">return</span> returnImage; }</pre><pre class="prettyprint">} <br></pre> <p>&nbsp;</p> <p>Hope this helps. <br> </p> 2009-02-23T18:52:44-05:003481479http://forums.asp.net/p/1348035/3481479.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>Please have a look on this.it will be very help full for u.</p> <p>http://www.colorpilot.com/pdfcreatorpilotmanual/How_to_convert_image_to_PDF_using_VB_NET.html</p> 2009-10-28T12:40:21-04:004159725http://forums.asp.net/p/1348035/4159725.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>This works for me too.</p> <p>But can we convert the whole folder containing tiff's? i.e, i have a folder tree containing tiff's in all different folder, so can we just give the root folder and convert all tiff's to pdf's?</p> <p>something like recursing all the the folder structure and converting with them to same file name.pdf..</p> <p>Thanks.</p> 2010-11-08T22:36:33-05:004407956http://forums.asp.net/p/1348035/4407956.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p><span class="hps" title="&#1084;, ">Try to</span>&nbsp;<span class="hps" title="&#1084;, ">use</span><a target="_blank" title="Convert Tiff to PDF" href="http://www.sautinsoft.com/products/convert-html-pdf-and-tiff-pdf-asp.net/html-to-pdf-jpeg-tiff-gif-to-pdf-asp.net.php">&nbsp;</a><span class="hps" title="&#1084;, "><a target="_blank" title="Convert Tiff to PDF" href="http://www.sautinsoft.com/products/convert-html-pdf-and-tiff-pdf-asp.net/html-to-pdf-jpeg-tiff-gif-to-pdf-asp.net.php">PDF Vision (for c#, asp.net, vb.net)</a>.</span>&nbsp;<span class="hps" title="&#1084;, ">Trial</span>&nbsp;<span class="hps" title="&#1084;, ">version</span>&nbsp;<span class="hps" title="&#1084;, ">is unlimited</span><span title="&#1084;, ">.</span>&nbsp;</p> <p><span class="hps" title="&#1084;, ">It</span>&nbsp;<span class="hps" title="&#1084;, ">adds</span>&nbsp;<span class="hps" title="&#1084;, ">only</span>&nbsp;<span class="hps" title="&#1084;, ">a small</span>&nbsp;<span class="hps" title="&#1084;, ">piece of text</span>&nbsp;<span class="hps" title="&#1084;, ">from</span>&nbsp;<span class="hps" title="&#1084;, ">which</span>&nbsp;<span class="hps" title="&#1084;, ">it is easy to</span>&nbsp;<span class="hps" title="&#1084;, ">get rid of.</span></p> 2011-05-05T11:10:33-04:004452198http://forums.asp.net/p/1348035/4452198.aspx/1?Re+How+to+convert+tiff+image+file+to+pdf+file+without+using+any+3rd+party+tool+using+C+netRe: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net <p>Hi,</p> <p>Thats very nice. The solution saves the converted PDF document on harddisk. I wonder, if anyone knows how to download the converted file (PDF) from an ASP.NET page.</p> <p>Thanks.</p> <p>R</p> 2011-06-09T07:35:52-04:00