5 Replies Latest reply on Dec 10, 2013 4:36 PM by Ado

    missing rotated text in PDF created via FPDF

    anupam82

      Hi guys,

      I have a weird problem which is preventing some rotated text to be viewed in adobe reader, while every other reader like foxit, google pdf viewer and scrib are doing just fine!

       

      if you create a flyer using following link

      http://www.erupert.ca/classifieds/create_flyer/ad/32_1306248214

       

      the generated PDF displays just fine in google document viewer but if I download and open the same in Adobe reader the pull tab text (text rorated 90 degrees) vanish, again the PDF is just fine in foxit reader as well!

       

      What am I doing wrong, any ideas would be much appriciated.

       

      Also here is the code to rotate text I'm using by extending the FPDF class

       

      ------------------------------------------------------------------------

       

      function Rotate($angle,$x=-1,$y=-1)

      {

      if($x==-1) $x=$this->x;

              if($y==-1) $y=$this->y; //echo "{$this->x} - {$this->y}";die();

              if($angle!=0) $this->_out('Q');

              $angle=$angle;

              if($angle!=0)

              {

      $angle*=M_PI/180;

      $c=cos($angle);

      $s=sin($angle);

      $cx=$x*$this->k;

      $cy=($this->h-$y)*$this->k;

       

      $this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));

      }

      }

      ------------------------------------------------------------------------
      OS: Windows Any ( >= XP)
      Adobe version X (latest updates)
      http://www.erupert.ca/images/flyer_on_foxit.png
      http://www.erupert.ca/images/flyer_on_foxit.png
      Thanks,
      Anupam
        • 1. Re: missing rotated text in PDF created via FPDF
          George_Johnson MVP & Adobe Community Professional

          There is a syntax error in the document. When you run Preflight in Acrobat on a file to check for syntax errors, it reports an "unbalanced q and Q operators" error.

          1 person found this helpful
          • 2. Re: missing rotated text in PDF created via FPDF
            anupam82 Level 1

            Hi George,

            Thanks for the heads up, the truth is that I am a dumb newbie when it comes to PDF structuring so I have no idea how to fix unbaanced qQ operators! I'll google it and try to get a solution. Do you have any resources which I can study to learn what I did wrong.

             

            Thanks in advance,

            Anupam

            • 3. Re: missing rotated text in PDF created via FPDF
              George_Johnson MVP & Adobe Community Professional

              It's probably nothing you did wrong, but it could be due to a flaw in the software that's used to create the PDF. I don't have any specific suggestions that might help you fix this problem. Maybe you can contact the people who supply the API to see if it's due to a bug in their software.

              1 person found this helpful
              • 4. Re: missing rotated text in PDF created via FPDF
                anupam82 Level 1

                ok I'll try that for sure, thank you very much for the suggestion, it helped a lot!

                • 5. Re: missing rotated text in PDF created via FPDF
                  Ado Level 1

                  Hello anupam,

                   

                  I know this is a particularly old thread, however i thought i'd post the solution here for others who may have been searching around for a solution to this very same problem and come across this thread.

                  As George has correctly stated it is an issue with the unbalanced q and Q operators. I recognise the provided piece of code, it is of course a snippet from a generation class such as FPDF or TCPDF or HTML2PDF, the error occurs when the rotation is not returned to 0 before finalising the document.

                   

                  i.e. You would have used something like $pdf -> Rotate(270,60,50) or $this -> Rotate(270,60,50) where 270=the degree of rotation , 60=the x coordinate , 50=the y coordinate.

                  Once you've completed writing all your text, lines, images, cells you need to make sure to reset the rotate i.e. $pdf -> Rotate(0) prior to Outputting the pdf to screen or saving it as a file.