Hey guys... this is a follow-up to viewtopic.php?t=39453 and I have been using https://sdkhelp.pdf-xchange.com/vi ... tractPages.
My problem ... I cannot figure out how to export the page to a byte array. I store everything within a SQL Server so I need the page (i.e. the page extracted into a new document) in byte array so I can save it to the SQL Server.
Is there some way I can do the page extraction into a separate document instance? Is there a better way to do this? I have tried the copy version using this approach https://sdkhelp.pdf-xchange.com/vi ... _movePages
but I am still getting stuck trying to get the standalone page object
I am sure I am missing something simple ... any suggestions?
Many Thanks!
-Eric
Extract Specific Page to ByteArray SOLVED
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Extract Specific Page to ByteArray
Hi Eric.
No, you cannot extract just the page object, without a document containing the page.
But you may extract the page to the new document instance via op.document.extractPages operation and with using this option:
extractOp.Params.Root["Options.ExtractPagesAction"].v = 0; // to extract page(s) to new document instance
then call:
extractOp.Do();
then get the new doc instance:
IPXC_Document newDoc = (IUnknown)extractOp.Params.Root["Output"].v;
then save the new doc to the memory stream-object:
// C#
MemoryStream memStream = new MemoryStream();
IStreamWrapper sw = new IStreamWrapper(memStream);
newDoc.WriteTo(sw);
then transfer data from the memStream to your SQL-database.
Cheers.
No, you cannot extract just the page object, without a document containing the page.
But you may extract the page to the new document instance via op.document.extractPages operation and with using this option:
extractOp.Params.Root["Options.ExtractPagesAction"].v = 0; // to extract page(s) to new document instance
then call:
extractOp.Do();
then get the new doc instance:
IPXC_Document newDoc = (IUnknown)extractOp.Params.Root["Output"].v;
then save the new doc to the memory stream-object:
// C#
MemoryStream memStream = new MemoryStream();
IStreamWrapper sw = new IStreamWrapper(memStream);
newDoc.WriteTo(sw);
then transfer data from the memStream to your SQL-database.
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 34
- Joined: Mon May 02, 2022 5:58 pm
Re: Extract Specific Page to ByteArray
I thought I had it working but after lots of testing I realize the Inst class is not generating an output. Here is my code ...
Dim pdfDoc As IPXC_Document
Dim v_Inst As IPXV_Inst = PDFPreview.PDFcntrl.Inst
Dim nID As Integer = v_Inst.Str2ID("op.document.extractPages", False)
Dim inputOperation As IOperation = v_Inst.CreateOp(nID)
inputOperation.Params.Root("Options.ExtractPagesAction").v = 0
Dim input As ICabNode = inputOperation.Params.Root("Input")
input.v = PDFPreview.PDFcntrl.Doc
Dim options As ICabNode = inputOperation.Params.Root("Options")
options("PagesRange.Type").v = "Exact"
options("PagesRange.Text").v = "1"
options("FieldsAction").v = 1 'this will flatten the field values into the PDF
options("CommentsAction").v = 2
options("BookmarksAction").v = 0
options("DeletePages").v = False
options("ExtractPagesAction").v = 1
options("OverwriteAll").v = True
options("FileName").v = "Page 1"
options("OpenFolder").v = False
inputOperation.[Do]()
pdfDoc = CType(inputOperation.Params.Root("Output").v, Object)
It runs without error. the pdf control is displaying the starting document with no problems. I am confident the input.v is referencing a legitimate Doc. any suggestions?
Dim pdfDoc As IPXC_Document
Dim v_Inst As IPXV_Inst = PDFPreview.PDFcntrl.Inst
Dim nID As Integer = v_Inst.Str2ID("op.document.extractPages", False)
Dim inputOperation As IOperation = v_Inst.CreateOp(nID)
inputOperation.Params.Root("Options.ExtractPagesAction").v = 0
Dim input As ICabNode = inputOperation.Params.Root("Input")
input.v = PDFPreview.PDFcntrl.Doc
Dim options As ICabNode = inputOperation.Params.Root("Options")
options("PagesRange.Type").v = "Exact"
options("PagesRange.Text").v = "1"
options("FieldsAction").v = 1 'this will flatten the field values into the PDF
options("CommentsAction").v = 2
options("BookmarksAction").v = 0
options("DeletePages").v = False
options("ExtractPagesAction").v = 1
options("OverwriteAll").v = True
options("FileName").v = "Page 1"
options("OpenFolder").v = False
inputOperation.[Do]()
pdfDoc = CType(inputOperation.Params.Root("Output").v, Object)
It runs without error. the pdf control is displaying the starting document with no problems. I am confident the input.v is referencing a legitimate Doc. any suggestions?
-
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Extract Specific Page to ByteArray SOLVED
your:I am confident the input.v is referencing a legitimate Doc. any suggestions?
options("FileName").v = "Page 1"
options("ExtractPagesAction").v = 1
means: extract specified pages to the new file on the disc with the name "Page 1".
For your case you need to specify the proper value, as I suggested in my previous reply:
options("ExtractPagesAction").v = 0 // to extract page(s) to new document instance
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 34
- Joined: Mon May 02, 2022 5:58 pm
Re: Extract Specific Page to ByteArray
Vasyl -
I have searched your online HELP and there is no place that even references the list of parameters such as "ExtractPagesAction" or "FileName". So I do not know where you think I am going to find the definitions for all of these options. Feel free to send me the links to the these because they do not appear in any searches of https://sdkhelp.pdf-xchange.com
I thought FileName referred to the output name of the document and not the input. I am sorry for wasting your time. I will continue to do my best to avoid posting here without exhaustive research on my side. What links can I follow to get a comprehensive list of all available root parameter settings and/or settings for ICabNode?
-Eric
I have searched your online HELP and there is no place that even references the list of parameters such as "ExtractPagesAction" or "FileName". So I do not know where you think I am going to find the definitions for all of these options. Feel free to send me the links to the these because they do not appear in any searches of https://sdkhelp.pdf-xchange.com
I thought FileName referred to the output name of the document and not the input. I am sorry for wasting your time. I will continue to do my best to avoid posting here without exhaustive research on my side. What links can I follow to get a comprehensive list of all available root parameter settings and/or settings for ICabNode?
-Eric
-
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Extract Specific Page to ByteArray
https://sdkhelp.pdf-xchange.com/vi ... tractPages
- there is link to described Options for this operation:
that jumps to:
https://sdkhelp.pdf-xchange.com/vi ... es_Options
- there is link to described Options for this operation:
that jumps to:
https://sdkhelp.pdf-xchange.com/vi ... es_Options
You do not have the required permissions to view the files attached to this post.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.