Probably a printer driver problem.
Best Regards,
Paulo Soares
> -----Original Message-----
> From: Yucom [SMTP:[EMAIL PROTECTED]
> Sent: Thursday, March 27, 2003 10:38
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] Problem with printing out created pdf file
>
> Hi,
>
> I am fairly new to itext, so I assume I made a stupid mistake.
>
> Below you will find my code which creates a pdf file based on an object
> that
> implements the Printable interface. This object may create more than one
> page. After runnen the program, I actualy do get a pdf file, that can be
> opened by Acrobad Reader 5.0 and can also be previewed (all pages are
> there). When I print the file in Acrobad, I get the first page printed,
> and
> all other pages are printed as a blank page.
>
> If I select only a specific page in the printing dialog of Acrobad, the
> page
> gets printed with content, but the remainder pages are again blank.
>
> What am I doing wrong?
>
>
> Thanks for the help.
>
>
> KR,
>
>
> Jan
> /*
> * PdfMaker.java
> *
> * Created on 24 maart 2003, 12:45
> */
>
> /**
> *
> * @author jv
> */
>
> import com.lowagie.text.*;
> import com.lowagie.text.pdf.*;
>
> import java.awt.print.*;
> import java.awt.*;
> import java.io.*;
> import javax.swing.*;
> import javax.swing.filechooser.FileFilter;
> import java.io.File;
> import javax.swing.*;
> import java.awt.*;
> import java.awt.event.*;
>
> public class PdfMaker {
>
> private Document document;
> private PdfWriter writer;
> private FileOutputStream fout;
> private Graphics2D g2;
> private PageFormat pf;
> private Printable target;
> private JFileChooser chooser = new JFileChooser();
> private String nameFile;
> private File outDir;
>
> /** Creates a new instance of PdfMaker */
> public PdfMaker(Printable target,PageFormat pf){
> this.pf = pf;
> this.target=target;
> setTargetFile();
> try{
> DefaultFontMapper mapper = new DefaultFontMapper();
> mapper.insertDirectory("c:\\winnt\\fonts");
> com.lowagie.text.Rectangle rect = new
>
> com.lowagie.text.Rectangle((float)pf.getWidth(),(float)pf.getHeight());
> document = new Document(rect);
>
> fout=new FileOutputStream(outDir.getAbsolutePath()+".pdf");
> writer = PdfWriter.getInstance(document,fout);
> document.open();
> PdfContentByte cb = writer.getDirectContent();
> int w = (int)rect.width();
> int h = (int)rect.height();
> PdfTemplate tp = cb.createTemplate(w, h);
>
> int pageIndex=0;
> try{
> while(true){
> tp = cb.createTemplate(w,h);
> g2 = tp.createGraphics(w, h, mapper);
> tp.setWidth(w);
> tp.setHeight(h);
>
> if(target.print(g2,pf,pageIndex)!=Printable.PAGE_EXISTS)break;
> cb.addTemplate(tp,0,0);
> document.newPage();
> pageIndex++;
> }
> }catch(PrinterException pe){}
> document.close();
>
> }catch(FileNotFoundException fnfe){
> JOptionPane.showMessageDialog(new JFrame(),
> fnfe.getMessage());
> }
> catch(DocumentException de){
> System.out.println("Mislukt");
> }
> }
>
> private void setTargetFile(){
> nameFile=null;
> chooser.setSelectedFile(null);
> outDir = new File("/Reports");
> chooser.setCurrentDirectory(outDir);
>
> chooser.addChoosableFileFilter(new PdfFileFilter());
> FileFilter ft = chooser.getAcceptAllFileFilter();
> chooser.removeChoosableFileFilter(ft);
> JFrame frame = new JFrame();
> //
> if(chooser.showOpenDialog(frame)!=JFileChooser.APPROVE_OPTION)return;
> try{
> chooser.showOpenDialog(frame);
> nameFile = chooser.getSelectedFile().getName();
> outDir = chooser.getSelectedFile().getAbsoluteFile();
> }catch(Exception exception){
> JOptionPane.showMessageDialog(new
> JFrame(),exception.getMessage(),"Error",
> JOptionPane.ERROR_MESSAGE);
> }
> }
>
> }
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:
> The Definitive IT and Networking Event. Be There!
> NetWorld+Interop Las Vegas 2003 -- Register today!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions