Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, February 9, 2011 2:55:49 AM(UTC)

J  
J

Groups: Registered
Posts: 25



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
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, February 9, 2011 6:20:31 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

I want to test this issue on my side. To do that please send an email to support@leadtools.com and include the following in the email:
1- Your LEADTOOLS v13 toolkit serial number (Do NOT post it here)
2- Try to isolate the problem in a very small working project (NOT your full application).
3- Put the project in a ZIP or RAR file with a sample source file and attach it to the email.
4- A link to this forum post.
 
#3 Posted : Wednesday, February 9, 2011 6:36:03 AM(UTC)

J  
J

Groups: Registered
Posts: 25


It'd be really difficult to create a working project for you as I have all my code developed using a RAD tool - CA Plex.

How do you suggest I do this?
 
#4 Posted : Thursday, February 10, 2011 5:26:38 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

The ability to create encrypted multi-page PDF files was not available in LEADTOOLS v13. This feature is part of more recent versions, such as the latest LEADTOOLS version 17.
However, this feature is not available in the Main OCX v17 and we do not have LEADTOOLS COM objects interface in the latest v17 SDK.
If you would like to try this feature using LEADTOOLS v17, you can use our DLL APIs, C++ classes, or .NET classes programming interfaces.

You can download the free evaluation edition of LEADTOOLS from our website.
 
#5 Posted : Thursday, February 10, 2011 9:39:17 PM(UTC)

J  
J

Groups: Registered
Posts: 25


What's strange is, I can now get it to scan in multiple pages and save it as a multi-page encrypted PDF file.
I know it's encrypted as the Document Security shows me these details.
But.. I still see those LEAD PDF errors when each page is being appended into the PDF file.
So, when I'm creating a 3 page PDF, I see this error twice.
 
#6 Posted : Sunday, February 13, 2011 6:27:32 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Are you referring to the same issue you're discussing with my colleague Maen in the thread titled "Script error when saving scanned images as PDF"? If yes, please try to keep the discussion in one thread when it's about one issue. Only open a new thread when you have a different issue.
To summarize what might be the problems you're facing:
1. If you create a PDF using non-LEAD software, such as a PDF printer, you will not be able to append pages to it using LEADTOOLS.
2. You can create a new PDF file that contains one page using LEADTOOLS that is either encrypted or unencrypted.
3. In LEADTOOLS 13, you could not append to that file if it was encrypted, even if it was initially created by LEADTOOLS.
4. In the current versions of LEADTOOLS, you can append to an encrypted file that was created by LEADTOOLS.
 
#7 Posted : Sunday, February 13, 2011 7:23:36 PM(UTC)

J  
J

Groups: Registered
Posts: 25


<BLOCKQUOTE><table width="85%"><tr><td class="txt4"><img src="/SupportPortal/CS/Themes/default/images/icon-quote.gif">&nbsp;<strong>Adnan Ismail wrote:</strong></td></tr><tr><td class="quoteTable"><table width="100%"><tr><td width="100%" valign="top" class="txt4">Are you referring to the same issue you're discussing with my colleague Maen in the thread titled "Script error when saving scanned images as PDF"?</td></tr></table></td></tr></table></BLOCKQUOTE>
Yes, I'm referring to the same error message (I mentioned it in my very first post here) but the issue isn't the same. Then I'd see the message when trying to save scanned pages and it never created a multi page file. That got resolved.
Now, I see this error only when trying to save multiple scanned pages as a single encrypted PDF file; although the file is created successfully.
<br>
<BLOCKQUOTE><table width="85%"><tr><td class="txt4"><img src="/SupportPortal/CS/Themes/default/images/icon-quote.gif">&nbsp;<strong>Adnan Ismail wrote:</strong></td></tr><tr><td class="quoteTable"><table width="100%"><tr><td width="100%" valign="top" class="txt4">3. In LEADTOOLS 13, you could not append to that file if it was encrypted, even if it was initially created by LEADTOOLS.</td></tr></table></td></tr></table></BLOCKQUOTE>
How is it then that I am able to create a multi-page encrypted PDF file now? It works fine except for those error messages I see that seem to have no significance!
 
#8 Posted : Sunday, February 13, 2011 7:27:10 PM(UTC)

J  
J

Groups: Registered
Posts: 25


"Are you referring to the same issue you're discussing with my colleague Maen in the thread titled "Script error when saving scanned images as PDF"?"

Yes, I'm referring to the same error message (I mentioned it in my very first post here) but the issue isn't the same. Then I'd see the message when trying to save scanned pages and it never created a multi page file. That got resolved.
Now, I see this error only when trying to save multiple scanned pages as a single encrypted PDF file; although the file is created successfully.


"3. In LEADTOOLS 13, you could not append to that file if it was encrypted, even if it was initially created by LEADTOOLS."

How is it then that I am able to create a multi-page encrypted PDF file now? It works fine except for those error messages I see that seem to have no significance!
 
#9 Posted : Monday, February 14, 2011 5:39:02 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

If you are able to save such files, please answer the following questions:
1. What LEADTOOLS function are you using to implement PDF encryption in your project? Could you send me the exact lines of code?
2. Can you send me a small PDF file that contains 1 or 2 pages that was saved with encryption?
 
