Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/a34c9390f6d32a3462402bbb30d9ecaf to your computer and use it in GitHub Desktop.
Save GroupDocsGists/a34c9390f6d32a3462402bbb30d9ecaf to your computer and use it in GitHub Desktop.
// For complete examples and data files, please go to https://github.com/groupdocs-parser/GroupDocs.Parser-for-Java
// Create a table layout
TableAreaLayout templateLayout = new TableAreaLayout();
// with 4 columns:
templateLayout.getVerticalSeparators().add(0.0);
templateLayout.getVerticalSeparators().add(25.0);
templateLayout.getVerticalSeparators().add(150.0);
templateLayout.getVerticalSeparators().add(180.0);
templateLayout.getVerticalSeparators().add(230.0);
// and with 5 rows:
templateLayout.getHorizontalSeparators().add(0.0);
templateLayout.getHorizontalSeparators().add(15.0);
templateLayout.getHorizontalSeparators().add(30.0);
templateLayout.getHorizontalSeparators().add(45.0);
templateLayout.getHorizontalSeparators().add(60.0);
templateLayout.getHorizontalSeparators().add(75.0);
// Print a rectangle
Rectangle rect = templateLayout.getTableRectangle();
// Prints: pos: (0, 0) size: (230, 75)
System.out.printf("pos: (%f, %f) size: (%f, %f) \r", rect.getLeft(), rect.getTop(), rect.getWidth(), rect.getHeight());
// Move layout to the definite table location
TableAreaLayout movedLayout = templateLayout.moveTo(315, 250.0);
// Ensure that the first separators are moved:
System.out.println(movedLayout.getVerticalSeparators().get(0)); // prints: 315
System.out.println(movedLayout.getHorizontalSeparators().get(0)); // prints: 250
Rectangle movedRect = movedLayout.getTableRectangle();
// Prints: pos: (315, 250) size: (230, 75)
System.out.printf("pos: (%f, %f) size: (%f, %f) \r", movedRect.getLeft(), movedRect.getTop(), movedRect.getWidth(), movedRect.getHeight());
// movedLayout object is a copy of templateLayout object, thus we can tune separators without the impact on the original layout:
movedLayout.getHorizontalSeparators().add(90.0);
System.out.println(movedLayout.getHorizontalSeparators().size()); // prints: 7
System.out.println(templateLayout.getHorizontalSeparators().size()); // prints: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment