Print Page | Close Window

Delphi 2007 - Convert multipage TIFF file to PDF

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2532
Printed Date: 05 May 25 at 8:36AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Delphi 2007 - Convert multipage TIFF file to PDF
Posted By: janigorse
Subject: Delphi 2007 - Convert multipage TIFF file to PDF
Date Posted: 14 Feb 13 at 1:57PM
Code below converts my TIFF file to PDF. But when I open the PDF with Acrobat, scrolling to particular page (sometimes page 4, on the other file page 2 for example) shows an Error on page
message. Can you point me to direction where can I look for a solution?

procedure TForm1.ConvertTiffToPdf(inputImagePath: String; outputFilePath: String);
var
  page, pages, id, UnlockResult, result, dpix, dpiy, docid: Integer;
  imageWidthInPoints, imageHeightInPoints: Double;
  pdfLib: TDebenuPDFLibrary0913;
begin

  pdfLib := TDebenuPDFLibrary0913.Create;
  pdfLib.UnlockKey('jn3343ac9ko4yt4gj7ak5z34y');
    
  docid := pdfLib.NewDocument;
  pdfLib.SetPDFAMode(2);
  pages := pdfLib.GetImagePageCount(inputImagePath);

  if pages = 0 then pages := 1;

  for page := 1 to pages do
  begin

      if page <> 1 then pdfLib.NewPage;

      id := pdfLib.AddImageFromFile(inputImagePath, page);
      pdfLib.SelectImage(id);
      dpix := pdfLib.ImageHorizontalResolution;
      dpiy := pdfLib.ImageVerticalResolution;

      if dpix = 0 then dpix := 72;
      if dpiy = 0 then dpiy := 72;

      imageWidthInPoints := pdfLib.ImageWidth / dpix * 72.0;
      imageHeightInPoints := pdfLib.ImageHeight / dpiy * 72.0;

      pdfLib.SetPageDimensions(imageWidthInPoints, imageHeightInPoints);
      pdfLib.SetOrigin(1);
      pdfLib.DrawImage(0, 0, imageWidthInPoints, imageHeightInPoints);

  end;
    
  pdfLib.SaveToFile(outputFilePath);
  pdfLib.RemoveDocument(docid);
    
  pdfLib.Free;

end;



Replies:
Posted By: AndrewC
Date Posted: 18 Feb 13 at 7:04AM

Which version of QPL are you using ?

Is the TIFF file a colour LZW TIFF image ?

Andrew.


Posted By: Ingo
Date Posted: 18 Feb 13 at 1:38PM
Hi Andrew!
 
It's 9.13 ;-)
 
Cheers, Ingo



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk