c# - set page margins programmatically in crystal report -


i m using crystal report 1 of report. need set margins dynamically report. margins being set user need apply margins programmatically.

i using below code set margins programmatically.

reportdocument rd = new reportdocument(); pagemargins pagemargins = new pagemargins(); pagemargins.leftmargin = 25; pagemargins.topmargin = 100; pagemargins.rightmargin = 25; pagemargins.bottommargin = 50; rd.printoptions.applypagemargins(pagemargins); 

and show preview of print user , user can print. using below code showing preview.

response.buffer = false; response.clearheaders(); response.clearcontent(); rd.exporttohttpresponse(exportformattype.portabledocformat, system.web.httpcontext.current.response, false, "print"); 

above not working me. doesn't apply margins (the same working when set margins statically design -> page setup). shows content if margins not applied when used dynamically. have attached image how being shown preview.

preview of report

can me can problem? why margins not being applied?

i found solution problem. there little change code used earlier. used code below.

reportdocument rd = new reportdocument(); pagemargins margins; // pagemargins structure , set  // margins report. margins = rd.printoptions.pagemargins; margins.bottommargin = 350; margins.leftmargin = 600; margins.rightmargin = 350; margins.topmargin = 300; // apply page margins. rd.printoptions.applypagemargins(margins); 

so above working fine. need report document page margins , set margins there instead of new initialization of pagemargins object.


Comments