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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Transforming images to single PDF files

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Aug 24 2017 : 18:47:54
I need to transform a bunch of image files each to single PDF files. So I use this code in a loop:

ThisIEBitmap.Read(fl.Items[i].Path);
ThisIEBitmap.Write('R:\test' + IntToStr(i) + '.pdf');


The created PDF files must meet the following requirements:

• The page orientation of the PDFs must follow the page orientation of the images, i.e. if the image width is larger than the image height then the PDF page orientation must be Landscape and vice-versa.

• The image on the PDF must be centered on the page and there must be a white margin with a fixed size for all PDFs.

• The PDF page dimensions must follow the image dimensions, but the longest dimension (width or height) must have a minimum and a maximum size.

Is this possible?

That's what I tried myself, following the advice in the documentation: "If you set PDF_PaperWidth and PDF_PaperHeight to 0 the page will be output at the size of the image.":

ThisIEBitmap.Read(fl.Items[i].Path);
ThisIEBitmap.Params.PDF_PaperWidth := 0; // EAccessViolation !!!
ThisIEBitmap.Params.PDF_PaperHeight := 0;
ThisIEBitmap.Write('R:\test' + IntToStr(i) + '.pdf');


These are the details of the exception:

Exception:
--------------------------------------------------------------------------------------------------------------
2.2 Address: 01C6697F
2.5 Type : EAccessViolation
2.6 Message: Access violation at address 01C6697F in module 'XYZ.exe'. Write of address 00000548.
2.7 ID : 84D30000
2.11 Sent : 0
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 25 2017 : 15:49:01
Hi Peter

1. No, the code looks line.

2. ImageEn will apply the DPI of the image to the PDF, so for example:

widthInches := 500 / ThisIEBitmap.Params.DPIX;
widthMM := widthInches * 25.4;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
PeterPanino Posted - Aug 25 2017 : 03:46:14
1. I now use the following code which works very well:

ThisIEBitmap := TIEBitmap.Create;
try
  for i := 0 to fl.Items.Count - 1 do
  begin      
     ThisIEBitmap.ParamsEnabled := True;
     ThisIEBitmap.Params.PDF_PaperSize := iepAuto;
     ThisIEBitmap.Read(fl.Items[i].Path);
     ThisIEBitmap.Resample(500, 500, rfHermite, True);
     ThisIEBitmap.Resize(ThisMargin, ThisMargin, ThisMargin, ThisMargin, clWhite);
     ThisIEBitmap.Write('R:\test' + IntToStr(i) + '.pdf');
  end;
finally
  ThisIEBitmap.Free;
end;


Is there anything which must be additionally freed/released in this code to avoid memory leaks?

2. The Resample method is wonderful! Specifically, the following code with both parameter values of 500 results in a PDF with the largest dimension (width or height) to be exactly 194.0 mm:

ThisIEBitmap.Resample(500, 500, rfHermite, True);

Now, to define the values in the Resample method not in Pixel but in resulting mm in the PDF, I could write an interpolation equation. But I am sure that there is already a method to translate the Pixel values into resulting mm?
xequte Posted - Aug 24 2017 : 20:00:04
Hi Peter

You must call:

ThisIEBitmap.ParamsEnabled := True;

Before reading, if you wish to access the Params.


To automatically set the page size, you can call:

ImageEnView1.IO.Params.PDF_PaperSize := iepAuto;

(Same as setting PDF_PaperWidth/PDF_PaperHeight to zero).





Nigel
Xequte Software
www.xequte.com
nigel@xequte.com