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
 Saving image as PDF

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 - Oct 27 2022 : 17:16:03
I use a TImageEnIO to create screenshots with IEIO.CaptureFromScreen.

Then I save it as a PDF with IEIO.SaveToFile(Filename.pdf).

Currently, the image is placed on top of an A4 page, with the lower part of the page remaining empty.

Is it possible to have the PDF page the same size as the image without empty space outside of the image?

UPDATE: If I use: IEIO.Params.PDF_PaperSize := iepAuto; then the created PDF pages have a lot of empty space around the image. But I need the PDF to have no empty space around the image - a kind of "PDF-AutoSize" (maybe with a configurable margin). How to achieve this?

When using iepAuto then this is how the PDF from a Windows Notepad window screenshot looks in Windows File Explorer Preview:



Please note the empty space around the image.

4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Oct 30 2022 : 20:18:23
Hi

Just to clarify a few points:
- PDF_PaperLayout has no effect if PDF_PaperSize=iepAuto
- iepAuto only matches the size to the image, it is not any best-fit standard size (e.g. landscape A4)
- From the next beta the string value of iepAuto will be a localized version of "Automatic"


Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Oct 28 2022 : 04:03:36
I have now created a ComboBox to let the user decide the PDF PaperSize:

var a: TIOPDFPaperSize;
  // Fill combobox with available PDF paper sizes:
  ComboBoxPdfPaperSizes.Clear;
  for a := Low(TIOPDFPaperSize) to High(TIOPDFPaperSize) do
  begin
    var ThisPaperSizeStr := iepdf.IEPaperSizeToStr(a);
    if ThisPaperSizeStr <> '' then // exclude the 'Unknown' PaperSize
      ComboBoxPdfPaperSizes.Items.Add(ThisPaperSizeStr);
  end;


This is how it looks in my App:



Then, at run-time I select "A4" PaperSize in the Combobox;

Then I save the screenshot as PDF:

IEIO.Params.PDF_PaperSize := IEStrToPaperSize(ComboBoxPdfPaperSizes.Text); 
if IEIO.IEBitmap.Height > IEIO.IEBitmap.Width then
  IEIO.Params.PDF_PaperLayout := ielPortrait
else
  IEIO.Params.PDF_PaperLayout := ielLandscape;
IEIO.SaveToFile(FileName.pdf);


The created PDF file is 297 x 209,9 mm. And this is how it looks in the PDF Viewer:



If I comment out the PDF Layout part:

{if IEIO.IEBitmap.Height > IEIO.IEBitmap.Width then
  IEIO.Params.PDF_PaperLayout := ielPortrait
else
  IEIO.Params.PDF_PaperLayout := ielLandscape;}


...then the created PDF file is still 209,9 x 297 mm, but it looks totally different in the PDF Viewer (because the default Layout is ielPortrait):



This seems almost correct because A4 is 210 x 297 mm or 297 x 210 mm, respectively.

So setting the PDF Layout with the above method gives correct results.

Also, when printed out on an A4 paper sheet, setting the Layout with this method results in a more efficient paper usage.

BTW, when using the "Auto" (iepAuto) item in the Combobox, the PDF size of the Notepad screenshot results in 155,6 x 105,1 mm - which is smaller than A4.
PeterPanino Posted - Oct 28 2022 : 00:16:54
Hi Nigel

I now use this logic:

IEIO.Params.PDF_PaperSize := iepAuto;
if IEIO.IEBitmap.Height > IEIO.IEBitmap.Width then
  IEIO.Params.PDF_PaperLayout := ielPortrait
else
  IEIO.Params.PDF_PaperLayout := ielLandscape;


Now in the Windows Preview Handler (which is a custom one from PDF-XChange) I have set the Preview Size to FITWIDTH:



The Windows Thumbnail Handler from PDF-XChange (in DOpus) shows this:



That's perfect.
xequte Posted - Oct 27 2022 : 23:15:03
Hi Peter

Does this happen even if IEIO.Params.PDF_PaperLayout is ielLandscape?



Nigel
Xequte Software
www.imageen.com