Author Topic: Flatten PDF stamps  (Read 25667 times)

0 Members and 1 Guest are viewing this topic.

Anonymous

  • Guest
Flatten PDF stamps
« on: August 29, 2008, 06:04:00 AM »
Hi,

We are currently trialing shell tools to see if we can use it to stamp electronic building permits.
The only issue we have had so far is that when we stamp a semi-transparent image, the file needs to be flattened before we can print it. Our printer won't print non-flattened PDF's for some reason, and it also causes a problem when merging documents with PDF shell tools.
Is there anyway of stamping an image onto the PDF and having the program flatten the PDF at the same time?

Also, we can't seem to stamp more than one PDF file at a time. If more than one PDF is selected, one of the created PDF's will be stamped, with the other blank pages.

Thanks,

Luke

RTT

  • Administrator
  • *****
  • Posts: 778
Flatten PDF stamps
« Reply #1 on: August 29, 2008, 05:11:00 PM »
Hi Luke,

Quote from: Luke
Our printer won't print non-flattened PDF's for some reason

Check this link http://kb.adobe.com/selfservice/viewContent.do?externalId=316508, for printing troubleshoot, at bottom of the page there are some hints regarding Postscript printers settings.
The "Print as image" option, also referenced in the article, normally fix many of these issues, but can slow the print task.

Quote from: Luke
and it also causes a problem when merging documents with PDF shell tools
If you can, please email to me, or send download link to, a sample of one of these PDF's so I can check what is causing the merge problem.

Right now I can't promise the development of such a feature. I have added the suggestion to the TODO list.
Even so, I'm developing a new stamp object, the PDF page. This stamp object will use a user selectable external file pdf page, and use its page contents as the source of stamp data. User can create very complex stamps, using the normal tools he use to create a PDF, and later stamp that page as background or watermark of another PDF page.
Using source pages already flattened will fix your issue, or maybe not...  ::)
Quote from: Luke
Also, we can't seem to stamp more than one PDF file at a time. If more than one PDF is selected, one of the created PDF's will be stamped, with the other blank pages.

Oops, you have found a bug. I have now fixed the code and soon a Patch will be available for registered users and a revised trial will go online also.
Thanks for mention it  ;)

LukeV

  • Newbie
  • *
  • Posts: 30
Flatten PDF stamps
« Reply #2 on: August 31, 2008, 11:26:00 PM »
Thanks for your quick reply.

We can print using the image setting, but it is slow, and I am worried clients won't be able to work it out  :D
I'll e-mail you a copy of the PDF's I am trying to merge.

BTW - another problem we have had with the image stamps is that when you open a saved stamp, it states "A call to the OS failed" or something like that. The stamp still opens but the details can't be changed. We are using XP SP3.

Would there be any way to get the stamp program to remember the last stamp used, so we don't have to load the same stamp up all the time?

Thanks,

LukeV

P.S - We should be registering soon as we have almost finished setting up our electronic permit system and your program seems to work well, other than these few minor issues. Well done on an easy to use program!

RTT

  • Administrator
  • *****
  • Posts: 778
