Announcement

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

    setting exportCSS to allow PDF to display in landscape mode

    Hello,

    I see in your docs here that you can set PDF to use landscape mode when using exportContent:

    http://www.smartclient.com/docs/10.0/a/b/c/go.html#attr..DSRequest.exportCSS

    However, we are not using the native exportContent API and we are instead calling getPDFRenderer() server-side ourselves like this. I tried to set exportCSS as one of the settings passed to getPdfRenderer but that didn't work. So, how do I set exportCSS in this example to use Landscape mode?


    Code:
    	        settings.put("skinName", exportData.get("skinName").toString());
    			
                    //this didn't work
    	        settings.put("exportCSS", "@page {size: US-Letter landscape; }");
    	        
    		PdfExport export = new PdfExport();
    			
    
    			
    	        ITextRenderer renderer = export.getPdfRenderer(finalHTML,settings);

    #2
    I was able to get this working by including html like in the html sent to getPDFRendered()

    Code:
    			String finalHTML =  "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
    			finalHTML +="<head><style type=\"text/css\">";
    			finalHTML +="@page{size: landscape }";
    			finalHTML +="</style></head><body>";
    If there is a more elegant way to do this, please let me know!

    Comment


      #3
      That's a reasonable approach. We might later add an API providing an explicit way to include extra CSS server-side, but your approach is fine.

      Comment

      Working...
      X