PDF Manipulation in PB? PDF to TIF Conveter
Posted: Wed May 30, 2012 2:28 pm
Can this be done in PureBasic? I need to basically convert PDF to TIF in PB.
http://www.purebasic.com
https://www.purebasic.fr/english/
I like this method the best honestly. It provides what I need the quickets without having to use libraries to write my own converter. I wish they would let me use the command line version in the trial. When I try it opens the app asking me to register first. Probobly will buy this once I get go ahed from my boss. In your command line example you have thismorosh wrote:using pdf2image (from http://www.verypdf.com), it can be launched from a command line. then using
RunProgram("pdf2img.exe" -i file1.pdf -o file1.tiff -b 1 -c lzw -r 300")
you can get what you want, but it's not free![]()
Regards
Code: Select all
"pdf2img.exe" -i file1.pdf -o file1.tiff -b 1 -c lzw -r 300"
Code: Select all
;http://www.ghostscript.com/download/
;Put in GS$ the path to Ghostscipt
GS$="c:\Program Files\gs\gs9.05\"
GSLib$=GS$+"lib"
GSFonts$=GS$+"fonts"
GSCmd$=GS$+"bin\gswin32c.exe"
FileName$=OpenFileRequester("Please choose a file","","PDF (*.pdf)|*.pdf",0,#PB_Requester_MultiSelection)
index=0
While Len(FileName$)
index+1
Debug Str(index)+" "+FileName$
Filepart$=GetFilePart(FileName$)
Pathpart$=GetPathPart(FileName$)
Extpart$=GetExtensionPart(FileName$)
NewName$=Left(Filepart$,Len(Filepart$)-(1+Len(Extpart$)))+"_P%04d.tif"
command$="-I"+Chr(34)+GSLib$+";"+GSFonts$+Chr(34)+" "
command$+"-sDEVICE=tiffg3 "
command$+"-dNOPAUSE "
command$+"-dSAFER "
command$+"-dBATCH "
command$+"-sPAPERSIZE=a4 "
command$+"-r600"
parameter1$=command$+" -sOutputFile="+Chr(34)+Pathpart$+NewName$+Chr(34)+" "+Chr(34)+FileName$+Chr(34)
parameter2$=Pathpart$
ProgramID=RunProgram(GSCmd$,parameter1$,parameter2$,#PB_Program_Open|#PB_Program_Read|#PB_Program_Error)
If ProgramID
Output$=""
While ProgramRunning(ProgramID)
If AvailableProgramOutput(ProgramID)
Output$ + ReadProgramString(ProgramID) + Chr(13)
EndIf
Wend
Exitcode=ProgramExitCode(ProgramID)
If Exitcode
MessageRequester("Ghostscript","Exitcode="+Str(Exitcode))
Else
If Len(Output$)
;MessageRequester("Ghostscipt",Output$)
EndIf
EndIf
EndIf
FileName$ = NextSelectedFileName()
Wend