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!
Split a document and store it in a stream in Delph |
Post Reply |
Author | |
pmaltais
Beginner Joined: 14 Dec 10 Location: 404 Status: Offline Points: 8 |
Post Options
Thanks(0)
Posted: 10 Jan 11 at 9:33PM |
Hi,
I need to split a PDF document bot I don't want to generate intermediate files. The resulting documents are stored in a database blob field using a MemoryStream. Thanks
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
Have a look in the online-reference here: http://www.quickpdflibrary.com/help/quickpdf/FunctionGroups.php These two chapters should be interest regarding your question: http://www.quickpdflibrary.com/help/quickpdf/DocumentManipulation.php http://www.quickpdflibrary.com/help/quickpdf/PageManipulation.php Cheers, Ingo |
|
Paddy
Beginner Joined: 24 Mar 10 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
If you use the ExtractPageRanges function then you can get the split / extract pages into memory and then save the resulting new document to your database using the SteamToStream function if you're using Delphi or the SaveToVariant function if you're using the ActiveX edition or the SaveToString function if you're using the DLL edition. That should do the trick.
|
|
pmaltais
Beginner Joined: 14 Dec 10 Location: 404 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
Ok I get it.
When you extract pages from document A. It creates document B. Do pages extracted from document A are deleted from that document or just copied to the new one (B)? Thanks
|
|
pmaltais
Beginner Joined: 14 Dec 10 Location: 404 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
Hi! Here's a function I call to SPLIT a document conained in a TMemoryStream property of a custom maid object. The object is to be split at page iFromPage. It works well as long as there's more than 2 pages in the document. Otherwise, the resulting splitted 2 documents only hava a blank page in it. Any idea on what's wrong with my code? Is there a better solution? Thanks function TDocumentService.SplitPDFDocument(oDocument : TDocument; iFromPage : integer) : TDocument; var iStatus: Integer; myPDFLibCtrl: TQuickPDF0722; iSubDocumentID: Integer; oNewDocument: TDocument; begin // Init. myPDFLibCtrl := nil; oNewDocument := nil; // Created by the CopyToNewDocument function iStatus := 0; if Assigned(oDocument) then begin try // Load Library myPDFLibCtrl := TQuickPDF0722.Create(); iStatus := myPDFLibCtrl.UnlockKey(LIC_QUICK_PDF_LIB); if (iStatus <> 0) then begin // Load document stream from custom document object into control // memStream is a property of type TMemoryStream oDocument.memStream.Seek(0, soFromBeginning); while not (oDocument.fileStream.Position = 0) do; myPDFLibCtrl.LoadFromStream(oDocument.memStream); // Save second part to new document iSubDocumentID := myPDFLibCtrl.ExtractPages(iFromPage, myPDFLibCtrl.PageCount); myPDFLibCtrl.SelectDocument(iSubDocumentID); oNewDocument := CopyToNewDocument(oDocument); myPDFLibCtrl.SaveToStream(oNewDocument.memStream); oNewDocument.numberOfPages := myPDFLibCtrl.PageCount; // Reload document object to process first part oDocument.fileStream.Seek(0, soFromBeginning); while not (oDocument.memStream.Position = 0) do; myPDFLibCtrl.LoadFromStream(oDocument.memStream); // Save pages from first part back into original document iSubDocumentID := myPDFLibCtrl.ExtractPages(1, iFromPage - 1); myPDFLibCtrl.SelectDocument(iSubDocumentID); myPDFLibCtrl.SaveToStream(oDocument.memStream); oDocument.numberOfPages := myPDFLibCtrl.PageCount; end else begin ShowMessage('Quick PDF Library: Invalid licence.'); end; except on E: Exception do ShowMessage(E.Message); end; // Cleanup FreeAndNil(myPDFLibCtrl); end; Result := oNewDocument; end; |
|
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