We are using v13 to Scan in multiple pages and save as PDF (and we're using COM implementation for LEADTOOLS scanning).
We also need to be able to encrypt the PDF, if required, though. And, that's where the problem arises.
I'm using the source code seen below to perform the encryption but when the pages are being appended, I see the error -
"The script engine: LEADRasterIO.LEADRasterIO.130
has reported the error: LEAD Error: PDF - Cannot insert, delete, append or replace pages
The statement that caused the error is:"
On Error Resume Next
' Briefly make the PDF printer the default printer
' PDF.SetDefaultPrinter -- upgrade pdf conversion
PdfEx.EnablePrinter "XXX", "YYY"
'Mandatory, if permissions are set and concatenate bit = TRUE on FileNameOptions
PdfEx.Encryption = 1
PdfEx.Permissions = -64 + 4 'Enable printing only (-64 + 4)
'No Prompt + UseFileName + Concatenate (omit the Encryption here)
' PdfEx.FileNameOptions = 7 + 256 'The 7 allows for concatenation when multiple pages. 256 is the decimal value of 100 HEX, value that specified encryption (Encrypt resulting document with 40Bit RC4 (256))
PdfEx.FileNameOptions = 1 + 2 + 4
'SetDefaultConfig: this method should be used with some of the settings to the PDF printer driver, not with all of them. But, it’s not a bad idea to use it always.
' In the particular case of the Permissions method, SetDefaultConfig is mandatory
PdfEx.SetDefaultConfig
' PdfEx.EnablePrinter "XXX", "YYY"
PdfEx.SetDefaultPrinter
' Send the file to the PDF printer
hDC = LEADRasterView1.PrintStart
Err.Clear
fltTwainHeight = LEADRasterView1.PrinterScaleHeight
fltTwainWidth = LEADRasterView1.PrinterScaleWidth
LEADRasterView1.Render hDC, 0, 0, fltTwainWidth, fltTwainHeight
If Err.Number<>0 Then
MsgBox "Could not create PDF -- Error #" & CStr(Err.Number) & vbCrLf & "Printer handle: " & CStr(hDC) & vbCrLf & "Width" & CStr(LEADRasterView1.ScaleWidth) & " Height" & CStr(LEADRasterView1.ScaleHeight)
Err.Clear
End If
LEADRasterView1.PrintEnd hDC
' Reset the default printer for other applications
' PDF.RestoreDefaultPrinter -- upgrade pdf conversion
PdfEx.RestoreDefaultPrinter
' Change the file name options to append for subsequent pages
' PDF.FileNameOptions = 7 -- upgrade pdf conversion
PdfEx.FileNameOptions = 7
The PDF file is generated successfully but it isn't encrypted. And, of course, the error I mentioned, on every page append.
This has reference to a previous post of mine, found at:
http://support.leadtools...rums/36038/ShowPost.aspx