I would like to know if it is possible to remove all margins for a text field whose default value in MSWord is 0.1 inch.The problem with this is that if we set the input text width to 0.2 inch and we want to add a photo with a width of 0.1 of them, it can’t be added. (msword can render it? )
Could you please ZIP and attach your input and expected output Word documents here for our reference? We will then provide you more information about your query.
The Shape.TextBox property defines attributes that specify how text is displayed in a shape.
Please use the following modified code to get the desired output.
final Document doc = new Document();
final DocumentBuilder documentBuilder = new DocumentBuilder(doc);
double oneTenthOfInch = 7.2D;
Shape rootShape = documentBuilder.insertShape(ShapeType.TEXT_BOX, 324,oneTenthOfInch*2 );
rootShape.setWrapType(WrapType.NONE);
rootShape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
rootShape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
rootShape.getTextBox().setInternalMarginRight(0);
rootShape.getTextBox().setInternalMarginLeft(0);
rootShape.getTextBox().setInternalMarginTop(0);
rootShape.getTextBox().setInternalMarginBottom(0);
final Shape img = documentBuilder.insertImage(MyDir + "SLG_9.svg");
img.setHeight(oneTenthOfInch);
img.setWidth(320);
img.setLeft(0);
img.setTop(0);
img.setDistanceLeft(50);
img.setDistanceTop(50);
rootShape.getLastParagraph().appendChild(img);
doc.save(MyDir + "20.6.docx");
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.