Updating PDF Producer throws an exception
Posted: Thu May 18, 2017 9:11 pm
Hi,
I am having an issue while updating the Producer of a PDF file. I am using Core Api and VB6 and this is happening for a particular set of files.
Following is the code that I am using for this:
The line
fails and goes to the error handler. The Err object shows the error description to be "Automation Error" and the error number is "-2112221168". I close out the document in the error handler block as you can see above.
The issue is that when that happens, my application throws a StackHeap exception after some time randomly. My questions are:
1. Is there a better way to do what I am trying to do here? If yes, can you share some VB6 code that I can use?
2. Is there a way the Core Api can tell me without throwing an exception that I cannot update the producer for a particular file? Any particular property/method that I can call before actually updating the producer?
3. Is there a way that I can cleanup after the exception so that my application does not throw run time heap exceptions after this exception is thrown?
Looking forward to your response.
Regards,
M
I am having an issue while updating the Producer of a PDF file. I am using Core Api and VB6 and this is happening for a particular set of files.
Following is the code that I am using for this:
Code: Select all
Public Function updateProducer(ByRef oCoreApi As clsCoreApi, ByRef pInst As PXC_Inst, sFileName As String, sProducer As String) As Boolean
Dim pDoc As IPXC_Document
On Error GoTo errorOccured
' load pdf file
If Not oCoreApi.loadPdfFile(sFileName, pDoc, pInst) Then
GoTo errorOccured
End If
' update the pdf producer
pDoc.Info.InfoStr(DocInfo_Producer) = sProducer
' save the pdf file
oCoreApi.savePdfFile sFileName, pDoc
Set pDoc = Nothing
updateProducer = True
Exit Function
errorOccured:
If Not pDoc Is Nothing Then
pDoc.Close
Set pDoc = Nothing
End If
updateProducer = False
End Function
Code: Select all
pDoc.Info.InfoStr(DocInfo_Producer) = sProducer
The issue is that when that happens, my application throws a StackHeap exception after some time randomly. My questions are:
1. Is there a better way to do what I am trying to do here? If yes, can you share some VB6 code that I can use?
2. Is there a way the Core Api can tell me without throwing an exception that I cannot update the producer for a particular file? Any particular property/method that I can call before actually updating the producer?
3. Is there a way that I can cleanup after the exception so that my application does not throw run time heap exceptions after this exception is thrown?
Looking forward to your response.
Regards,
M