Encrypt jsPDF generated pdf to SharpPDF

898 Views Asked by At

i'm generating a pdf in my client using jsPDF, and want to encrypt it in my server app with SharpPDF, but when im trying to pass the jsPDF to SharpPDF i get that it can't recognize some characters:

here is the pdf value using jsPDF output and then encoding it into base 64

var out = doc.output();
var url = 'data:application/pdf;base64,' + out.toString(CryptoJS.enc.Base64);


%PDF-1.3
3 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/Contents 4 0 R>>
endobj
4 0 obj
<</Length 9717>>
stream
0.57 w
0 G
BT
/F1 14 Tf
16.099999999999998 TL
0 g
227.46 510.24 Td
(SOME TEXT) Tj
ET
BT
/F3 8 Tf
9.2 TL
0 g
42.52 48.19 Td

then at my server when im trying to encrypt it using this example http://www.pdfsharp.net/wiki/ProtectDocument-sample.ashx

i get an error in this line:

        System.IO.File.WriteAllText("D://" + data.Texto, data.Valor);

        HERE--> PdfDocument document = PdfReader.Open("D://" + data.Texto, "some text");

        PdfSecuritySettings securitySettings = document.SecuritySettings;


        securitySettings.UserPassword = "user";

        securitySettings.OwnerPassword = "owner";

The error is Token 'obj' was not expected.

0

There are 0 best solutions below