Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Questions about PDF export

    I have a few questions about PDF export.

    1. canExport=true for a field does not export that field for XLS. Should this be the same for PDF? If it should, I will generate a test case as these fields are being exported in the PDF.

    2. I am exporting a listgrid with about 12 columns. The last two fields are being cut off in the PDF. Is there a way to tell the table to fit the page? I see that field values wrap text, but the field titles do not, which could free up some space. I am exporting the listgrid object, should I wrap it in a layout and export the layout? I would like to do this natively as part of the SC API.

    3. Is there a way to tell the PDF to use landscape instead of portrait? Again, I would prefer to do this natively.

    #2
    1. several settings affect which fields are exported, and there's also a difference between exportData() and exportClientData(). If you think something's going wrong, we'd need to see a test case.

    2. you can use ordinary CSS techniques to affect word wrapping, or to use smaller fonts if you are trying to fit a large amount of data on the page

    3. we don't have a setting for this, but you can use DSResponse.getExportObject() to get the generated iText object and modify it using iText APIs.

    Comment


      #3
      SmartClient_SNAPSHOT_v90d_2013-05-10

      Load the following test case, then execute the command:
      Code:
      isc.RPCManager.exportContent(gridObject, { skinName : "EnterpriseBlue",	pdfName : "test" });
      The static field appears in the export. I realize that PDF export uses getPrintHTML(), which generates HTML of the the grid, which includes the static field, but I would expect this to work like XLS export where fields marked as canExport=false do not export.

      I can override the getPrintHTML method of the listgrid, and iterate through each filed, but I just need to know if this is possible to do.

      Code:
      <!DOCTYPE html>
      
      <html>
      <head>
          <title >ExportTest Case</title>
      	
         	<script type="text/javascript" >
      		var isomorphicDir="http://localhost:8080/isomorphic/";
      		
      		var data = [
      			{inspectorID:12345, inspections:206,observations:913,segment: " ",lastInspectionDate:new Date(2012, 8, 13),index:52.6, isLocal:1, inspectionType: {id:123, name:"type1"}},
      			{inspectorID:67890, inspections:66,observations:0,segment: " ",lastInspectionDate:new Date(2013, 02,02),index:75.3, isLocal:1,inspectionType: {id:123, name:"type1"}},
      			{inspectorID:88776, inspections:66,observations:67,segment: " ",lastInspectionDate:new Date(2013,02,03),index:75.3, isLocal:0,inspectionType: {id:123, name:"type1"}},
      			{inspectorID:44556, inspections:206,observations:0,segment: " ", lastInspectionDate:new Date(2012,08,31),index:52.6, isLocal:1,inspectionType: {id:123, name:"type1"}}
      		];
      </script>
      	
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Core.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Foundation.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Containers.js"></script>
        <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Grids.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Forms.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_DataBinding.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Drawing.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_PluginBridges.js"></script> 
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Charts.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Tools.js"></script>
       <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
      	
      </head>
      <body>
      
      	<br><br>
      	<script>
      	
      			var gridObject = isc.ListGrid.create({
      				fields:[
      					{name:"inspectorID", title:"Inspector ID", type:"integer" },
      					{name:"inspections", type:"integer", title:"# Inspections"},
      					{name:"static", type:"string", canExport:false, title:"Static Field"},
      					{name:"observations", type:"integer", title:"# Observations"},
      					{name:"lastInspectionDate", type:"date", title:"Last Inspection"},
      					{name:"isLocal", type:"boolean", title:"Local"},
      					{name:"segment", type:"text", title:"Segment"}
      		
      				],
      				dataFetchMode : "local",
      				data: data,
      				width : "100%",
      				align : "center",
      				autoFitData : "vertical",
      				autoFitMaxHeight : 400,
      				alternateRecordStyles : true,
      				canAddFormulaFields : true,
      				canAddSummaryFields : true,
      				canGroupBy : true,
      				canReorderFields : true,
      				showGroupSummary : true,
      				groupByMaxRecords : 5
      			});	
      
      	
      	</script>
      	<br><br>
      
      </body>
      
      </html>

      Comment


        #4
        As you say, it's the export of the printed output - it's literally exporting HTML without reference to the underlying fields at all. To control what's exported, control the printed output.

        Comment


          #5
          Support for @page CSS

          CSS2 introduced some page rules to control how content is printed. Does SmartClient support these rules? I was trying to use these to force the PDF export to landscape.

          Comment


            #6
            We don't attempt to prevent their use, but it's a question of whether iText (the library we use for PDF rendering) supports them, and how robustly.

            Comment


              #7
              FYI - adding the following to skin_styles.css forces the PDF to display in landscape mode:
              @page {
              size: landscape;
              margin: 1cm 1cm 1cm 1cm;
              }

              Flying saucer also supports other CSS Paged Media styles, and can be found at:
              http://www.w3.org/TR/css3-page/

              Comment

              Working...
              X