Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Extract image |
Post Reply |
Author | |
Quicker
Beginner Joined: 27 Apr 06 Status: Offline Points: 14 |
Post Options
Thanks(0)
Posted: 29 Apr 06 at 5:08AM |
How do I extract images from a certain page of PDF? Many thanks. |
|
swb1
Debenu Quick PDF Library Expert Joined: 05 Dec 05 Location: United States Status: Offline Points: 100 |
Post Options
Thanks(0)
|
An Example to extract images can be found here: http://www.quickpdf.org/forum/forum_posts.asp?TID=376&KW=swb1 |
|
Quicker
Beginner Joined: 27 Apr 06 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
Steve, thank you. Sorry, your example isn't what I was looking for. I need to extract the image from the 5th page of PDF (for example). It is possible? |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Quicker!
Steves' example is what you need. You only have to lay a loop "page by page" around it. You can separate each page and then analyze each page with Steves' code. Best regards, Ingo |
|
Quicker
Beginner Joined: 27 Apr 06 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
Sorry, how can I separate each page? Please give me the example. |
|
swb1
Debenu Quick PDF Library Expert Joined: 05 Dec 05 Location: United States Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Quicker, The problem is that an image is not necessarily “on” a given page. Images are part of the document and typically only a reference to an image is on a given page. This allows the PDF to be more efficient in the storage and display of images, particularly when they are redundant, for example: a company logo on a multiple page invoice. The direct solution to this may be somewhat complicated. You would need to get a list of images and their references and then using GetPageContent you would cross reference the list of image references on the page. This is definitely advance topic and would require pretty good understanding of the PDF specification. I think a function of this sort would make a nice addition to the library but I don’t think that a simple way of doing this exists in the library today. The indirect solution is to separate each page from the document, using ExtractPages, and then, as separate documents, use the code that I supplied. This is not very efficient and will require time and I/O however it should work.
An example to extract pages goes something like this: procedure TForm1.btnExtractPagesClick(Sender: TObject); var PageIndex : integer; FirstName : string; NewDocID : integer; begin qPDF := TiSEDQuickPDF.Create; qPDF.UnlockKey(MY_QDPF_KEY); if OpenDialog1.Execute then begin qPDF.LoadFromFile( OpenDialog1.FileName ); FirstName := copy(OpenDialog1.FileName,1,pos('.pdf',lowercase(OpenDialog1.FileName))); for PageIndex := 1 to qPDF.PageCount do begin qPDF.ExtractPages(PageIndex,1); NewDocID := qPDF.SelectedDocument; qPDF.SaveToFile(FirstName + IntToStr(PageIndex) + '.pdf' ); qPDF.RemoveDocument(NewDocID); end end; qPdf.Free; end;
sb
|
|
Quicker
Beginner Joined: 27 Apr 06 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
Sorry, I don't understand isedQuickPDF's rules well. How many PDF files (or DocID) can it hold? Is this correct: qPDF := TiSEDQuickPDF.Create; qPdf.Free; |
|
swb1
Debenu Quick PDF Library Expert Joined: 05 Dec 05 Location: United States Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Quicker, I suspect that for practical purposes the document capacity of a TiSEDQuickPDF object is unlimited. Memory and processing time are probably the only factors you will need to be concerned with. As far as your code is concerned; my understanding of how QuickPDF works is largely due to trial and error. Your code looks like it ought to work. Try it. If it works - how wrong can it be? If it does not work you may want to try separating the split page and extract images functions into different operations. sb |
|
Quicker
Beginner Joined: 27 Apr 06 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
Steve, am I right thinking that when I call qPDF.RemoveDocument(NewDocID), I release the memory?
|
|
swb1
Debenu Quick PDF Library Expert Joined: 05 Dec 05 Location: United States Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Yes. That I think that is a safe assumption. I have not inspected this code carefully however it appears to be doing the right thing as far cleaning up after itself.
sb |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store