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
//
}
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
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?
something like recursing all the the folder structure and converting with them to same file name.pdf..
ravi2k7@hotm...
Participant
1315 Points
312 Posts
How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Nov 14, 2008 04:49 AM|LINK
HI all
I have a urgent requirement i want to convert .tiff image to .pdf file
Thanks in advance
Ravi
Please click "mark as answer" if this post helped you.
skvignesh
Contributor
2670 Points
512 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Nov 14, 2008 10:33 AM|LINK
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
S.K.Vignesh
Srikanth Kas...
Contributor
4289 Points
883 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Nov 21, 2008 11:09 AM|LINK
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!..
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
maduranga001
Member
162 Points
235 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Jan 06, 2009 12:44 PM|LINK
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();
}
}
maduranga001
Member
162 Points
235 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Jan 07, 2009 02:21 AM|LINK
doknek
Member
750 Points
145 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Jan 18, 2009 11:05 PM|LINK
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.
maduranga001
Member
162 Points
235 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Jan 19, 2009 02:41 AM|LINK
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.
sowji250
Member
3 Points
5 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Feb 23, 2009 06:52 PM|LINK
Thanks to Srikanth Kasturi. PDFSharp code worked fine for me. Here is the code.
To make this work you need Tiff related code also. Here is the Tiff Image Splitter code.
Hope this helps.
get pages in Tiff image Convert Tiff to PDF
raja.s
Member
252 Points
61 Posts
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Oct 28, 2009 12:40 PM|LINK
Please have a look on this.it will be very help full for u.
http://www.colorpilot.com/pdfcreatorpilotmanual/How_to_convert_image_to_PDF_using_VB_NET.html
Raja Subramanian.
Please mark it as Answer if its a correct solution.
It will help others to avoid reading wrong post.
SandeshSindo...
Member
2 Points
1 Post
Re: How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
Nov 08, 2010 10:36 PM|LINK
This works for me too.
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?
something like recursing all the the folder structure and converting with them to same file name.pdf..
Thanks.