Author Topic: how to choose the PDF page to import  (Read 3419 times)

pierre77

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
  • Scribus User
how to choose the PDF page to import
« on: July 29, 2012, 03: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

Code: [Select]
#!/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

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
  • Scribus User
Re: how to choose the PDF page to import
« Reply #1 on: July 30, 2012, 02: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:
Code: [Select]
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
Code: [Select]
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1587
  • Karma: 23
    • the graphics lab
Re: how to choose the PDF page to import
« Reply #2 on: July 30, 2012, 02: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 :-)

pierre77

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
  • Scribus User
Re: how to choose the PDF page to import
« Reply #3 on: July 30, 2012, 09: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



Quote
and 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.

Coeur Noir

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
  • Scribus User
Re: how to choose the PDF page to import
« Reply #4 on: August 12, 2012, 06: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.

pierre77

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
  • Scribus User
Re: how to choose the PDF page to import
« Reply #5 on: August 13, 2012, 09:23:50 am »
@coeur noir:
F2 / properties / image / Page Number

carusoswi

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
  • Scribus User
Re: how to choose the PDF page to import
« Reply #6 on: August 28, 2012, 11:17:05 am »
 ;) Thanks!