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
 Extract the images from a 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
jeffp Posted - Oct 17 2024 : 09:17:58
Is there a way to extract or pull out the images contained in an image PDF file.

For example, we do a lot with scanned documents. So we get a tons of image based PDF files. Sometimes we need to pull out the image, clean it up, and the put the image back in the PDF.

Can this be done?

jp
8   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Nov 05 2024 : 00:31:17
Hmm, your code with the PDF above works fine for me:

procedure TfrmMain.Button3Click(Sender: TObject);
var
  i: Integer;
  B: TBitmap;
  oPDF: TPdfObject;
  FViewer: TImageEnView;
begin
  OpenFile( 'D:\Testing_Multimedia\PDF\ColorTest.pdf' );
  FViewer := ImageEnView1;

  for i := 0 to FViewer.PdfViewer.Objects.Count - 1 do
  begin
    oPDF := FViewer.PdfViewer.Objects[i];
    if (oPDF.ObjectType = ptImage) then
    try
      B := oPDF.GetImage;
      try
        // Result := EN_CleanupBitmap(B, AOpts);
        oPDF.SetImage(B);
        FViewer.PdfViewer.ReloadPage;
      finally
        B.Free;
      end;
    except
      Raise;
    end;
    //break; //NOTE: We are only going to clean if One image on page.
  end;
end;



As do both of the following:

// Reduce the size of the PDF file by lowering the quality of the images (B is a TIEBitmap)
for i := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
begin
  oPDF := ImageEnView1.PdfViewer.Objects[i];
  if (oPDF.ObjectType = ptImage) then
  begin
    B := TIEBitmap.Create();
    try
      if oPDF.GetImage( B ) then
      begin
        B.Resample( 0.5 );
        oPDF.SetImage(B);
       end;
    finally
      B.Free;
    end;
  end;
end;
ImageEnView1.PdfViewer.ReloadPage();

// Same as above but B is a TBitmap (must add iexHelperFunctions to your uses clause for TBitmap.Proc)
for i := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
begin
  oPDF := ImageEnView1.PdfViewer.Objects[i];
  if (oPDF.ObjectType = ptImage) then
  begin
    B := oPDF.GetImage();
    if B <> nil then
    try
      B.Proc.Resample( 0.5 );
      oPDF.SetImage(B);
    finally
      B.Free;
    end;
  end;
end;
ImageEnView1.PdfViewer.ReloadPage();



Are you using ImageEn v13.6.0?

Does it happen with all PDF files you test.

Can you check your version of the iepdf32.dll, by right-clicking it and selecting Properties? It should be v 125.0.6406.0.

Is there any further information you can provide?

Nigel
Xequte Software
www.imageen.com
xequte Posted - Oct 27 2024 : 08:40:32
Thanks, I'll test it once I'm back in the office.

Nigel
Xequte Software
www.imageen.com
jeffp Posted - Oct 26 2024 : 21:06:46
It's a 32bit application. Using Delphi Delphi 11 Version 28.0.48361.3236

jp

attach/jeffp/2024102621719_ColorTest.pdf
xequte Posted - Oct 26 2024 : 17:31:40
OK, thanks. Can you email me a sample PDF where it occurs. 32 or 64bit application? What version of Delphi?

Nigel
Xequte Software
www.imageen.com
jeffp Posted - Oct 26 2024 : 09:25:37
Yes, it still fails even if you just get the Bitmap and immediately re-set it.

jp
xequte Posted - Oct 25 2024 : 18:14:33
Hi Jeff

I'll need to investigate that. If you comment out the line:

// Result := EN_CleanupBitmap(B, AOpts);

(i.e. set the same bitmap, you extract).

Does it still fail? If not, what occurs in EN_CleanupBitmap()?

Nigel
Xequte Software
www.imageen.com
jeffp Posted - Oct 25 2024 : 14:29:48
I can pull the image out of the page, but it's not letting me put the image back in the page. I'm trying to pull an image out of a PDF page, clean it up, and then put it right back in. Here's my code.

It's crashing on the line: oPDF.SetImage(B);

function TEnDoc.CleanupPDFPage(AOpts: TRecCleanupOptions; APageNo: Integer = 0): TRecCleanupResult;
var
  i: Integer;
  B: TBitmap;
  oPDF: TPdfObject;
begin
  Result := TRecCleanupResult.Create;
  if (AOpts <> []) then
  begin
    SelectPage(APageNo);
    if (CurrentPage > 0) then
    begin
      for i := 0 to FViewer.PdfViewer.Objects.Count - 1 do
      begin
        oPDF := FViewer.PdfViewer.Objects[i];
        if (oPDF.ObjectType = ptImage) then
        try
          B := oPDF.GetImage;
          try
            Result := EN_CleanupBitmap(B, AOpts);
            oPDF.SetImage(B);
            FViewer.PdfViewer.ReloadPage;
          finally
            B.Free;
          end;
          FModified := True;
        except  end;
        break; //NOTE: We are only going to clean if One image on page.
      end;
    end;
  end;
end;


jp
xequte Posted - Oct 17 2024 : 17:40:50
Yes, please see the image example at:

http://www.imageen.com/help/TIEPdfViewer.Objects.html

Nigel
Xequte Software
www.imageen.com