Batch Convert PDF files to Flash Paper
ANT has been on my list of stuff to check out for the last while - however, it's real strength is that it is cross platform. For this project I found it a bit overkill so I just put together a little VB script to handle it.
This script is also simpler to set up on non-technical users machines as you don't need to have Java, Ant and Ant contrib set up.
The following script reads file in from a folder "in" and outputs them to a folder "out". It does very little error checking but works for me . Hope it helps.
' Reads files from folder "in" and outputs to folder "out"
flashPrinter= """C:\Program Files\Macromedia\FlashPaper 2\FlashPrinter.exe"""
inPath = "in\"
outPath = "out\"
delayMsec = 10000 'wait to let flashPrinter complete
If "CSCRIPT.EXE" <> UCase( Right( WScript.Fullname, 11 ) ) Then
'WScript.Interactive = false
WScript.Echo "To use this script enter: cscript " & WScript.ScriptName & vbcrlf & "or right click and select 'Open with Command Prompt'"
WScript.Quit 1
End If
Dim strMbox
Set objFileScripting = CreateObject("Scripting.FileSystemObject")
'Return folder object
Set objFolder = objFileScripting.GetFolder(inPath)
'return file collection In folder
Set filecollection = objFolder.Files
strMbox= MsgBox("Ready to process " & fileCollection.count & " files",1)
If strMbox = 2 Then
Wscript.Echo "Cancelled"
WScript.Quit
end if
For Each filename In filecollection
filename=right(filename,len(filename)-InStrRev(filename, "\"))
if InStrRev(filename, ".") then 'remove extension if there is one
FilenameNoExt=left(filename,InStrRev(filename, ".")-1)
end if
' Run the flashprinter for each file
command = flashPrinter & " " & inPath & filename & " -o " & outPath & filenameNoExt & ".swf"
Set objShell = CreateObject("WScript.Shell")
'objShell.CurrentDirectory =
Wscript.Echo "Processing: " & inPath & filename & " --> " & outPath & filenameNoExt & ".swf"
objShell.Run(command)
'Wait some for it to complete
Wscript.Sleep delayMsec
Next
Wscript.Echo "Done"
WScript.Quit
Feel free to use it and if you have any improvements please let me know.
Update: changed comment from // to ' which makes it barf. That will teach me to comment it after I write it.




I tried the ANT script but having never touched ANT it just took to long for me to set up and I left it.
This script works well for PDF to SWF.
How can I use it to convert the contents of a folder that might contain any printable file including pdf into two output directorys for pdf and swf respectivly.
Some submitted PDF's are rather large.. can flashpaper process them again to make them smaller?
- Matt
I got this
C:\Staff>cscript pdf2flashpaper.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Processing: Book PDF's for Web\bk1933.pdf --> Book PDF's for Web\bk1933.swf
Processing: Book PDF's for Web\bk1963.pdf --> Book PDF's for Web\bk1963.swf
Processing: Book PDF's for Web\bk2005.pdf --> Book PDF's for Web\bk2005.swf
Processing: Book PDF's for Web\bk2010.pdf --> Book PDF's for Web\bk2010.swf
Done
--->
But nothing. Any ideas as to why Im getting no output?
Not sure - are you getting any output at all? Are you seeing any flash paper screens? Flash paper is installed in the same location? It is flash paper 2 you are using?
Cheers,
Mark
Im not seeing any flashpaper screens when running the script,
I have FlashPaper 2 Installed in C:\Program Files\Macromedia\FlashPaper 2\FlashPrinter.exe
It is version 2.01.2283.0
Licencing 4.0.0.38
Maybe I've got a dud Flashpaper that does not respond to command line?
Make sure that the directory name does not have any spaces in it - I haven't done any escaping for spaces in the directory name.
I typically run it from c:\pdf2flash\ . Let me know how you go.
Cheers,
Mark
flashPrinter= """C:\Program Files\Macromedia\FlashPaper 2\FlashPrinter.exe"""
inPath = "in\"
outPath = "out\"
delayMsec = 10000 'wait to let flashPrinter complete
But no luck :( ... I tried re-installing flashpaper and now I get an error/warning on install, something to do with registry keys! I re-installed, so I could select all users instead of just this user - I thought that might be the problem, but no.
Flashpaper still works even with the warning on installation. I can run it manually. The strange thing is that in trial mode the vb script opens the flashpaper registration window, I press ok , but still no output. In registered mode nothing opens at all.
Basically it looks like my flashpaper installation takes no notice of the command line.
M.
inPath = "C:\PDF\"
outPath = "C:\SWF\"
As with Matt, I got messages such as...
Processing: Book PDF's for Web\bk1933.pdf --> Book PDF's for Web\bk1933.swf
but after the processing was complete, there were no SWF files.
Any ideas?
Thanks, Carlos
What directory are you in when you run the script? Where is the script in location to the in and out folders?
Did you change inPath = "in\" to inPath = "C:\PDF"? I'm not sure if it will correctly handle the absolute path.
Try adding the following line:
Wscript.Echo command
just above
objShell.Run(command)
That should output the command being run. Then try running it by hand and see if it is giving any errors.
Cheers,
Mark
As for Matt's and Carlos problems I found similar or same problem, but found out why in my environment.
I tried FlashPaper on a newly installed virtual machine (no Acrobat Reader).
First problem, install program failed to register flash.ocx (Error 1904), but found a solution:
http://www.adobe.com/cfusion/knowledgebase/index.c...
Second problem: Acrobat Reader must be installed (not suprisingly of course..).
Third problem: Well, couldn't get it to dance with Acrobat Reader 8. Installed version 7.0.9 - that solved it.
As Acrobat Reader kicked in when running the script and not exiting I added this code to the script:
----------- Before looping the files:
adobeReader="""C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"""
set objWshAdobe=CreateObject("WScript.Shell")
' Start the reader
Set objAdobe=objWshAdobe.Exec(adobeReader)
----------- And before exiting the program:
objAdobe.Terminate()
This gets the Reader window disappear after executing the script.
Thanks again Mark,
/Lars
Thank you!!
VBScript example:
P2F = CreateObject(“P2F.Server”)
P2F.ConvertDir "C:\docs", "*.pdf", "C:\inetpub\www.mysite.com\swf"
Command line example:
p2fserver.exe C:\ Docs\*.pdf C:\inetpub\www.mysite.com\swf
In the examples all PDFs in the "C:\docs" folder are converted to Flash. The output files are written to the "C:\inetpub\www.mysite.com\swf" folder.
Print2Flash OLE Automation API objects can run using rights of a user different from the user which creates and uses these objects. This allows converting documents from server-side scripts like ASP or PHP.
Print2Flash batch processing also allows you to fine-tune document options like paper size, page orientation, printing resolution, etc.
Print2Flash official website:
http://print2flash.com
See help topics at
http://print2flash.com/help/BatchProcessing.php http://print2flash.com/help/EnhancedBatchProcessing.php" target="_blank">http://print2flash.com/help/EnhancedBatchProcessin... http://print2flash.com/help/AutomationAPIReference.php" target="_blank">http://print2flash.com/help/AutomationAPIReference...
Problem now is that it is doing a useless job a compressing. A 216kb PDF at input is coming out as a 2MB swf and as a 2MB+ PDF !?
Memory of using flashpaper was that it done a great job at compression but now its performing like balls!
The input PDF properties states: WebFast= Yes , Created by Adobe..
The output PDF says WebFast=no and Created by PDFLib/C++
Im not sure why Im getting crap results now maybe its to do with Adobe 8? I'll try version 7 - if anyone knows how to get the best compression out of flashpaper please share.
M.
the PDF files are larger then SWF
what can i do?