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
 Problem importing tif, exporting PDF
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

lorife

Italy
9 Posts

Posted - Jan 04 2022 :  12:13:11  Show Profile  Reply
Hello,
I'm trying your ImageEN DEMO. I need to open a PDF, and extract first 2 pages to another pdf.
This is what i'm doing:

IEGlobalSettings().RegisterPlugIns([ iepiPDFium ]);
iev_IN.PdfViewer.Enabled := True;

iev_IN.ClearAll;

iev_IN.IO.Params.ImageIndex := 0;
iev_IN.IO.LoadFromFile('c:\temp\IN.pdf');
iemv_OUT.AppendImage;
iemv_OUT.SetImage(iemv_OUT.SelectedImage, iev_IN.IEBitmap);

iev_IN.IO.Params.ImageIndex := 1;
iev_IN.IO.LoadFromFile('c:\temp\IN.pdf');
iemv_OUT.AppendImage;
iemv_OUT.SetImage(iemv_OUT.SelectedImage, iev_IN.IEBitmap);

iemv_OUT.MIO.SaveToFile('c:\temp\OUT.pdf');


it works, but the resulting file is all blurried, not sharp.
If i load a tif and export to PDF the resulting file is perfect.

do you have any idea on why?
thank you

xequte

6666 Posts

Posted - Jan 04 2022 :  14:59:31  Show Profile  Reply
Hi

A better method would be to use ExportPages:

https://www.imageen.com/help/TIEPdfViewerInteraction.ExportPages.html

Otherwise this output method should work better:

// Add current page to a TImageEnMView
idx := ImageEnMView1.AppendImage( 0,0,ie24RGB );
bmp := ImageEnMView21.GetTIEBitmap( idx );
ImageEnView1.PdfViewer.DrawTo( bmp );
ImageEnMView1.ReleaseBitmap( idx, True );



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 05 2022 :  02:43:24  Show Profile  Reply
Hello,
thank you for writing back.


I understand ExportPages might work better but I simplified a little the logic.
In reality I need to analyze each page and then decide, also I do not know the format IN and OUT so I was looking for something that could work for each format. ExportPages is very PDF specific.

My original code was format independent that's why I liked it.
Do you think you can fix the problem in a future version?

Thank you

Go to Top of Page

xequte

6666 Posts

Posted - Jan 05 2022 :  04:44:55  Show Profile  Reply
Hmm, I'm away from the office until Friday, so I cannot check.

Please try:

bmp := TIEBitmap.create();
ImageEnView1.PdfViewer.DrawTo( bmp );
ImageEnMView1.AppendImage( bmp );
bmp.Free;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 05 2022 :  05:40:03  Show Profile  Reply
Like this it works but it's still not focused.

bmp := TIEBitmap.create();
iev_IN.PdfViewer.DrawTo(bmp);
iemv_OUT.AppendImage(bmp);

iev_IN.PdfViewer.SaveToFile('c:\temp\a.pdf');
bmp.Write('c:\temp\b.pdf');
iemv_OUT.MIO.SaveToFile('c:\temp\c.pdf');

bmp.Free;


what is strange is that a.pdf is focused (and 18MB) while b.pdf and c.pdf are not focused (and 1.4 MB)
Go to Top of Page

xequte

6666 Posts

Posted - Jan 07 2022 :  00:36:51  Show Profile  Reply
Hi

You can set the current frame using:

https://www.imageen.com/help/TImageEnMView.SelectedImage.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 07 2022 :  02:03:41  Show Profile  Reply
But i don't have problems with the current frame, my problem is that pdf is blurred. The file is correct but not focused.
Go to Top of Page

xequte

6666 Posts

Posted - Jan 08 2022 :  16:37:15  Show Profile  Reply
Sorry, *focused* has two meanings here, and I got the wrong one.

You can email me for an update that extends DrawTo with size parameters.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 12 2022 :  11:57:30  Show Profile  Reply
Hello I did write you, did you get the mail?
Go to Top of Page

xequte

6666 Posts

Posted - Jan 12 2022 :  20:59:15  Show Profile  Reply
Hi Lorenzo

Yes, I emailed you back to find your order name or email address, because I could find an order for you. If you are just using a trial, please wait for the next update.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 19 2022 :  03:38:36  Show Profile  Reply
Hello,
I did write you back on the mail because I do not see the new option; also if you could guide me on the use of it.
I need to export to A4 size, and shrink just bigger images while keeping proportions.
Go to Top of Page

xequte

6666 Posts

