ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 MIO.Savetopdf
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

tchant

Australia
2 Posts

Posted - May 06 2015 :  03:08:13  Show Profile  Reply
Hi ALl,

I'm a little new to this but any help would be appreciated , I'm using Delphi 2009 and ImageEn Ver 6.0.0, The bit of code below take an input *.tif file ( multi page in most cases and All I want to do is save it to a pdf file ,the pdf ends up being huge so the compression is cleary not being applied. where have I gone wrong in this. Appreciate any help guys / girls.

function TForm3.fCreatePDFFile(fInFile,fOutFile: String): boolean;
const
  PDFCompression: array[0..3] of TIOPDFCompression = (ioPDF_RLE, ioPDF_G3FAX2D, ioPDF_G4FAX, ioPDF_JPEG);

var iPageNum : Integer;
    StreamedDoc : TMemoryStream;
begin

  StreamedDoc := TMemoryStream.Create;
  ScanImg.Clear;
  ScanImg.MIO.LoadFromFileTIFF(fInFile) ;
  try
    for iPageNum := 0 to ScanImg.ImageCount - 1 do
    begin
      ScanImg.MIO.Params[iPageNum].PDF_Creator     := 'Company X';
      ScanImg.MIO.Params[iPageNum].PDF_PaperSize   :=  IEStrToPaperSize('A4', iepA4);
      ScanImg.MIO.Params[iPageNum].PDF_Compression := PDFCompression[0];
    end;
    ScanImg.MIO.SaveToStreamPDF(StreamedDoc);
    StreamedDoc.Position := 0;
    StreamedDoc.SaveToFile(fOutFile);
  finally
   StreamedDoc.Free;
   ScanImg.Clear;
  end;
end;



Trevor Chant

xequte

38514 Posts

Posted - May 07 2015 :  19:26:48  Show Profile  Reply
Hi Trevor

How large are the images you are adding to the PDF? You might want to resample them to the page size, e.g.

...
  ScanImg.LockUpdate;
  for iPageNum := 0 to ScanImg.ImageCount - 1 do
  begin
    ScanImg.MIO.Params[iPageNum].PDF_Creator     := 'Company X';
    ScanImg.MIO.Params[iPageNum].PDF_PaperSize   :=  IEStrToPaperSize('A4', iepA4);
    ScanImg.MIO.Params[iPageNum].PDF_Compression := PDFCompression[0];
    ScanImg.SelectedImage := iPageNum;
    ScanImg.Proc.Resample(ScanImg.MIO.Params[iPageNum].PDF_PaperWidth, 
                          ScanImg.MIO.Params[iPageNum].PDF_PaperHeight,
                          rfLanczos3, True);
  end;
  ScanImg.UnlockUpdate;
...


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: