Hi,
I'm using Qt to run inkscape.exe in shell mode. The idea is to process multiple files through inkscape. In shell mode, inkscape accepts commands from stdin. However I'm experiencing problems when I try to write more than one command to inkscape. Here's my code.
	
	- int main(int argc, char* argv[]) { 
-     // create application 
-   
-     QString-  os_program  = QDir::toNativeSeparators ("E:/_Inkscape/inkscape.exe")- ; 
 
-     arguments << "--shell" << "--without-gui"; 
-   
-     // start the program 
-     inkex. setProcessChannelMode(QProcess::ForwardedChannels)- ; 
-     inkex.waitForStarted(); 
-   
-     // query the version 
-     inkex.write("--version\n"); 
-   
-     // export a file to png 
-     QString-  svgfile =QDir::toNativeSeparators("E:/_Development/Cpp/RxBuilder/test/test_twee.svg")- ; 
 
-     QString-  pngfile =QDir::toNativeSeparators("E:/_Development/Cpp/RxBuilder/test/test_twee.png")- ; 
 
-     QString-  cmd ="--file=\"%1\" --export-png=\"%2\" --export-area=0:0:1042:768\n"- ; 
 
-     cmd=cmd.arg(svgfile).arg(pngfile); 
-     out << "---" << endl; 
-     out << cmd << endl; 
-     out << "---" << endl; 
-     inkex.write(cmd.toAscii()); 
-   
-     // quit the program 
-     inkex.write("quit\n"); 
-     inkex.waitForBytesWritten(); 
-     inkex.waitForFinished(); 
-   
-     // exit 
-     app.quit(); 
-     return 0; 
- } 
        int main(int argc, char* argv[]) {
    // create application
    QCoreApplication app(argc, argv);
    QTextStream out(stdout, QIODevice::Unbuffered | QIODevice::WriteOnly);
    QProcess inkex;
    QStringList arguments;
    QString os_program = QDir::toNativeSeparators ("E:/_Inkscape/inkscape.exe");
    arguments << "--shell" << "--without-gui";
    // start the program
    inkex.setProcessChannelMode(QProcess::ForwardedChannels);
    inkex.start (os_program, arguments, QIODevice::ReadWrite | QIODevice::Unbuffered);
    inkex.waitForStarted();
    // query the version
    inkex.write("--version\n");
    // export a file to png
    QString svgfile=QDir::toNativeSeparators("E:/_Development/Cpp/RxBuilder/test/test_twee.svg");
    QString pngfile=QDir::toNativeSeparators("E:/_Development/Cpp/RxBuilder/test/test_twee.png");
    QString cmd="--file=\"%1\" --export-png=\"%2\" --export-area=0:0:1042:768\n";
    cmd=cmd.arg(svgfile).arg(pngfile);
    out << "---" << endl;
    out << cmd << endl;
    out << "---" << endl;
    inkex.write(cmd.toAscii());
    // quit the program
    inkex.write("quit\n");
    inkex.waitForBytesWritten();
    inkex.waitForFinished();
    // exit
    app.quit();
    return 0;
}
To copy to clipboard, switch view to plain text mode 
  
The expected result is that the version is displayed and an png-image is created based on the svg-image. However that line never is executed. When the application exits only the version is displayed.
The commandline is not the problem. If I strip the call to:
	
	- inkex.write("--version\n"); 
        inkex.write("--version\n");
To copy to clipboard, switch view to plain text mode 
  
Inkscape suddenly responds by generating the image. Somehow the first command is actually blocking the execution of the second command. Any idea's on whats wrong here?
Thx.
Ruud
				
			
Bookmarks