Posted - Jan 19 2022 :  20:51:24  Show Profile  Reply
Sorry, I had a brain fart. Let me email you the latest source code.

You can use the new parameters for DrawTo():

procedure DrawTo(Bitmap: TIEBitmap; Width: Integer = -1; Height: Integer = -1; MaintainAR: Boolean = True); overload;
procedure DrawTo(Bitmap: TBitmap; Width: Integer = -1; Height: Integer = -1; MaintainAR: Boolean = True); overload;
procedure DrawTo(Canvas: TCanvas; Width: Integer = -1; Height: Integer = -1; MaintainAR: Boolean = True); overload;



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 20 2022 :  05:17:52  Show Profile  Reply
Hello,
thanks. I tried the beta with this code:

iev_IN.IO.Params.ImageIndex := 0;
iev_IN.IO.LoadFromFilePDF('c:\temp\OBR\S30C-921122015230.pdf');
bmp := TIEBitmap.create();
iev_IN.PdfViewer.DrawTo( bmp, 1024, 768, true );
iemv_OUT.AppendImage( bmp );
bmp.Free;
iemv_OUT.MIO.SaveToFile('c:\temp\OUT.pdf');


but the output file is empty.
I also tried this:

iev_IN.PdfViewer.DrawTo( bmp, -1, -1, true );


or this:

iev_IN.PdfViewer.DrawTo( bmp );


but no luck.
Also, what should I use as the new params? destination size will be A4 so I need bigger images to shrink to A4 (but keeping proportions).

thanks
Go to Top of Page

xequte

6666 Posts

Posted - Jan 20 2022 :  15:23:14  Show Profile  Reply
1. Please enable the PDF viewer:

ImageEnView1.PdfViewer.Enabled := True;


2. That is not a recommended way to create a PDF file. It will convert a PDF document (with images and text, etc) to a PDF file containing images.

Please see the notes at:

https://www.imageen.com/help/File_Formats.html


3. Mostly ImageEn only deals with images, so "A4" is not relevant. You can create an image of pixel size of A4 (i.e. considering size and DPI), but how it would display depends on the viewer.

For PDF files, see: https://www.imageen.com/help/TIOParams.PDF_PaperSize.html



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 20 2022 :  15:44:57  Show Profile  Reply
My problem is that i receive pdf coming from a scanner so each page is an image. I need to analyze each page for barcodes and then apply some logics. If correct i need to add the page to another pdf..but as the page (image) in the original pdf is quite big i need to shrink it so that I can have a smaller file.
Also the new pdf must be A4 so i don't want to shrink the image too much.

That's why I need to treat it as image and not as pdf.

Does it make any sense?

Thank you

Go to Top of Page

xequte

6666 Posts

Posted - Jan 20 2022 :  19:51:52  Show Profile  Reply
OK, then in principal that should work. Just set the PDF_PaperSize to iepA4 and use DuplicateCompressionInfo if the TImageEnMView has multiple pages:

ImageEnMView1.MIO.Params[0].PDF_PaperSize := iepA4;
ImageEnMView1.MIO.Params[0].PDF_ImageOptions := [iepioShrinkOnly, iepioCentered];
ImageEnMView1.MIO.DuplicateCompressionInfo(TRUE);
ImageEnMView1.MIO.SaveToFilePDF('d:\test.pdf');


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

lorife

Italy
9 Posts

Posted - Jan 21 2022 :  05:03:40  Show Profile  Reply
Hello,
thanks.

Please don't hate me...

so I tried:
iev_IN.PdfViewer.DrawTo( bmp, -1, -1, true );

and the output file was in bad quality.
then I tried:
iev_IN.PdfViewer.DrawTo( bmp, 2000, 2000, true );

and the quality is better but still a little blurried.
So I'm asking:
1. If I leave -1 shouldn't it use the maximum quality
2. what numbers should i write for height and width to achieve a good quality?
Please note i'm still not compressing anything, the only code is this:

IEGlobalSettings().RegisterPlugIns([ iepiPDFium ]);
iev_IN.PdfViewer.Enabled := True;
iev_IN.IO.Params.ImageIndex := 0;
iev_IN.IO.LoadFromFilePDF('c:\temp\OBR\S30C-921122015230.pdf');
bmp := TIEBitmap.create();
iev_IN.PdfViewer.DrawTo( bmp, 2000, 2000, true );
iemv_OUT.AppendImage( bmp );
bmp.Free;
iemv_OUT.MIO.SaveToFile('c:\temp\OUT.pdf');


thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: