Estou usando o pdfview....alguem sabe como eu concateno as paginas?
// draw the first page to an imagePDFPagepage=pdffile.getPage(0);intnpages=pdffile.getNumPages();System.out.println("Paginas :"+npages);//get the width and height for the doc at the default zoom Rectanglerect=newRectangle(0,0,(int)page.getBBox().getWidth(),(int)page.getBBox().getHeight());//generate the imageImageimg=page.getImage(rect.width,rect.height,//width & heightrect,// clip rectnull,// null for the ImageObservertrue,// fill background with whitetrue// block until drawing is done);
Só consigo mostrar as paginas separadas......Preciso juntar todas elas em uma unica imagem!! :roll:
Ja fiz isso, se nao me engano era essa classe que peguei da internet
/* * $Id: Concatenate.java 2441 2006-10-27 17:24:01Z xlv $ * $Name$ * * This code is free software. It may only be copied or modified * if you include the following copyright notice: * * This class by Mark Thompson. Copyright (c) 2002 Mark Thompson. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *//** * This class demonstrates copying a PDF file using iText. * @author Mark Thompson */packagecom.lowagie.examples.general.copystamp;importjava.io.FileOutputStream;importjava.util.ArrayList;importjava.util.List;importcom.lowagie.text.Document;importcom.lowagie.text.pdf.PRAcroForm;importcom.lowagie.text.pdf.PdfCopy;importcom.lowagie.text.pdf.PdfImportedPage;importcom.lowagie.text.pdf.PdfReader;importcom.lowagie.text.pdf.SimpleBookmark;/** * Tool that can be used to concatenate existing PDF files. */publicclassConcatenate{/** * This class can be used to concatenate existing PDF files. * (This was an example known as PdfCopy.java) * @param args the command line arguments */publicstaticvoidmain(Stringargs[]){if(args.length<2){System.err.println("arguments: file1 [file2 ...] destfile");}else{System.out.println("PdfCopy example");try{intpageOffset=0;ArrayListmaster=newArrayList();intf=0;StringoutFile=args[args.length-1];Documentdocument=null;PdfCopywriter=null;while(f<args.length-1){// we create a reader for a certain documentPdfReaderreader=newPdfReader(args[f]);reader.consolidateNamedDestinations();// we retrieve the total number of pagesintn=reader.getNumberOfPages();Listbookmarks=SimpleBookmark.getBookmark(reader);if(bookmarks!=null){if(pageOffset!=0)SimpleBookmark.shiftPageNumbers(bookmarks,pageOffset,null);master.addAll(bookmarks);}pageOffset+=n;if(f==0){// step 1: creation of a document-objectdocument=newDocument(reader.getPageSizeWithRotation(1));// step 2: we create a writer that listens to the documentwriter=newPdfCopy(document,newFileOutputStream(outFile));// step 3: we open the documentdocument.open();}// step 4: we add contentPdfImportedPagepage;for(inti=0;i<n;){++i;page=writer.getImportedPage(reader,i);writer.addPage(page);}PRAcroFormform=reader.getAcroForm();if(form!=null)writer.copyAcroForm(reader);f++;}if(!master.isEmpty())writer.setOutlines(master);// step 5: we close the documentdocument.close();}catch(Exceptione){e.printStackTrace();}}}}
R
Raarm
Vlw ffranceschi…Onde vc arrumou estas classes com.lowagie.text.pdf.*???
F
ffranceschi
eu usei algo parecido uns 3 anos atrás, e agora eu busquei no www.google.com por “pdf concat java”
se a classe que usei nao foi a mesma, parecida com certeza é!
No meu caso eu tive que montar contrato dinamicos, onde variava a capa do contrato (com nome da empresa), que depois eu concatanava o corpo do contrato que era padrão pra todos os clientes, e na ultima folha com o preço variava tb de acordo com a escolha do plano. Entao usei isso pra juntar tudo
[]´s
Q
qmx
procura por itext, a biblioteca de manipulação de pdf’s