how to choose the PDF page to import

Previous topic - Next topic

pierre77

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()

pierre77

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

a.l.e

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 :-)

pierre77

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]

Coeur Noir

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.

pierre77

@coeur noir:
F2 / properties / image / Page Number

carusoswi