Flatten PDF stamps
« Reply #3 on: September 01, 2008, 11:43:00 PM »
With your sample files, and thank you for these file copies  ;), I have now fixed a couple of bugs in the stamp tool.
One of these bugs is responsible of the merge fail (despite the fact the merged PDF shows OK in Foxit reader and PDF-Xchange viewer, file is really partially corrupted and fail to show in Acrobat.

If you really need to merge these already stamped files you will need to use a Hex editor, or a text editor with binary edit capabilities (Notepad++ is a good one) and replace all the "/length 1" occurrences by "Length 1" (without quotes). Already stamped files will merge correctly after this substitution done.
This problem is now fixed and I'll e-mail you the download link for the next patch (beta version) so you can test it. Let me know if you find something else.

Quote from: LukeV
BTW - another problem we have had with the image stamps is that when you open a saved stamp, it states "A call to the OS failed" or something like that. The stamp still opens but the details can't be changed. We are using XP SP3.
Is this problem stamp file related or show up every time you open a stamp, even different one, file?
What objects you have on these stamps?
Tested in Windows Vista and XP SP3 and is working fine here. But for sure a bug is causing this at your system, so, please try to discover what steps, stamp file objects, etc.., are need to reproduce the error.

Quote from: LukeV
Would there be any way to get the stamp program to remember the last stamp used, so we don't have to load the same stamp up all the time?
No, but now that you mention it, I'm going to replace the open stamp button by one with a drop down menu to easily access last used stamp files.
Even so, and using the versatile PDF-ShellTools command line interface, the Windows Shell Send To context menu functionality and batch scripts you can easily add new entries to the Shell Send To menu and use it to specifically apply a stamp file to all the PDF's selected.

Here is how:

Let suppose you have a CompanyLogo.stp at C:\Stamps
PDF-ShellToosl is installed at C:\Program Files\PDF-ShellTools

In the C:\Stamps folder, or any other work folder, create a "Stamp.cmd" file, open it in a text editor (Notepad) and enter next lines

Code: [Select]
@ECHO OFF
:NEXT
     set v=%1
     SHIFT
     IF (%1)==() GOTO STAMPIT
     set v=%v%;%1
     SHIFT
     GOTO NEXT
:STAMPIT
call rundll32 "C:\Program Files\PDF-ShellTools\PDFShellTools.dll",Stamp stamprules=1- Template=C:\Stamps\CompanyLogo.stp %v%
and save it.

Now create a shorcut to the .cmd file you have just created, give it a meaningful name, and icon, and place it in the Send To folder. To do that, cut the shorcut file and in Windows Explorer address bar enter:
%APPDATA%\Microsoft\Windows\SendTo
to open the send to folder. Paste the shortcut there.

Now you have a new item in the "Send To" Shell context menu. To apply that stamp to a file(s), just select these PDF files and next run your Shell Context menu>Send To>"YourShortcutName".

To apply this technique to other stamps, e.g. StampDraft.stp, StampConfidential.stp, etc.., better change the script file to:

Code: [Select]
@ECHO OFF
     set s=%1
     SHIFT
     set v=%1
     SHIFT
:NEXT
     IF (%1)==() GOTO STAMPIT
     set v=%v%;%1
     SHIFT
GOTO NEXT
:STAMPIT
call rundll32 "C:\Program Files\PDF-ShellTools\PDFShellTools.dll",Stamp Template=%s% stamprules=1- %v%

Now, as before, create a shortcut, but in the shortcut properties target field add the path to the stamp file you want to apply.

To stamp the company logo create a shortcut with target:
C:\Stamps\Stamp.cmd C:\Stamps\CompanyLogo.stp

To stamp the Draft word create a shortcut with target:
C:\Stamps\Stamp.cmd C:\Stamps\StampDraft.stp

To stamp the Draft word create a shortcut with target:
C:\Stamps\Stamp.cmd C:\Stamps\StampConfidential.stp

etc..

Obvious you need to create also these .stp files

Let me know if you don't understand something.

LukeV

  • Newbie
  • *
  • Posts: 30
Flatten PDF stamps
« Reply #4 on: September 02, 2008, 02:58:00 AM »
Quote from: RTT
Is this problem stamp file related or show up every time you open a stamp, even different one, file?
What objects you have on these stamps?
It happens with all stamps (image and text). I have worked out now that if I deselect the stamp object and then re-click on it, all the values seem to come up again anyway.

I've got the "Send to" stamp command working. This is really helpfull!!
The only issue I have is that when it loads up a text stamp, the second text line/object isn't rotated like how it was saved. It works when I stamp manually, but using the send to link it puts it at 0 degrees rotation. I'll e-mail you my stp file and the PDF to see if you can work out why.

Cheers,

LukeV

LukeV

  • Newbie
  • *
  • Posts: 30
Flatten PDF stamps
« Reply #5 on: September 02, 2008, 03:02:00 AM »
Ohh one other thing with the Send To stamp. When you try and select the destination of the new PDF as the same location as the original, it doesn't create the PDF.

RTT

  • Administrator
  • *****
  • Posts: 778
Flatten PDF stamps
« Reply #6 on: September 03, 2008, 12:28:00 AM »
Quote from: LukeV
It happens with all stamps (image and text). I have worked out now that if I deselect the stamp object and then re-click on it, all the values seem to come up again anyway.
Strange..., is working fine here. Or the problem is already fixed in the version I'm testing, or is related to some specificity of your system.

Quote from: LukeV
The only issue I have is that when it loads up a text stamp, the second text line/object isn't rotated like how it was saved.
I also found that bug while testing the "Send to" menu idea, and it is now fixed.

Quote from: LukeV
Ohh one other thing with the Send To stamp. When you try and select the destination of the new PDF as the same location as the original, it doesn't create the PDF.
Fixed that too.

Check if with the patched version I have emailed to you any of these bugs persist, or if a new one shows up  ;)

LukeV

  • Newbie
  • *
  • Posts: 30
Flatten PDF stamps
« Reply #7 on: September 03, 2008, 02:19:00 AM »
Good work!! All the mentioned bugs seem to have been sorted!!

Do you think it would be possible to use the "send to" command to stamp more than 1 PDF at a time? Or is this not possible?
If not, it would be great to get the drop down list of recently used stamps so you don't need to navigate and find it each time, or have the previously used stamp come up as default  :)

Thanks for all your help. I will continue testing to see if any other bugs.

Cheers,

Luke

Edit - One other thing, is it possible to select the default treatment of files once the have been stamped? At the moment, I have to go in and change the file save mode from "save in another folder" to "overwrite original files" each time you stamp a document.

RTT

  • Administrator
  • *****
  • Posts: 778
Flatten PDF stamps
« Reply #8 on: September 03, 2008, 10:27:00 PM »
Quote from: LukeV
Do you think it would be possible to use the "send to" command to stamp more than 1 PDF at a time? Or is this not possible?
Have you tried?! Almost all the code in the above two batch file examples is to deal with that possibility, and works fine. The maximum number of files we can pass is limited by the maximum length available for command line parameters, so, it is directly related to files names and path lengths.
http://support.microsoft.com/kb/830473
When this limit is reached, because of too many files selected, you will get a warning message from the Shell.
I have also noted an extra length limit in Windows Vista when what we put in the "Send to" folder is a shortcut and not the batch file itself.
In XP the limit is equal for shortcuts or real batch files, but, in Vista, decrease when shortcuts used!! I haven't read nothing about why this occur!!!

Quote from: LukeV
If not, it would be great to get the drop down list of recently used stamps so you don't need to navigate and find it each time, or have the previously used stamp come up as default :)
The list of last used ones is already working and will go out with next version. ;)
Quote from: LukeV
One other thing, is it possible to select the default treatment of files once the have been stamped? At the moment, I have to go in and change the file save mode from "save in another folder" to "overwrite original files" each time you stamp a document
When started from the command line interface (the used from the "Send to" menu), yes. If no OutputPath parameter specified, it will overwrite source file, if OutputPath equal to the source file path, will create a backup file, and when specified OutputPath is different from the source path will, obviously, create the stamped files on that directory.
For the GUI interface, maybe I can add a "Set as default" button that show up when user change that option... ::)

LukeV

  • Newbie
  • *
  • Posts: 30
« Reply #9 on: September 04, 2008, 11:55:00 PM »
I've managed to get the first code you posted working with a single file. So I right click, select "send to -stamp" and it pops up the GUI and I can stamp the file.
When I try selecting 2 PDFs, right click and select "send to- stamp" the GUI comes up but when I press stamp, I get the following RunDLL32 error:
"Access violation at address 00BBE3F4 in module "PDFShellTools.dll. Read of address 00000024."

I haven't been able to get the second code working. I've created the cmd file with the code as above, and created a shortcut with the C:\stamps\Test.cmd "C:\stamps\ps.stp" in the target box. When I use it though, it doesn't start the GUI, similiar to when I tried pointing the first script to a stp file with a space in it's name.


Luke

RTT

  • Administrator
  • *****
  • Posts: 778
