Free Support Forum -

PDF License Problem with Word Conversion in WebService

I have encountered the error "CryptoAPI cryptographic service provider (CSP) for this implementation could not be acquired." when I execute the WebService below. This currently works in production with the old license scheme but after changing to the new license and modifying the code to use it, it has problems when setting up the license for the PDF object. Below is the code that is being executed.

Please advise on how to fix this problem.

I have noted where the code actually exceptions out with the following:

StackTrace: " at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.RSACryptoServiceProvider..ctor()
at Aspose.Pdf.License.a(XmlNode A_0, XmlNode A_1)
at Aspose.Pdf.License.a(XmlDocument A_0)
at Aspose.Pdf.License.SetLicense(Stream stream)
at Aspose.Pdf.License.SetLicense(String licenseName)
at ws_rpmOffice_v1.WS_RPMOffice_V1.RPMWordDocToPDF(String inUNC, String outUNC, String strUserLogon) in xxx.vb:line 222"


    <System.Web.Services.WebMethod( _
Description:="ASPOSE Service to Convert a Word 2000 Document to a ASPOSE PDF file. Takes fully qualified input and output UNC's as parameters as well as the User's Logon ID for conversion annotation. Then Checks for existance and returns a string reporting conversion status: 'SUCCESS|' appended with newly created UNC filename or 'ERROR|' appended with the error condition message. Calling application requires access to both parameter paths.")> _
Public Function RPMWordDocToPDF(ByVal inUNC As String, ByVal outUNC As String, ByVal strUserLogon As String) As String
        Dim RtnVal As String = String.Empty
        Dim InPath As String = inUNC.Trim
Dim OutPath As String = outUNC.Trim
        If Not File.Exists(InPath) Then
RtnVal = "ERROR|" & "File does not exist: " & InPath
Return RtnVal
Exit Function
End If
        If strUserLogon.Trim.Length = 0 Then
RtnVal = "ERROR|" & "User Logon ID was not provided." & InPath
Return RtnVal
Exit Function
End If
        'Determine if ASPOSE License is avalible for use; otherwise watermarked output will be created (for testing servers)
Dim WordLicense As String = GetWebConfigAppValue("ASPOSEWordLicenseFile")
If WordLicense.Length > 0 Then
If Not File.Exists(WordLicense) Then
RtnVal = "ERROR|" & "ASPOSE Word License File in Web.Config can not be found. Contact RPM Systems support."
Return RtnVal
Exit Function
End If
End If
        Dim PDFLicense As String = GetWebConfigAppValue("ASPOSEPDFLicenseFile")
If PDFLicense.Length > 0 Then
If Not File.Exists(PDFLicense) Then
RtnVal = "ERROR|" & "ASPOSE PDF License File in Web.Config can not be found. Contact RPM Systems support."
Return RtnVal
Exit Function
End If
End If
        'Delete Temp Work file
Dim fi As FileInfo = New FileInfo(InPath)
        Dim DirName As String = fi.DirectoryName
Dim FileName As String = fi.Name.Substring(0, fi.Name.IndexOf(".")) & "_TMP.XML"
Dim wrkFile As String = DirName & "\" & FileName
        If File.Exists(FileName) Then File.Delete(FileName)
If File.Exists(wrkFile) Then File.Delete(wrkFile)
If WordLicense.Length > 0 Then
'Old License Processing:[ WORD.Word.SetLicense(WordLicense) ] replaced by new below:
Dim license As WORD.License = New WORD.License
End If
            Dim objDocument As WORD.Document = New WORD.Document(InPath)
objDocument.Save(wrkFile, WORD.SaveFormat.FormatAsposePdf)
            'Create PDF 
Dim objPDF As PDF.Pdf = New PDF.Pdf
            If PDFLicense.Length > 0 Then
'Old License Processing:[ PDF.Pdf.SetLicense(PDFLicense) ] replaced by new below:
Dim licensePDF As PDF.License = New PDF.License

End If
            objPDF.BindXML(wrkFile, Nothing)
            'Add Timestamp Note.
Dim CRLF As String = System.Environment.NewLine
            'Attach Timestamp to file
Dim strTimestamp As String = CRLF & "Approved and submitted for conversion by" & CRLF & strUserLogon & " on " & DateTime.Now.ToShortDateString & " " & DateTime.Now.ToLongTimeString & ". " & CRLF & " "
            Dim sec1 As PDF.Section = objPDF.Sections.Add()
            Dim table1 As PDF.Table = New PDF.Table
table1.ColumnWidths = "1.5inch 1.5inch" 'Dims per cell
            Dim row1 As PDF.Row = table1.Rows.Add()
            Dim cell1Row1 As PDF.Cell = row1.Cells.Add(strTimestamp)
cell1Row1.ColumnsSpan = 2
cell1Row1.Border = New PDF.BorderInfo(CType(PDF.BorderSide.All, Integer), 2.5, New PDF.Color("BLUE"))
            If File.Exists(OutPath) Then
End If
            If Not File.Exists(OutPath) Then
RtnVal = "ERROR|" & "Output File does not exist. File not created : " & InPath
RtnVal = "SUCCESS|" & OutPath
End If
        Catch ex As Exception
Dim x As String = ex.Message
RtnVal = "ERROR|" & ex.Message
End Try
If File.Exists(wrkFile) Then File.Delete(wrkFile)
Catch ex As Exception
Dim x As String = ex.Message
End Try
        Return RtnVal
    End Function

Please let me know what should be done to correct the problem. As stated earlier, this is working in production but after the new key and modifications it does not work. If I remove the second license call for the PDF object it works well but the output has a watermark.

Thanks for the help.


PS. I have also downloaded the new License file prior to execution and it is the same file in the WebConfig file that is referenced by both config calls.


Hi Dave,

Thank you for considering Aspose.

Please send your order ID to sales to get the correct new license file.

Yes, I have already downloaded the new license prior to excuting the Webservice. If it is the wrong license, then shouldn't the code for the WORD module would have not worked. Correct? Please note the problem statement and look at the WORD Forums, it appears that the PDF assembly has the same problems that WORD did before ASPOSE fixed the WORD problem.

I contacted Sales and because I downloaded the new license while on the phone with them, they told me again today after requesting a new one that I have the correct license. That does not resolve the problem. Please follow up and see if the same patch was applied to the PDF assembly as the WORD problem or open a new problem log. For more information on how it was resolved for your customers for Word, please search the Forums for "crypto" and you'll see a few pages worth of postings on the topic. Could it be that PDF was not updated while Word was?

Thanks for your help!


I think Aspose.Pdf was updated on this issue.

Please make sure there is a special directory exists on your machine and has the proper permissions as specified in

Tommy, please double check your License.cs has this code:

//Create cryptographic service provider. Note that just creating the provider creates

//a key pair. The key pair is created in the user profile and when running as ASP.NET page

//or Web Service, there could be no user profile and it will throw an exception, so

//we force it to create in the machine key store, see

CspParameters cspParam = new CspParameters();

cspParam.Flags = CspProviderFlags.UseMachineKeyStore;

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cspParam);

I changed permissions, etc. per your suggestion and the PDF module still exceptions with the same Crypto error messages brought on by the ASPOSE licenseing change. The version we're running is PDF v. (Product version 2005.01.23)
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please reply with direct instructions on what to do exactly to fix the problem with the ASPOSE PDF module. Only simple, tested, and direct answers, please! My boss is wondering why this is taking so long to get resolved when it is just 1 line of code that needs to get changed by us.



Sorry I’ve got nothing to add. It works for everyone else so it must still be a configuration problem on your machine.

I’m sure you followed the instructions, but there is nothing I can suggest but double check and follow these steps again:

1. You need to have the latest hotfix. Right click on Aspose.Pdf.dll to make sure it is the latest version. Sometimes your proxy server or firewall can cache and prevent downloading the latest version. Search for any other Aspose.Pdf.dll on your machine and delete them just in case.
2. Make sure there is a directory \Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys exists, create it if needed.
3. Make sure Everyone has read and write permissions into this directory.

I downloaded a new version of the Production release and have retested the application again and the problem still persists with the production version (1/23 dated file) of the product. (The Everyone permission change suggestion was implemented days ago.) But on the bright side, I also downloaded the HOTFIX (dated 3/1) and, using the same code, it works as expected but contains some PDF formatting problems as described below.

<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

Attached are two files - if I could figure out how to attache them; if not, I send them as a seperate email. The first is the Word Document created in another process via ASPOSE Word. A very fine looking document and is viewable by Word. The second document is a PDF file that is the output of a WORD to PDF conversion processing as processed by this thread’s code (above) that uses the first Word attached file as input.


It appears that the HOTFIX from viewing the PDF output, that line-breaks (or some other characters) are being underscored for some reason. This does not happen with the pre-license change version of the PDF module. Can you please look into it as see what can be done to resolve the PDF conversion problem with the current HOTFIX.


Thanks for you help.



Please send the files to and and include a link to this forum in your message.

Thanks for the followup. I sent out the emails per your request and hope that they can assist you in resolving the discrepancy.


Some of your empty paragraphs have underline turned on.

Normally, the end of paragraph character is invisible and the underline will not be visible for an empty paragraph, but at the moment Aspose.Word has to convert empty paragraphs into spaces when exporting to Aspose.Pdf. This results in underscored characters in your document.

You need to remove the underline from the empty paragraphs in your document and it will work okay.