Scribus Forums

Scribus => Scripts and Plugins => Topic started by: pierre77 on July 29, 2012, 02:20:31 PM

Title: how to choose the PDF page to import
Post by: pierre77 on July 29, 2012, 02:20:31 PM
Hello,
How did you choose to pdf page inserted into a picture frame
I tested several code found on the internet, but without success (as xx.getPage (x))

I simplified THE SCRIPT: create a document with 2 frame (p1 and p2 of the pdf document)

but always page 1

#!/usr/bin/env python

import sys
import string
import scribus
import os
from pyPdf import PdfFileReader

imageFile = scribus.fileDialog('Select PDF Directory','PDF (*.pdf *.PDF)')

scribus.newDoc((450,320),(15,15,11.5,11.5),scribus.PORTRAIT,1, scribus.UNIT_MILLIMETERS, scribus.NOFACINGPAGES, scribus.FIRSTPAGELEFT)
a = scribus.createImage(15, 11.5, 210, 297,'image_a')
scribus.loadImage(imageFile, a)
b = scribus.createImage(225, 11.5, 210, 297,'image_b')
scribus.loadImage(imageFile, b)
scribus.setRedraw(1)
scribus.redrawAll()
Title: Re: how to choose the PDF page to import
Post by: pierre77 on July 30, 2012, 01:09:16 PM
Hello,
this is the first time I use the scrypts in scribus (and also the first in python)
I do not know if I should use pypdf. in the readme file pypdf, it is written:
Example:
    from pyPdf import PdfFileWriter, PdfFileReader
    output = PdfFileWriter()
    input1 = PdfFileReader(file("document1.pdf", "rb"))
    # add page 1 from input1 to output document, unchanged
    output.addPage(input1.getPage(0))
...
...
...

I tried several combinations, but without success
input1 = PdfFileReader(file(imageFile, "rb"))
outputa = PdfFileWriter()
outputa.addPage(input1.getPage(2))
page5 = input1.getPage(4)

scribus.newDoc((450,320),(15,15,11.5,11.5),scribus.PORTRAIT,1, scribus.UNIT_MILLIMETERS, scribus.NOFACINGPAGES, scribus.FIRSTPAGELEFT)
a = scribus.createImage(15, 11.5, 210, 297,'image_a')
scribus.loadImage(outputa, a)
b = scribus.createImage(225, 11.5, 210, 297,'image_b')
scribus.loadImage(page5, b)


the alternative would be to split the file into as many page pdf, but I preferred to use a single file if possible.
It would be to impose a brochure (2 pages per sheet) and crop the following pdf bleed

if you have any feedback, thank you in advance
Title: Re: how to choose the PDF page to import
Post by: a.l.e on July 30, 2012, 01:23:08 PM
hi pierre,

i don't fully get what you're trying to do...

some sort of imposition of a pdf inside of scribus?

just some hints:
- you don't need pyPdf to export a pdf from a scribus script
- it's probably not possible (yet) to choose from a script the page of a pdf loaded into an image frame
- exporting each page in an individual file and then loading each page is probably the way to go (and probably the most effective way to solve the problem, if you are trying to impose a pdf created by scribus)

and for the good news of the day: there is scribus user who is working on real imposition inside of scribus... but it won't be released before 1.6... so it's for the (hopefully not too distant) future :-)
Title: Re: how to choose the PDF page to import
Post by: pierre77 on July 30, 2012, 08:47:03 PM
Hi,
It is to impose a pdf file in scribus, for example:
  - I import a pdf file of eight A4 pages plus bleed (what you see in magenta) on a document format scribus supperior to A3 (450x320mm instead of 420x297mm)
  - I put the 8 & 1 page pdf on the scribus page1
  - I cut the 8 pdf on the right and the 1on the left to remove the bleed
  - I again provided there has pages



Quoteand for the good news of the day: there is scribus user who is working on real imposition inside of scribus.
this is a very good news, the next great

I will continue the script to import a folder containing several pdf.

[attachment deleted by admin]
Title: Re: how to choose the PDF page to import
Post by: Coeur Noir on August 12, 2012, 05:17:59 PM
I'm looking for the same functionnality.

If I import one pdf file into a image box in my scribus document, I want to choose which page from the pdf will be displayed - it is possible in some other known softwares...

For the moment it only imports first page from the pdf.
Title: Re: how to choose the PDF page to import
Post by: pierre77 on August 13, 2012, 08:23:50 AM
@coeur noir:
F2 / properties / image / Page Number
Title: Re: how to choose the PDF page to import
Post by: carusoswi on August 28, 2012, 10:17:05 AM
 ;) Thanks!