Announcement

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

    PDF grid not rendered a a table

    SmartClient Version: v8.2p_2012-04-12/EVAL Deployment (expires 2012.06.11_05.20.12) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    I have a formatting issue trying to generate a pdf from a grid.

    The example code below is based on the 'Print Grid' example in the showcase
    http://www.smartclient.com/smartgwt/showcase/#featured_print_grid
    I've added a PDF export button to this example, the pdf is created but the pdf it has generated is not formatted as a table.
    Attached is a screenshot of the generated pdf.
    I've used the libraries from the evaluation download:
    <classpathentry kind="var" path="SGWTEE_HOME/lib/isomorphic_contentexport.jar"/>
    <classpathentry kind="var" path="SGWTEE_HOME/lib/iText-2.0.8.jar"/>
    <classpathentry kind="var" path="SGWTEE_HOME/lib/jtidy-r938.jar"/>

    Code:
    CountryXmlDS countryDS = CountryXmlDS.getInstance();  
    				  
    SectionStack printStack = new SectionStack();  
    printStack.setVisibilityMode(VisibilityMode.MULTIPLE);  
    printStack.setWidth(400);  
    printStack.setHeight(455);  
    
    
    final DetailViewer printViewer = new DetailViewer();  
    printViewer.setDataSource(countryDS);  
    printViewer.setWidth100();  
    printViewer.setMargin(15);  
    printViewer.setEmptyMessage("Select a country to view its details");  
    
    final ListGrid printGrid = new ListGrid();  
    printGrid.setHeight(150);  
    
    printGrid.setDataSource(countryDS);  
    
    ListGridField countryCode = new ListGridField("countryCode", "Code", 50);  
    ListGridField countryName = new ListGridField("countryName", "Country");  
    ListGridField capital = new ListGridField("capital", "Capital");  
    ListGridField continent = new ListGridField("continent", "Continent");  
    printGrid.setFields(countryCode, countryName, capital, continent);  
    
    printGrid.addRecordClickHandler(new RecordClickHandler() {  
    	public void onRecordClick(RecordClickEvent event) {  
    		printViewer.setData(new Record[]{event.getRecord()});  
    	}  
    });  
    
    SectionStackSection countriesSection = new SectionStackSection("Countries");  
    countriesSection.setExpanded(true);  
    countriesSection.addItem(printGrid);  
    printStack.addSection(countriesSection);  
    
    SectionStackSection detailsSection = new SectionStackSection("Country Details");  
    detailsSection.setExpanded(true);  
    detailsSection.addItem(printViewer);  
    printStack.addSection(detailsSection);  
    
    
    final VLayout printContainer = new VLayout(10);  
    
    
    HLayout printButtonLayout = new HLayout(5);  
    
    IButton newButton = new IButton("New");  
    newButton.setDisabled(true);  
    IButton changeButton = new IButton("Change");  
    changeButton.setDisabled(true);  
    IButton printPreviewButton = new IButton("Print Preview");  
    printPreviewButton.addClickHandler(new ClickHandler() {  
    	public void onClick(ClickEvent event) {  
    		Canvas.showPrintPreview(printContainer);  
    	}  
    });  
    IButton pdfButton = new IButton("Export to PDF");  
    pdfButton.addClickHandler(new ClickHandler() {  
    	public void onClick(ClickEvent event) {  
    		DSRequest requestProperties = new DSRequest();
    		requestProperties.setExportFilename("pdfgrid");
    		requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
    		//requestProperties.setContentType("application/pdf");
    		//requestProperties.setDownloadResult(true);
    		RPCManager.exportContent(printContainer, requestProperties); 
    	}  
    });  
    printButtonLayout.addMember(newButton);  
    printButtonLayout.addMember(changeButton);  
    printButtonLayout.addMember(printPreviewButton);  
    printButtonLayout.addMember(pdfButton);
    
    
    printContainer.addMember(printStack);  
    printContainer.addMember(printButtonLayout);  
    
    
    // The filter is just to limit the number of records in the ListGrid - we don't want to print them all  
    printGrid.filterData(new Criteria("CountryName", "land"), new DSCallback() {  
    	public void execute(DSResponse response, Object rawData, DSRequest request) {  
    		printGrid.selectRecord(0);  
    		printViewer.setData(new Record[]{printGrid.getSelectedRecord()});  
    	}  
    });  
    
    printContainer.draw();
    Attached Files

    #2
    We've tried your code, and we're not reproducing the problem.

    It's hard to imagine how this output is possible, since no CSS settings could possibly cause an HTML table to render like that.

    Comment

    Working...
    X