How to align ViewMaster (Vertical) to LEFT side of the page in the word/pdf

We have achieved inserting ViewMaster (vertical) in the document by following below link
How to apply built-in footer style using Aspose Word?
But by default ViewMaster(vertical) is aligning to Right side of the page. But my requirement is to align to Left of the page as show in the attached image.

Posted same question in the stackover and tired couple of code base attached in the below link but not luck.
https://stackoverflow.com/questions/73275816/how-to-align-viewmaster-vertical-to-left-side-of-the-page-in-the-word-pdf

Could some one help us the resolve the same, please free to request more details. thank you

@imsadanala I have checked the scenario on my side once again and position of footer content is changed properly on my side. Here the full code I have used for testing:

Document docBuildingBlocks = new Document("C:\\Users\\alexe\\AppData\\Roaming\\Microsoft\\Document Building Blocks\\1033\\16\\Built-In Building Blocks.dotx");
Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
HeaderFooter hf = doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY);

GlossaryDocument glossaryDocument = docBuildingBlocks.getGlossaryDocument();
for (BuildingBlock buildingBlock : glossaryDocument.getBuildingBlocks())
{
    if (buildingBlock.getGallery() == BuildingBlockGallery.FOOTERS &&
            buildingBlock.getName().equals("ViewMaster (Vertical)"))
    {
        Section sec = (Section)buildingBlock.getFirstChild();
        for (Node node : (Iterable<Node>)sec.getBody().getChildNodes())
            hf.appendChild(doc.importNode(node, true));
    }
}

// Change alignment
moveShapesLeft(hf.getChildNodes(NodeType.SHAPE, true));
moveShapesLeft(hf.getChildNodes(NodeType.GROUP_SHAPE, true));

doc.save("C:\\Temp\\out.docx");
doc.save("C:\\Temp\\out.pdf");
private static void moveShapesLeft(Iterable<ShapeBase> shapes)
{
    for (ShapeBase shape : shapes)
    {
        if (!shape.isTopLevel())
            continue;

        shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.MARGIN);
        shape.setHorizontalAlignment(HorizontalAlignment.LEFT);
    }
}

Here are output documents produced by this code: out.docx (10.5 KB) out.pdf (15.8 KB)

Its works now @alexey.noskov. Thanks a lot for your time and support

And also we are getting Page number inside the VeiwMaster(vertical) as shown in the image and this embedded page number needs to removed. can you help us on this

@imsadanala Page number is represented by PAGE field. So you should simply remove this field:

// Remove page number field from the footer.
for(Field f : hf.getRange().getFields())
{
    if(f.getType() == FieldType.FIELD_PAGE)
        f.remove();
}

If you need to remove whole “black box” with page number, you should remove shape that contains this page number:

// Remove page number field from the footer.
for(Field f : hf.getRange().getFields())
{
    if(f.getType() == FieldType.FIELD_PAGE) {
        Node parentShape = f.getStart().getAncestor(NodeType.SHAPE);
        if(parentShape!=null)
            parentShape.remove();
    }
}
1 Like

code works. thanks again :slight_smile:

1 Like

We wanted change the weight of the vertical line to 1/4 pt in the ViewMaster vertical. can someone help me with the code ?

@imsadanala You can use code like the following to increate weight of the vertical line:

// Get shapes from the footer.
Iterable<Shape> shapes = hf.getChildNodes(NodeType.SHAPE, true);
for (Shape s : shapes)
{
    if (s.getShapeType() == ShapeType.RECTANGLE)
    {
        // Increase width of the shape.
        // Since this shape is inside groupshape its dimensions are in internal group shape coordinates.
        // So we use a scale to increase its width. For example 1.5.
        // You can use the parent GroupShape.CoorsSize to calculate absolute size of shape. 
        s.setWidth(s.getWidth() * 1.5);
    }
}
1 Like

code works. thank you alexey, noskov

1 Like