[scribus] corrupted pdf exported using python

kuba kuba kuba456 at gmail.com
Fri May 15 14:12:39 CEST 2009

Ok got it sorted. I need to reinitiate the instance of PDFfile every loop -
then everything works fine :)a.l.e - sorry for the code. I knew pasting is
not the best idea. Can I sent attachments to the mailing list?. Anyway here
is the script if anyone interested.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import scribus
import string, time
import unicodedata

def remove_accents(str):
    nkfd_form = unicodedata.normalize('NFKD', unicode(str))
    only_ascii = nkfd_form.encode('ASCII', 'ignore')
    return only_ascii


### Set which layers to exclude from eksport


### Some layers have unicode characters - need to remove them
### Otherwise will get heap of errors down the road
layersClean = []
for i in layers:

print layers

### Prepare directory path
print fileOld
print fileList
fileDir = "/".join(fileList)
print fileDir

for i in range(0,len(layers)):
### swich on only the layer beeing processed
### this layer will be only exported
 ### create instance of the PDFfile class
### Need to be recreated per exported file
pdf = scribus.PDFfile()
print i
 ### use "layersClean" for pdf files naming
fileName = fileDir+"/"+layersClean[i]+".pdf"
#print fileName
pdf.file = fileName
print "pdf fileName to export:", pdf.file
 ### Switch of the layer export off

On Fri, May 15, 2009 at 12:44 PM, a.l.e <ale.comp_06 at xox.ch> wrote:

> dear kuba kuba,
>  Hello everyone,My first post here. Has anyone ever had any problems
>> with outputting pdf files using PDFfile class in scribus python? The
>> problem
>> I've run into while exporting each layer as a separate pdf is that all
>> generated files but the first one are corupted? Any idea? I must be doing
>> something stupid... Here it goes a snippet of my script. Much appreciate
>> for
>> any advice.
>> for i in layers:
>> fileName = fileDir+'/'+i+'.pdf'
>> pdf.file = fileName # sets the new file name to export
>> print "pdf fileName to export:", pdf.file
>> pdf.save() # instance of scribus.PDFfile() class
>> PS. Just noticed for loop works independently from pdf.save.... somehow
> i guess you first need some proper indenting :-)
> as pasted here the code will probably just create one pdf with the whole
> document (but i have no idea what are you doing before and afterwards)
> have fun
> a.l.e
> _______________________________________________
> scribus mailing list
> scribus at lists.scribus.net
> http://lists.scribus.net/mailman/listinfo/scribus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20090515/bd7fe533/attachment.htm>

More information about the scribus mailing list