Print Page | Close Window

Convert image (EMF) 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=914
Printed Date: 17 May 24 at 5:12AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Convert image (EMF) to pdf
Posted By: waynefulcher
Subject: Convert image (EMF) to pdf
Date Posted: 24 Jun 08 at 12:18PM
I am trying to convert an EMF to a pdf. I have tried several different draw methods but none seem to work. No matter what I do I end up with a pdf file that has one blank page on it. I stripped out all the error checking code to make it easier to read but I was getting no errors. Can someone look at this code and tell me what I am doing wrong. I am using Delphi 7, iSED version 5.21.
 
 
procedure EMFToPDF(EMFFileName: String) ;
var
  PDFObj: TiSEDQuickPDF;
  ImageID: Integer ;
begin
  PDFObj := TiSEDQuickPDF.Create;
  try
    PDFObj.UnlockKey(PDF_Unlock_Key);
    PDFObj.NewDocument ;
    ImageID := PDFObj.AddImageFromFile(EMFFileName, 0) ;
    PDFObj.SelectPage(1) ;
    PDFObj.SelectImage(ImageID) ;
 
//   My test emf reports that
//   PDFObj.ImageWidth = 5105
//   PDFObj.ImageHeight = 6598
//    PDFObj.DrawImage(1, 1, PDFObj.ImageWidth, PDFObj.ImageHeight) ;

    PDFObj.DrawScaledImage(1, 1, 0.25) ;
    PDFObj.SaveToFile(ChangeFileExt(EMFFileName, '.pdf')) ;
  finally
    PDFObj.Free ;
  end ;
end ;
 
Thanks in advance
wayne



Replies:
Posted By: waynefulcher
Date Posted: 30 Jun 08 at 10:37AM
OK I changed the routine up slightly and made it work for all image types but EMF ( I have not tried TIFFs ). I am wondering now there seems to be only three possible problems:
1. My EMF image file ( I can view in windows just fine )
2. My code ( which works for all other image types )
3. QuickPDF does not work with EMF images.
Can anyone else or has anyone else get/got this to wotk with an EMF?
 
procedure ImageToPDF(ImageFileName: String) ;
var
  PDFObj  : TiSEDQuickPDF;
  DocID   : Integer ;
  ImageID : Integer ;
  W, H    : Double ;
begin
  PDFObj := TiSEDQuickPDF.Create;
  try
    PDFObj.UnlockKey(PDF_Unlock_Key);
    DocID := PDFObj.NewDocument ;
    PDFObj.SelectDocument(DocID) ;
    PDFObj.SelectPage(1) ;
    ImageID := PDFObj.AddImageFromFile(ImageFileName, 0) ;
    PDFObj.SelectImage(ImageID) ;
    if (PDFObj.ImageWidth > PDFObj.PageWidth) or
       (PDFObj.ImageHeight > PDFObj.PageHeight) then begin
     W := PDFObj.PageWidth ;
     H := PDFObj.PageHeight ;
   end
   else begin
     W := PDFObj.ImageWidth ;
     H := PDFObj.ImageHeight ;
   end ;
    PDFObj.FitImage(1, PDFObj.PageHeight-80, W, H, 1, 1, 0) ;
    PDFObj.SaveToFile(ChangeFileExt(ImageFileName, '.pdf')) ;
  finally
    PDFObj.Free ;
  end ;
end ;



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