#10 Posted : Tuesday, March 1, 2011 2:45:35 AM(UTC)

J  
J

Groups: Registered
Posts: 25


"1. What LEADTOOLS function are you using to implement PDF encryption in your project? Could you send me the exact lines of code?"

My very first post within this thread has the lines of code I use to implement encryption - an encrypted PDF file is created here using the first scanned in page.
Thereafter, every page is appended to this PDF file using the following code:

' Refresh the image on the screen
LEADRasterView1.SetDstRect 0, 0, LEADRasterView1.ScaleWidth, LEADRasterView1.ScaleHeight
LEADRasterView1.SetDstClipRect 0, 0, LEADRasterView1.ScaleWidth, LEADRasterView1.ScaleHeight

' Load the file into a raster object
Set RasterIn = CreateObject("LEADRasterIO.LEADRasterIO")

' Quality of image (compression)
If &(2:) = 75 Then
' PNG
QFactor = 7
ElseIf &(2:) = 5 Then
' Lead CMP
QFactor = -4 ' Quality more important than size
ElseIf &(2:) = 10 or &(2:) = 11 or (&(2:) >= 20 and &(2:) = 150 and &(2:) = 146 and &(2:) <= 152 Then
LEADRasterView1.Raster.UnlockSupport 21, "XXX"
RasterIn.PDFSaveUseDPI = TRUE
End If

' Unlock Document Imaging if JBIG needed
If &(2:) = 115 or &(2:) = 139 Then
' JBIG - Unlock Document imaging
LeadRasterView1.Raster.UnlockSupport 0, "XXX"
End If

' Unlock TIFF LZW Support if needed
If &(2:) = 17 or &(2:) = 86 or &(2:) = 94 Then
LeadRasterView1.Raster.UnlockSupport 2, "XXX"
End If

' Unlock GIF LZW Support if needed
If &(2:) = 2 Then
LeadRasterView1.Raster.UnlockSupport 1, "XXX"
End If

RasterIn.Save LEADRasterView1.Raster, &(1:), &(2:), &(4:), QFactor, &(3:)
Set RasterIn = Nothing

LEADRasterView1.HScrollInfo.Pos = 0
LEADRasterView1.VScrollInfo.Pos = 0


It is when this above bit of code is being executed that we see the Lead PDF error I have stated earlier.


"2. Can you send me a small PDF file that contains 1 or 2 pages that was saved with encryption?"
Attached herewith is the encrytped PDF that was created through the application by scanning in 3 pages and saving them as an encrpted PDF.
File Attachment(s):
Multipage Encrypted PDF.PDF (1,428kb) downloaded 164 time(s).
 
#11 Posted : Tuesday, March 1, 2011 6:54:37 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

This PDF was NOT saved using any LEADTOOLS PDF writer. This means the RasterIn.Save() method in your code above is NOT responsible for writing this file.
In the first post, you did not mention our Save method. Instead, you mentioned the LEADRasterView1.Render() method, which sends the image to a device such as printer.

Are you using a non-LEAD printer driver to save PDF? If yes, these PDF files cannot have pages appended to or deleted from them using our toolkit.
 
#12 Posted : Tuesday, March 1, 2011 7:07:32 PM(UTC)

J  
J

Groups: Registered
Posts: 25



"This PDF was NOT saved using any LEADTOOLS PDF writer. This means the RasterIn.Save() method in your code above is NOT responsible for writing this file.

In the first post, you did not mention our Save method. Instead, you mentioned the LEADRasterView1.Render() method, which sends the image to a device such as printer."

Thank you! This totally makes sense now!

"Are you using a non-LEAD printer driver to save PDF? If yes, these PDF files cannot have pages appended to or deleted from them using our toolkit."

It looks like the earlier developer used Amyuni PDF Converter to create the encrypted PDF file and was then using the Raster Save method for 'compression' while appending further pages. I don't know - sounds strange.

So, you're saying I cannot implement multi page encrypted & compressed PDFs using LEAD 13, right?
And, even if I do upgrade to 17, we don't have COM implementation, which would mean redesigning my entire scan feature?
 
#13 Posted : Wednesday, March 2, 2011 6:36:44 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

You are correct. LEADTOOLS v17 SDK has C++ Class Library, DLL API and .NET programming interfaces, which contain almost all our new features.
If you upgrade to LEADTOOLS v17, you might consider one of these interfaces to redesign the application because the COM and OCX controls do not have the latest features, such as multi-page encrypted PDF support.

Edited by moderator Thursday, March 16, 2017 4:25:38 PM(UTC)  | Reason: Not specified

 
#14 Posted : Thursday, February 9, 2017 10:46:50 AM(UTC)
BonzoFestoon

Groups: Administrators
Posts: 27

Was thanked: 1 time(s) in 1 post(s)

In case anyone else finds this old thread:

On our blog, I posted a v19 C# Console Application with Windows Explorer integration that will encrypt a PDF file with a password.

PDF Encrypter - C# - Console App
Gabriel Smith
LEAD Technologies, Inc.

LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.219 seconds.