Flatten PDF stamps
« Reply #10 on: September 05, 2008, 01:59:00 AM »
Quote from: LukeV
I've managed to get the first code you posted working with a single file. So I right click, select "send to -stamp" and it pops up the GUI and I can stamp the file.
When I try selecting 2 PDFs, right click and select "send to- stamp" the GUI comes up but when I press stamp, I get the following RunDLL32 error:
"Access violation at address 00BBE3F4 in module "PDFShellTools.dll. Read of address 00000024."
Make sure the number of files in the files to stamp list (Files tab) matches the number you have submitted. If not, don't run it or you get that error.
The problem is related to some bad file list passed from the command line, and weak code (now fixed) unable to deal with that.
Why the file list is wrong, I don't know. Check if files submitted don't have comma or semicolon characters on it's names.
You can inspect the file list command line passed inserting next two lines

Code: [Select]
Echo %v%
pause

before the :STAMPIP label line.

Quote from: LukeV
I haven't been able to get the second code working. I've created the cmd file with the code as above, and created a shortcut with the C:\stamps\Test.cmd "C:\stamps\ps.stp" in the target box. When I use it though, it doesn't start the GUI, similar to when I tried pointing the first script to a stp file with a space in it's name.

Sorry, my mistake. The double quotes in the path to the stamp template are the cause.
To fix it, and also add support for templates with spaces in name/path, set target box as C:\stamps\Test.cmd "Template=C:\stamps\ps.stp" (double quotes are now needed)
and use next improved batch code.
Code: [Select]
@ECHO OFF
     set s=%1
     SHIFT
     set v=%1
     SHIFT
:NEXT
     IF (%1)==() GOTO STAMPIT
     set v=%v%;%1
     SHIFT
GOTO NEXT
:STAMPIT
call rundll32 "C:\Program Files\PDF-ShellTools\PDFShellTools.dll",Stamp %s% stamprules=1- %v%

LukeV

  • Newbie
  • *
  • Posts: 30
« Reply #11 on: September 05, 2008, 05:58:00 AM »
OK. So I updated to the new code in the cmd file.
I also added the echo command (and deleted the echo off command at start). This is the output. It still won't show both files in StampIt. Maybe you can see something wrong with my output? Oh, 2.PDF is the file that shows up in the file list. EDIT - Actually the file that loads up is different every time.


C:\stamps>set s="Template=C:\stamps\ps.stp"

C:\stamps>SHIFT

C:\stamps>set v=C:\temp1\1.pdf

C:\stamps>SHIFT

C:\stamps>IF (C:\temp1\2.pdf) == () GOTO STAMPIT

C:\stamps>set v=C:\temp1\1.pdf ;C:\temp1\2.pdf

C:\stamps>SHIFT

C:\stamps>GOTO NEXT

C:\stamps>IF () == () GOTO STAMPIT

C:\stamps>call rundll32 "C:\Program Files\PDF-ShellTools\PDFShellTools.dll",Stamp
 "Template=C:\stamps\ps.stp" stamprules=1- C:\temp1\1.pdf ;C:\temp1\2.pdf

LukeV

  • Newbie
  • *
  • Posts: 30
« Reply #12 on: September 05, 2008, 06:16:00 AM »
OK. So I worked out the problem. There is a space between the first file extension and the semi-colon. If I put the file names in manually without the space it works.
Only problem is I don't know what is putting the space in there, so I may need your help.


Thanks,

Luke

RTT

  • Administrator
  • *****
  • Posts: 778
Flatten PDF stamps
« Reply #13 on: September 05, 2008, 10:23:00 AM »
I only see one possibility, you have a space after set v=%1_
Make sure the end of line is just after the 1.

LukeV

  • Newbie
  • *
  • Posts: 30
Re: Flatten PDF stamps
« Reply #14 on: September 07, 2008, 11:50:17 PM »
Hehehe....I should have worked that out  ::)
I think when you copy and paste scripts from IE it adds a space after every line.

All working now :)

P.S I also modified the script to allow me to specify which pages will be stamped, without having to modify the CMD file. I just add "" to the end of the target field to print all the pages, or "1" to print the first page, etc.

Echo@ off
     set s=%1
     SHIFT
     set q=%1
     SHIFT
     set v=%1
     SHIFT
:NEXT
     IF (%1)==() GOTO STAMPIT
     set v=%v%;%1
     SHIFT
GOTO NEXT
:STAMPIT
call rundll32 "C:\Program Files\PDF-ShellTools\PDFShellTools.dll",Stamp %s% stamprules=%q% %v%