I've made a small app in C# which converts PDF files to PDF/A with the Adobe Acrobat SDK.
I've used the SaveAs
JavaScript function, included in the SDK, this way:
var pdfDocument = new AcroPDDoc();
pdfDocument.Open(fileInfo.FullName);
object pdfJavascriptObject = pdfDocument.GetJSObject();
Type jsType = pdfJavascriptObject.GetType();
// FinalExtension is either jpg or pdf (depends of convId)
var outputFileName = fileInfo.Name.Replace(fileInfo.Extension, "." + finalExtension);
var finalFullName = Path.Combine(outputFolderPath, outputFileName);
// AdobeConvId is either com.callas.preflight.pdfa either com.adobe.acrobat.jpeg
object[] saveAsParam = { finalFullName, adobeConvId, string.Empty, false, false };
// Use Javascript Object SaveAs Method
jsType.InvokeMember(StringConstants.AcrobatSaveAsMethod
, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance
, null
, pdfJavascriptObject
, saveAsParam
, CultureInfo.InvariantCulture);
pdfDocument.Close();
It worked fine with Adobe Acrobat Professional X, but now I have to use Adobe Acrobat Professional XI/DC. I've upgraded the DLL of the SDK but it does not work.
There is a "progression" message which blinks as if there were tons of documents to convert and the process never ends.
However, this code works fine when I convert to JPG file (same code just changing the convId
).
Do you know what I can do from there?...
If the "SaveAs" method is a NoGo, I've heard of preflights, but I don't know how to use them from C# code.