Skip to content

Instantly share code, notes, and snippets.

@locofocos
Created March 23, 2020 02:05
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 locofocos/362566f0119a68664a3da115aa2d2a80 to your computer and use it in GitHub Desktop.
Save locofocos/362566f0119a68664a3da115aa2d2a80 to your computer and use it in GitHub Desktop.
Sweet Home 3D custom PDF page size snippet, the poor man's way
// in PageSetupPanel
public void updateController(PageSetupController controller) {
// ...
Paper paper = this.pageFormat.getPaper();
float width = 45 * 72; // My desired width is 45 inches
float height = 30 * 72; // My desired height is 30 inches
// float theMargin = (float) ((1.0 / 10.0) * 72.0); // 1/10th of an inch
float theMargin = 0; // 0 inches
float paperTopMargin = theMargin;
float paperLeftMargin = theMargin;
float paperBottomMargin = theMargin;
float paperRightMargin = theMargin;
HomePrint homePrint = new HomePrint(paperOrientation, width, height,
paperTopMargin, paperLeftMargin,
paperBottomMargin,
paperRightMargin,
this.furniturePrintedCheckBox.isSelected(),
this.planPrintedCheckBox.isSelected(),
this.view3DPrintedCheckBox.isSelected(),
this.userPlanScaleRadioButton.isSelected() && this.userPlanScaleSpinner.getValue() != null
? 1f / ((Number)this.userPlanScaleSpinner.getValue()).intValue()
: null,
this.headerFormatTextField.getText().trim(),
this.footerFormatTextField.getText().trim());
controller.setPrint(homePrint);
}
// in HomePrintableComponent
public static PageFormat getPageFormat(HomePrint homePrint) {
// ...
pageFormat.setPaper(paper);
// pageFormat = printerJob.validatePage(pageFormat); // comment out this line
return pageFormat;
}
}
@locofocos
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment