Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Creating a multi page PDF from a multipage TIFF |
Post Reply |
Author | |
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(1)
Posted: 01 Feb 12 at 9:06AM |
Here is some code that correctly imports and scales pages from a multipage TIFF image and creates a multipage PDF file. NOTE : ImageWidth and ImageHeight return the size of the image in pixels, not points, so we must calculate the correct page size by extracting the DPI from the image. Andrew. private void AddImageFromFile_Click(object sender, EventArgs e) { openFileDialog1.Filter = "TIFF Files|*.tif"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { QP.NewDocument(); int pages = QP.GetImagePageCount(openFileDialog1.FileName); if (pages == 0) pages = 1; for (int i=1;i<=pages;i++) { if (i != 1) QP.NewPage(); int id = QP.AddImageFromFile(openFileDialog1.FileName, i); QP.SelectImage(id); int dpix = QP.ImageHorizontalResolution(); int dpiy = QP.ImageVerticalResolution(); if (dpix == 0) dpix = 72; if (dpiy == 0) dpiy = 72; double ImageWidthInPoints = (double)QP.ImageWidth() / dpix * 72.0; // assumming dpi units double ImageHeightInPoints = (double)QP.ImageHeight() / dpiy * 72.0; QP.SetPageDimensions(ImageWidthInPoints, ImageHeightInPoints); QP.SetOrigin(1); QP.DrawImage(0, 0, ImageWidthInPoints, ImageHeightInPoints); } QP.SaveToFile("out.pdf"); QP.RemoveDocument(QP.SelectedDocument()); } } |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store