We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Simple conversion TIFF to PDF

Is there a simple way to take a bunch of TIFF files and convert them to PDF? I've been reading posts and tried some of the sample code. Although I can create the PDF, images are being cut-off, etc. when all I would like to do is take a multi page tiff and have a pdf representation of it.

Sample Code:
Pdf pdf1 = new Pdf();
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();
sec1.PageInfo.Margin.Top = 0;
sec1.PageInfo.Margin.Left = 0;
sec1.PageInfo.Margin.Right = 0;
sec1.PageInfo.Margin.Bottom = 0;
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(sec1);
sec1.Paragraphs.Add(image1);
image1.ImageInfo.File = "test.tif";
image1.ImageInfo.ImageFileType = ImageFileType.Tiff;
image1.ImageInfo.TiffFrame = -1;
image1.ImageInfo.IsAllFramesInNewPage = true;
pdf1.Save("test.pdf");

Hello Jon,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

For information on converting Tiff file into Pdf, please visit Use Image from Local Disk and incase the you are facing any problem while converting the Tiff to Pdf, please share the resource file so that we can test the issue at our end. Please make sure you are using the latest version of Aspose.Pdf. You can download the latest hotfix for Aspose.Pdf from 145747.

Thanks, I did find that and was able to create pdfs from tiffs but here is my problem. I have multi page tiff files from an old imaging system when scanning paper was mainstream…some of the tiff files have pages that are portrait and landscape, letter and legal size. When running one of these tiff files thru the sample code, the pdf that was created was all letter portrait and the landscape images were getting cut off. Is there a way to auto size (so to speak) the images so the correct page orientation is used?

Hello Jon,

Please refer to Set Page Size and Margins and incase you still face any problem, please share the resource Tiff file so that we can test the issue at our end. For more information you may also consult PageSetup and PageSize.

Applied latest hotfix and reran the code. The output pdf is also attached. First page is cutoff cause it is landscape/legal size and the second page which is portrait/letter is getting stretched for some reason.



How can I get the size information from each page of the image (via your api) prior to setting the margins, etc. in the pdf?



FYI - the original sample code is included in the original post.

Hi,

Please refer to the following code to get the size of each frame in the TIFF:

Bitmap b = new Bitmap("d:/temp/test.tif");

int total = b.GetFrameCount(FrameDimension.Page);

for(int j = 0; j < total; j++)
{
b.SelectActiveFrame(FrameDimension.Page, j);
float width = b.Width;
float height = b.Height;
Console.WriteLine(width.ToString() + " * " + height.ToString());
}