c# - OpenXML strange behaviour with font-size -
i using dll create methods generates me logic create paragraph based on parameters passed:
for example on c# code have this:
// document permission title docrun accesstypetitle = new docrun(); run permissiontitle = accesstypetitle.createparagraph("document access", paragraphcolor,fontsizetext,defaultfont);
i have method on dll logic:
public class docrun { public run createparagraph(string text, string colorval, string fontsize,string font) { run run = new run() { rsidrunproperties = "00c53974" }; runproperties runproperties = new runproperties(); runfonts runfonts = new runfonts() { ascii = font, highansi = font, eastasia = "segoe ui", complexscript = font }; color color = new color() { val = colorval }; //kern kern = new kern() { val = (uint32value)24u }; fontsize fontsize11 = new fontsize() { val = fontsize }; fontsizecomplexscript fontsizecomplexscript11 = new fontsizecomplexscript() { val = fontsize }; runproperties.append(runfonts); runproperties.append(color); //runproperties.append(kern); runproperties.append(fontsize11); runproperties.append(fontsizecomplexscript11); text t = new text(text) { text = text, space = spaceprocessingmodevalues.preserve }; run.append(runproperties); run.append(t); return run; } } }
after return run, can same images nd other paragraph , append them doc this:
var stream = new memorystream(); using (wordprocessingdocument doc = wordprocessingdocument.create(stream, wordprocessingdocumenttype.document, true)) { maindocumentpart mainpart = doc.addmaindocumentpart(); // logo company construction docimage companylogo = new docimage(); run imagelogo = companylogo.imagecreator(mainpart,companylogopath,companyimagename,companylogowidth,companylogoheight,companyimagealing); docimage titleshape = new docimage(); run imageshape = titleshape.imagecreator(mainpart, shapeimagepath, titleshapeimagename, titleshapewidth, titleshapeheight,shapeimagealing); docimage clientimage = new docimage(); run clientlogo = titleshape.imagecreatorurl(mainpart, shapeimagepath, titleshapeimagename, titleshapewidthclientlogo, titleshapeheightclientlogo, clientimagealign,clientlogopath); new document(new body()).save(mainpart); body body = mainpart.document.body; body.append(new paragraph( new run(imagelogo))); body.append(new paragraph( new run(imageshape))); body.append(new paragraph( new run(projectnametxt))); body.append(new paragraph( new run(clientlogo))); body.append(new paragraph( new run(datetxt))); body.append(new paragraph( new run(permissiontitle))); body.append(new paragraph( new run(permission))); body.append(new paragraph( new run(disclaimertitletxt))); body.append(new paragraph( new run(disclaimerdescriptiontxt))); mainpart.document.save(); } stream.seek(0, seekorigin.begin); directory.createdirectory(hostingenvironment.mappath(documentslocation)); system.io.file.writeallbytes(hostingenvironment.mappath("~/files/test5.docx"), stream.toarray()); }
my problem document generated font size half of real size defined on openxml dll created.
i debuged fontsize pass parameter , fontsize received on dll correct one, going on?
thanks guys,
the fontsize specified value measures in half-points. if need 11 point font, need specify value 22.
this documented on page 13 in e-book "open xml explained" wouter van vugt.
Comments
Post a Comment