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
 TImageEnMIO.Params[].PDF_PaperSize
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Elemental

USA
56 Posts

Posted - Feb 24 2015 :  16:23:11  Show Profile  Reply
I just discovered that TImageEnMIO.SaveToStreamPDF relies on the options set in the Params property. The param that is alarming my users is PDF_PaperSize. When I don't set any values, the exported PDF has large bottom margins for a letter-size document on a 8.26 x 11.69 piece of paper, which is undesirable. As a programmer, I do not know the page size in exact inches of the scanned document from long ago. Nor do I want to ask the user this information when he or she exports it. If ImageEn exports a PDF, I want it to choose the right size for the image's pixel size automatically. Our system has images of all sizes, from postcards to plats. What should I do to export the image correctly, without assuming or asking what the page size is?

xequte

38610 Posts

Posted - Feb 24 2015 :  20:21:24  Show Profile  Reply
PDF_PaperSize is just a shortcut property to PDF_PaperWidth and PDF_PaperHeight:

http://www.imageen.com/help/TIOParamsVals.PDF_PaperSize.html

Which sets the size of the page in "Adobe PDF points" (where a point is 1/72 inch).

The PDF format standard requires you to specify an output size.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Elemental

USA
56 Posts

Posted - Feb 25 2015 :  17:17:02  Show Profile  Reply
I know what the properties mean and I understand they're necessary. But my ImageEn program could be holding a little document or a very large one, and I don't know how to programmatically pick one. After all, I only know the pixel dimensions and DPI. I would like the ImageEn object to pick the correct PDF_PaperSize based on the size of the image. Can it automatically do that? If not, how would *I* automatically do that? Or do I really have the user pick the desired document size?
Go to Top of Page

xequte

38610 Posts

Posted - Feb 25 2015 :  18:44:28  Show Profile  Reply
Hi

Well you should be able to calculate it. I.e.

dActualWidth := Params.Width / Params.DpiX;

So:

PDF_PaperWidth := Round( dActualWidth * 72 );


I would consider having an automatic option for this, but as the PDF page size applies to the whole document it would not handle each page having a different size image.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Elemental

USA
56 Posts

Posted - Mar 02 2015 :  11:45:48  Show Profile  Reply
The following solution, modified from your post, worked pretty well on a document with a 6-page document, where 5 of the pages were 8 1/2 x 11 and another was a weird page size:


  StreamedDoc := TMemoryStream.Create;
  try
    for iPageNum := 0 to iemvDocViewer.ImageCount - 1 do
    begin
      iemvDocViewer.MIO.Params[ iPageNum ].PDF_PaperWidth :=
        iemvDocViewer.MIO.Params[ iPageNum ].Width * 72 div
        iemvDocViewer.MIO.Params[ iPageNum ].DpiX;
      iemvDocViewer.MIO.Params[ iPageNum ].PDF_PaperHeight :=
        iemvDocViewer.MIO.Params[ iPageNum ].Height * 72 div
        iemvDocViewer.MIO.Params[ iPageNum ].DpiY;
    end;
    iemvDocViewer.MIO.SaveToStreamPDF( StreamedDoc );
    StreamedDoc.Position := 0;
    StreamedDoc.SaveToFile( DestinationName );
  finally
    StreamedDoc.Free;
  end;


Thank you for the help!
Go to Top of Page

xequte

38610 Posts

Posted - Mar 04 2015 :  20:00:02  Show Profile  Reply
Hi

I did a bit of research into this today. It looks like PDF is quite forgiving to having non-consistent, non-standard page sizes. In fact as the DPI is not used it is best to set it as follows:

  StreamedDoc := TMemoryStream.Create;
  try
    for iPageNum := 0 to iemvDocViewer.ImageCount - 1 do
    begin
      iemvDocViewer.MIO.Params[ iPageNum ].PDF_PaperWidth := 
        iemvDocViewer.MIO.Params[ iPageNum ].Width;
      iemvDocViewer.MIO.Params[ iPageNum ].PDF_PaperHeight :=         
        iemvDocViewer.MIO.Params[ iPageNum ].Height;
    end;
    iemvDocViewer.MIO.SaveToStreamPDF( StreamedDoc );
    StreamedDoc.Position := 0;
    StreamedDoc.SaveToFile( DestinationName );
  finally
    StreamedDoc.Free;
  end;


At any rate, for the next update you can set the page size iepAuto and ImageEn will do this automatically.


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: