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
 PDF to picture( TParallel.For and For)

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
foxdingding Posted - Jan 21 2022 : 04:49:28
PDF to picture( TParallel.For)

Some pictures were found to be blank

Can I use it like this?



Var
    PDFView: TImageEnView;
.....
Begin
  PDFView.PdfViewer.AllowFormEditing := false;//True;
  PDFView.PdfViewer.Enabled := True;
  ImageEnMView1.AttachedImageEnView := PDFView;
.....
  PDFView.PdfViewer.Enabled := True;
  try
    PDFView.IO.LoadFromFile( OpenPDF.Filename );
    Self.Hint:=OpenPDF.Filename;

    PDFView.MouseInteractGeneral := [ miScroll, miZoom ];
  except
    on e:Exception do
      MessageDlg( 'Error encountered loading PDF file: ' + e.message, mtError, [ mbOK ], 0 );
  end;

..........

            tmpiTask:=TTask.Run(
              procedure
              Begin
                TParallel.For(0,ImageEnMView1.ImageCount - 1,
                  procedure (Hidx: Integer)
                  var
                    tmpIENView:TImageEnView;
                    tmpFileName_Back,
                    tmpFileName_Do:String;
                  begin
                    
tmpFileName_Do :=...

                    tmpIENView:=TImageEnView.Create(Nil);
                    Try
                     
                      ImageEnMView1.CopyToIEBitmap( Hidx, tmpIENView.IEBitmap,TRUE );

                      Try
                        tmpIENView.IO.SaveToFileIEN(tmpFileName_Do);
                      Except
                        TInterlocked.Increment(TInterlocked_Err_Count);
                      End;
                    Finally
                      tmpIENView.Free;
                    End;
                  end);
              End);

......

TTask.WaitForAll([tmpiTask]);
......



Some pictures were found to be blank









10   L A T E S T    R E P L I E S    (Newest First)
foxdingding Posted - Jan 26 2022 : 01:29:30
20% faster
Old:Operating time:51.635 s
New:Operating time:44.411 s


New Code

........

       PDFView.LockUpdate;
       PDFView.LockPaint;
       Try
         SW:=TStopwatch.StartNew;
         for I := 0 to PDFView.PdfViewer.PageCount-1 do
         Begin
            Self.ProgressBar1.Position:=I;
            Application.ProcessMessages;

            tmpImageEnView.ClearAll;

            PDFView.PdfViewer.PageIndex:=I;
            PDFView.PdfViewer.DrawTo( tmpImageEnView.IEBitmap,
                        MulDiv(PDFView.PdfViewer.PageWidth,300,72),
                        MulDiv(PDFView.PdfViewer.PageHeight,300,72)
                          );
            tmpImageEnView.Update;
........
         End;
         Writeln('Operating time:'+(SW.ElapsedMilliseconds/1000).ToString+'s');
........

       Finally
          PDFView.UnlockUpdate;
          PDFView.UnlockPaint;
      End


Operating time:44.411s
foxdingding Posted - Jan 25 2022 : 21:07:12
yes,TImageEnMView StoreType is ietFastThumb

I will test LoadFromFilePDF/SaveToFileJPEG,today
xequte Posted - Jan 25 2022 : 17:43:12
Hi

Saving to PDF can be done in threads, it is only loading that does not support threading (PDFium does not support it).

I expect the cause of the blank frames in your first post is due to threading. Is your TImageEnMView StoreType ietThumb/ietFastThumb? If so, then ImageEnMView1.CopyToIEBitmap( idx, bmp, TRUE ); forces the TImageEnMView to load the PDF from file (i.e. threading is not possible).

If TImageEnMView StoreType is ietNormal then loading will not occur then and threading can be used, but that would make your initial fill of TImageEnMView much slower.

So I think LoadFromFilePDF/SaveToFileJPEG is the fastest method overall (Unless they are saving most/all of the images in the TImageEnMView).

Nigel
Xequte Software
www.imageen.com
foxdingding Posted - Jan 24 2022 : 23:25:46
YES
xequte Posted - Jan 24 2022 : 22:45:22
OK, so you have PDF pages showing in a TImageEnMView, the user specifies (or selects) indexes of pages to save as images, clicks a button and they are then saved in a batch?

Nigel
Xequte Software
www.imageen.com
foxdingding Posted - Jan 24 2022 : 21:14:14
It's too slow. I want to be faster.
First show all the pages
Then let the user choose
Then convert the selected page.
xequte Posted - Jan 24 2022 : 16:19:55
Why not just load and save each file? Something like:

tempIE := TImageEnView.Create(nil);
try
  tempIE.PdfViewer.Enabled := True;
  for i := 0 to ssFileList - 1 do
  begin
    tempIE.IO.LoadFromFilePDF( ssFileList[i] );
    tempIE.IO.SaveToFileJPEG( ChangeFileExt( ssFileList[i], '.jpeg' );
  end;
finally
  tempIE.Free;
end;


Nigel
Xequte Software
www.imageen.com
foxdingding Posted - Jan 24 2022 : 07:24:08
Quickly convert PDF pages to images.
Is there any good way?
xequte Posted - Jan 23 2022 : 23:28:36
Hi

PDFium should NOT be used in threads.

Can you describe what you are wanting to do?

Nigel
Xequte Software
www.imageen.com
foxdingding Posted - Jan 21 2022 : 04:52:37
PDF to picture( For)

This is OK!
No blank image.
But it's slow!


       tmpImageEnView:=TImageEnView.Create(Nil);
       Try
         for I := 0 to ImageEnMView1.ImageCount-1 do
         Begin
            Application.ProcessMessages;

            tmpImageEnView.ClearAll;
            ImageEnMView1.CopyToIEBitmap(I,tmpImageEnView.IEBitmap,TRUE );
.....            
tmpFileName_Do:=.........
.....
            Try
            
                tmpIENView.IO.SaveToFileIEN(tmpFileName_Do);
            Except
		....
            End;

         End;
       Finally
          tmpImageEnView.Free;
       End;