Zwei Dateien zu einer zusammenf}hren

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
philippjosefrichard
User
Beiträge: 8
Registriert: Freitag 3. Februar 2006, 06:28

Problem: Ich m|chte zwei Dateien zu einer zusammenf}hren, um sie als eine Datei zu drucken
= "Formulardruck mit Daten-Datei und graphischer Hintergrunddatei"

Hat jemand eine Ahnung, wie ich das in python realiseren kann?

Danke f}r Tips
Philipp


Zur Verdeutlichung habe ich hier ein Perl-Script, in dem das funktioniert:

-----------------------------perl-script----------------------

#!/usr/bin/perl
# description:
# creates postscript from plaintext file using background provided in eps
file
# output is generated as postscript, and can easily converted to pdf using
ps2pdf
# optionally a printer name can be given as an argument,
# the file will then be printed using the lpr command

#use encoding "latin-1";
use strict;
use PostScript::Simple;
use PostScript::Simple::EPS;


my $sizex=600;
#HintergrundDatei weiter nach unten
my $sizey=800;
my $x=-5;
my $y=$sizey-30;
my $linepitch=10;
# weil am anmNet2 der Druck zu klein ausf{llt
# VordergrundDatei gr|ßer geschrieben:
my $fontsize=12;
#my $font="Courier";
my $font="Courier-iso";

#print "#" x 70;
#print "\n trendprint v0.1 - copyright 2005 by it-TREND, Michael Wagner\n";
#print "#" x 70;
#print "\n";

if ($#ARGV < 2)
{
print "usage: $0 printfile background output [printer]\n";
print "example: $0 test.txt test.eps /somepath/out.ps lpr0\n";
exit(1);
}
# create postscript object
my $p = new PostScript::Simple(
eps => 0,
xsize => $sizex,
ysize => $sizey,
clip => 1,
colour => 1,
units => "bp",
reencode => "ISOLatin1Encoding");

$p->newpage;

# create an eps object
my $e = new PostScript::Simple::EPS(file => $ARGV[1]) || die "unable to include
background file\n";
# add eps to the current page
$p->importeps($e, -20,-10);

$p->setcolour( "black" );
$p->setfont($font, $fontsize);

# open text file for inserting into postscript
open(INFILE, "<$ARGV[0]") || die "cannot open printfile\n";
my(@lines) = <INFILE>;
my($line);
foreach $line (@lines)
{
$line=~s/\|/\xf6/g;
$line=~s/\\/\xd6/g;
$line=~s/\{/\xe4/g;
$line=~s/\[/\xc4/g;
$line=~s/\}/\xfc/g;
$line=~s/\]/\xdc/g;
$line=~s/\~/\xdf/g;

# print "$line\n";
$p->text($x,$y, $line);
$y-=$linepitch;
}
close(INFILE);

# write the output
$p->output($ARGV[2]) || die "could not write output file\n";
#wal print "created $ARGV[2]\n";

# print if printer was given as an argument
if ($ARGV[3])
{
# print "printing $ARGV[2] to $ARGV[3]\n";
exec("lpr -P $ARGV[3] $ARGV[2]");
}


------------------------- Ende---perl-script----------------------
BlackJack

Das lässt sich wahrscheinlich mit PyX umsetzen.
Antworten