use Xchange SDK in service

PDF-XChange Editor SDK for Developers

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.
chavas
User
Posts: 141
Joined: Tue Mar 15, 2016 12:21 pm

use Xchange SDK in service

Post by chavas »

Hi,

We would like to use PDF-Xchange SDK in a service to optimize PDFs. I have the following code for that-
Dim fsInst As PDFXEdit.IAFS_Inst = CType(Inst.GetExtension("AFS"), PDFXEdit.IAFS_Inst)
Dim impPath As PDFXEdit.IAFS_Name = fsInst.DefaultFileSys.StringToName(outputpath)
'' //We save it on disk
doc.CoreDoc.WriteTo(impPath)
Dim pxcInst As PDFXEdit.IPXC_Inst = CType(Inst.GetExtension("PXC"), PDFXEdit.IPXC_Inst)
Dim resDoc As PDFXEdit.IPXC_Document = pxcInst.OpenDocumentFrom(impPath, Nothing)
'' //Then pass it to the optimization operation
input.Add().v = resDoc
Dim options As PDFXEdit.ICabNode = op.Params.Root("Options")
Dim images As PDFXEdit.ICabNode = options("Images")
images("Enabled").v = True
images("ReducedOnly").v = True
Dim comp As PDFXEdit.ICabNode = images("Comp")
comp("Color.JPEGQuality").v = 0
comp("Grayscale.JPEGQuality").v = 0
op.Do()
'' //And save the optimized document again to the same file
resDoc.WriteTo(impPath)
I would like to know if it is possible to use the control without keeping an instance of the control on the window and what steps should be taken to ensure no memory leak. Our service would be processing PDF files in a loop. We would load the plugin (PDFOptimizer.pvp) when the service starts.

Rgds
Charu
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: use Xchange SDK in service

Post by Sasha - Tracker Dev Team »

Hello Charu,

Well the steps would be to Init the IPXV_Inst once when service starts and Shutdown it when the service is being destroyed. To avoid leaks - use C++ - there you would manage all of the memory by yourself and you can guarantee that no leaks are being left.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