made output filename optional
authorkramm <kramm>
Sat, 5 Apr 2003 19:19:34 +0000 (19:19 +0000)
committerkramm <kramm>
Sat, 5 Apr 2003 19:19:34 +0000 (19:19 +0000)
pdf2swf/pdf2swf.1
pdf2swf/pdf2swf.cc

index 1103cf4..7704ee1 100644 (file)
@@ -3,7 +3,7 @@
 pdf2swf - convert PDF files into SWF
 .SH Synopsis
 .B pdf2swf
-[\fIoptions\fR] \fIfile.pdf\fR -o \fIfile.swf\fR
+[\fIoptions\fR] \fIfile.pdf\fR [-o \fIfile.swf\fR]
 .SH DESCRIPTION
 This tools converts Acrobat PDF files into Flash SWF Animation
 files.
index 2cd110a..4cec4f5 100644 (file)
@@ -270,7 +270,7 @@ int args_callback_command(char*name, char*val) {
 
 void args_callback_usage(char*name)
 {
-    printf("Usage: %s [-si] [-j quality] [-p range] [-P password] input.pdf -o output.swf\n", name);
+    printf("Usage: %s [-si] [-j quality] [-p range] [-P password] input.pdf [-o output.swf]\n", name);
     printf("\n");
     printf("-p  --pages=range          Convert only pages in range\n");
     printf("-P  --password=password    Use password for deciphering the pdf\n");
@@ -351,6 +351,25 @@ void addfontdir(FILE*database, char* dirname, int*numfonts, char*searchpath)
 }
 #endif
 
+char* stripfilename(char*filename, char*newext)
+{
+    char*last1 = strrchr(filename, '/');
+    char*last2 = strrchr(filename, '\\');
+    char*pos = filename;
+    char*name;
+    char*dot;
+    if(last1>pos) pos = last1 + 1;
+    if(last2>pos) pos = last2 + 1;
+    name = (char*)malloc(strlen(pos)+5);
+    strcpy(name, pos);
+    dot = strrchr(name, '.');
+    if(dot) {
+       *dot = 0;
+    }
+    strcat(name, newext);
+    return name;
+}
+
 int main(int argn, char *argv[])
 {
     int ret;
@@ -369,6 +388,14 @@ int main(int argn, char *argv[])
     initLog(0,-1,0,0,-1,loglevel);
     if(!outputname)
     {
+       if(filename) {
+           outputname = stripfilename(filename, ".swf");
+           logf("<notice> Output filename not giving. Writing to %s", outputname);
+       } 
+    }
+       
+    if(!outputname)
+    {
        fprintf(stderr, "Please use -o to specify an output file\n");
        exit(1);
     }