Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • Tom
      in reply to: Problem with output ledger type PDF Width
      #28596

      K. I dont think client would accept having multi page pdf output. They need it as Ledger (11/17).

      Also you suggested one solution by adding style to documents with a constraint ,they slightly differ. Actually what ever htmls come, those are reports of their clients. So obviously as there will be huge difference between one report and another report. We cant count on that.

      But as you suggested we shall try to add style while building pdf. So is addStyle method takes care of font and all ?. if not please let me how to use that for my reports.

      Tom
        in reply to: Problem with output ledger type PDF Width
        #28594

        I could understand your explanation to some extent. But here the problem is input HTML files come from 3rd party. We dont generate them . Our job is to get the pdf out of that HTML file. What should i do now?.

        Tom
          in reply to: Problem with output ledger type PDF Width
          #28592

          Well, i had to do lot of trail and error kind of things before i write new comment with my observations on your code.
          Still we are not comfortable with the solution you provided:

          Reason :
          I had kept your modified code and i did some modifications to reduce the time taking by pd4ml to generate the document.

          Your code : ………………..

          for ( int i = 0; i < 40; i++ ) {
          baos.reset();
          int width = 900 + (i * 20);

          ………….
          Changed code : ………………..
          for ( int i = 0; i < 3; i++ ) {
          baos.reset();
          int width = 900 + (i * 425);

          ………….
          I just reduced the number of iterations.

          With either your code or my changed code , i could just expand the content to right side. So that left margin, right margin are in sync (i attached the output PDF).
          The problems i observed are :
          1) I could just increase the space between columns. But text font still remain unreadable. How text was appearing before having this new code , same way text is appearing now. You can see in the attached pdf. We have to increase text font here.

          2) I thought with the fix of text font ,we resolved the issue . But i just changed the input html to another huge html file comparitively. Problem still persists. Here content is not expanding. I see what ever fix we made is for 1st file. again if i change the numbers it starts expanding. Dont know what i should do with this behaviour of code.

          In one line , we might needed a code which should

          1) expand the content to right , i mean left margins should be in sync
          2) text font should be little visible
          3)code should behave same for any input file irrespective of content.

          Tom
            in reply to: Problem with output ledger type PDF Width
            #28590

            I just replaced with your code . Firstly document is getting generated with a size of 0kb by taking 10 sec to 12 secs time. When i try to open it obviously it is showing file is damaged.

            if you want i can provide you my input html .

            Please suggest the solution for this problem or give a conclusion on this regard. We need to tell the same to our client as soon as possible.

            The following is the code i used

            java.io.FileOutputStream fos = new java.io.FileOutputStream(outputPDFFile); PD4ML pd4ml = new PD4ML();
            pd4ml.fitPageVertically();
            pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.LEDGER)); // ledger page orientation
            double desiredRatio = (double)PD4Constants.LEDGER.width / PD4Constants.LEDGER.height;
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            for ( int i = 0; i < 40; i++ ) {
            
            int width = 900 + (i * 20);
            pd4ml.setHtmlWidth( width );
            
            pd4ml.render("file:" + inputHTMLFileName, baos);
            
            int height = ((Long)pd4ml.getLastRenderInfo(PD4Constants.PD4ML_DOCUMENT_HEIGHT_PX)).intValue();
            //width = ((Long)pd4ml.getLastRenderInfo(PD4Constants.PD4ML_RIGHT_EDGE_PX)).intValue(); // for special cases
            
            double actualRatio = (double)width /  height;
            if ( actualRatio < desiredRatio * 1.1 && actualRatio > desiredRatio * 0.9 ) {
            break;
            }
            
            baos.reset();
            }
            
            fos.write( baos.toByteArray() );
            fos.close();

            Tom
              in reply to: Problem with output ledger type PDF Width
              #28588

              Thanks for you reply..

              Now i removed pd4ml.adjustHtmlWidth() call. Yes you are right. I need to fill a single page horizontally and vertically with the document content. In the attached output pdf in my previous thread you can see content is not expanding to the right.

              Also i couldnot understand this ByteArrayOutputStream . I could only get output pdf if i use fileoutputstream object.

              I hope you understood the problem iam facing. Vertically it is coming fine. When it comes to horizontally content is not expanding 100%.

              Could you please suggest me code to use ByteArrayoutputstream .

              As of now this is my current code..

              java.io.FileOutputStream fos = new java.io.FileOutputStream("C:/ouputPdf.pdf");
              
              PD4ML pd4ml = new PD4ML();
              
              pd4ml.fitPageVertically();
              
              pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.LEDGER));
              
              pd4ml.render("file:" + inputHTMLFileName, fos );

              Tom
                in reply to: Problem with output ledger type PDF Width
                #28586

                Adding to the below issue, i would like to add my output pdf file for better understanding on the problem. Please let me know if you require input html file

                We want whole pdf content to expand to its right.

              Viewing 6 posts - 1 through 6 (of 6 total)