www.webdeveloper.com
Results 1 to 7 of 7

Thread: Print a PDF generated by FPDF directly

  1. #1
    Join Date
    Apr 2007
    Posts
    3

    Print a PDF generated by FPDF directly

    Dear All,

    Would anyone help to show me the direction to print a PDF generated by FPDF directly with/without printer prompt?

    I have searched the nets for hours... it seems that there are 2 solutions

    1. Open the downloaded PDF in iframe either hidden or a small window, then print it by Javascript
    2. Or using the javascript-enabled PDF browser to print the PDF by in-bed javascript

    Both solutions are lack of further information. Did anyone try these successfully before?

  2. #2
    Join Date
    Apr 2007
    Posts
    3
    hee... hee...

    finally, I found it la...

  3. #3
    Join Date
    Jan 2008
    Posts
    1

    Can you help me out

    Quote Originally Posted by topcater
    Dear All,

    Would anyone help to show me the direction to print a PDF generated by FPDF directly with/without printer prompt?

    I have searched the nets for hours... it seems that there are 2 solutions

    1. Open the downloaded PDF in iframe either hidden or a small window, then print it by Javascript
    2. Or using the javascript-enabled PDF browser to print the PDF by in-bed javascript

    Both solutions are lack of further information. Did anyone try these successfully before?
    I am facing the same problem, can you plz tell or point me to the solution.

  4. #4
    Join Date
    Jul 2008
    Posts
    1
    please help.... same problem

    "print a PDF generated by FPDF directly with/without printer prompt"

    please.....

    thank you

    ryn112289@yahoo.com

  5. #5
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    There isn't one since you need the print dialog box to tell it where you want it to print and whether you want it to resize to fit the paper in that printer. You can't print ANY PDF without the print dialog displaying.
    Stephen

  6. #6
    Join Date
    Nov 2009
    Posts
    1

    Printing with fpdf

    here's an additional class to FPDF for including javascript. where in you can do wonderful things like.. print!

    just include a couple functions that extend FPDF and call IncludeJS() with your acrobat javascript..

    PHP Code:
    class paperpdf extends FPDF {
        var 
    $javascript;
        var 
    $n_js;

        function 
    IncludeJS($script) {
            
    $this->javascript=$script;
        }

        function 
    _putjavascript() {
            
    $this->_newobj();
            
    $this->n_js=$this->n;
            
    $this->_out('<<');
            
    $this->_out('/Names [(EmbeddedJS) '.($this->n+1).' 0 R]');
            
    $this->_out('>>');
            
    $this->_out('endobj');
            
    $this->_newobj();
            
    $this->_out('<<');
            
    $this->_out('/S /JavaScript');
            
    $this->_out('/JS '.$this->_textstring($this->javascript));
            
    $this->_out('>>');
            
    $this->_out('endobj');
        }

        function 
    _putresources() {
            
    parent::_putresources();
            if (!empty(
    $this->javascript)) {
                
    $this->_putjavascript();
            }
        }

        function 
    _putcatalog() {
            
    parent::_putcatalog();
            if (!empty(
    $this->javascript)) {
                
    $this->_out('/Names <</JavaScript '.($this->n_js).' 0 R>>');
            }
        }

    Simple page to demonstrate..
    PHP Code:
    $paperpdf = new paperpdf;
    $paperpdf->AddPage('P');
    $paperpdf->SetMargins(0,0,0);
    $paperpdf->SetFont('Arial','','10');
    $paperpdf->SetXY(50,20);
    $paperpdf->Write('I am going to print');

    $paperpdf->IncludeJS("print('true');");

    $paperpdf->Output('foobar.pdf','I'); 

  7. #7
    Join Date
    Apr 2013
    Posts
    26
    i can share with the way i do it, but we don't use the same software. i think the ways to print pdf files are almost same , so it might serve as reference for you.

    using System.IO;
    using System.Drawing.Printing;
    using RasterEdge.Imaging;
    using RasterEdge.Imaging.Processing;
    using RasterEdge.Imaging.Pdf;

    RasterEdgeImaging PDF = new RasterEdgeImaging();

    public void PdfProcessorPrint();
    {
    PDFInputFile = (@"C:/1.pdf");
    Printer = (@"C:/HP Color LaserJet 5550 PCL 6");
    };
    PDF. PdfProcessorPrint(@"C:/1.pdf", @"C:/HP Color LaserJet 5550 PCL 6");

    using System.IO;
    using System.Drawing.Printing;
    using RasterEdge.Imaging;
    using RasterEdge.Imaging.Processing;
    using RasterEdge.Imaging.Pdf;

    RasterEdgeImaging PDF = new RasterEdgeImaging();

    public void PdfProcessorPrint();
    {
    PDFInputFile = (@"C:/1.pdf");
    PDFPageNumberStart = "0";
    PDFPageNumberStop = "4";
    Printer = (@"C:/ HP Color LaserJet 5550 PCL 6");
    };
    PDF. PdfProcessorPrint(@"C:/1.pdf", "0","4", @"C:/ HP Color LaserJet 5550 PCL 6");

    i hope that can be helpful. good luck

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles