From 1c7ca69e4cb831c15ed1483ac2ba617e19282a2e Mon Sep 17 00:00:00 2001 From: John Thomson Date: Wed, 4 Feb 2026 12:40:42 -0600 Subject: [PATCH] Add separate control for full bleed layout --- .../localization/en/BloomMediumPriority.xlf | 13 +++++ .../bookSettings/BookSettingsDialog.tsx | 52 ++++++++++++++++++- src/BloomExe/Book/AppearanceSettings.cs | 16 +++--- src/BloomExe/Book/Book.cs | 20 +++---- src/BloomExe/Book/SizeAndOrientation.cs | 12 +++++ .../MakePdfUsingExternalPdfMakerProgram.cs | 45 +++++++++++----- .../web/controllers/BookSettingsApi.cs | 6 +++ 7 files changed, 132 insertions(+), 32 deletions(-) diff --git a/DistFiles/localization/en/BloomMediumPriority.xlf b/DistFiles/localization/en/BloomMediumPriority.xlf index e197f14e0026..11ad53d5314e 100644 --- a/DistFiles/localization/en/BloomMediumPriority.xlf +++ b/DistFiles/localization/en/BloomMediumPriority.xlf @@ -771,6 +771,19 @@ Using this option turns on the [Print Bleed](https://en.wikipedia.org/wiki/Bleed_%28printing%29) indicators on paper layouts. See [Full Page Cover Images](https://docs.bloomlibrary.org/full-page-cover-images) for information on sizing your image to fit. BookSettings.CoverIsImage.Description + obsolete as of Bloom 6.3 + + + Replace the front cover content with a single full-bleed image. See [Full Page Cover Images](https://docs.bloomlibrary.org/full-page-cover-images) for information on sizing your image to fit. + BookSettings.CoverIsImage.Description.V2 + + + Use full bleed page layout + BookSettings.FullBleed + + + Enable full bleed layout for printing. This turns on the [Print Bleed](https://en.wikipedia.org/wiki/Bleed_%28printing%29) indicators on all page layouts. See [Full Bleed Layout](https://docs.bloomlibrary.org/full-bleed) for more information. + BookSettings.FullBleed.Description Content Pages diff --git a/src/BloomBrowserUI/bookEdit/bookSettings/BookSettingsDialog.tsx b/src/BloomBrowserUI/bookEdit/bookSettings/BookSettingsDialog.tsx index 9c2240267d53..28bc7d32fc3e 100644 --- a/src/BloomBrowserUI/bookEdit/bookSettings/BookSettingsDialog.tsx +++ b/src/BloomBrowserUI/bookEdit/bookSettings/BookSettingsDialog.tsx @@ -28,8 +28,10 @@ import { DialogResult, } from "../../react_components/color-picking/colorPickerDialog"; import { + get, post, postJson, + useApiBoolean, useApiObject, useApiStringState, } from "../../utils/bloomApi"; @@ -120,6 +122,11 @@ export const BookSettingsDialog: React.FunctionComponent<{ defaultOverrides, ); + const [pageSizeSupportsFullBleed] = useApiBoolean( + "book/settings/pageSizeSupportsFullBleed", + true, + ); + const xmatterLockedBy = useL10n( "Locked by {0} Front/Back matter", "BookSettings.LockedByXMatter", @@ -256,8 +263,17 @@ export const BookSettingsDialog: React.FunctionComponent<{ "BookSettings.CoverIsImage", ); const coverIsImageDescription = useL10n( - "Using this option turns on the [Print Bleed](https://en.wikipedia.org/wiki/Bleed_%28printing%29) indicators on paper layouts. See [Full Page Cover Images](https://docs.bloomlibrary.org/full-page-cover-images) for information on sizing your image to fit.", - "BookSettings.CoverIsImage.Description", + "Replace the front cover content with a single full-bleed image. See [Full Page Cover Images](https://docs.bloomlibrary.org/full-page-cover-images) for information on sizing your image to fit.", + "BookSettings.CoverIsImage.Description.V2", + ); + + const fullBleedLabel = useL10n( + "Use full bleed page layout", + "BookSettings.FullBleed", + ); + const fullBleedDescription = useL10n( + "Enable full bleed layout for printing. This turns on the [Print Bleed](https://en.wikipedia.org/wiki/Bleed_%28printing%29) indicators on all page layouts. See [Full Bleed Layout](https://docs.bloomlibrary.org/full-bleed) for more information.", + "BookSettings.FullBleed.Description", ); // This is a helper function to make it easier to pass the override information @@ -358,6 +374,8 @@ export const BookSettingsDialog: React.FunctionComponent<{ const tierAllowsFullPageCoverImage = useGetFeatureStatus("fullPageCoverImage")?.enabled; + const tierAllowsFullBleed = useGetFeatureStatus("PrintshopReady")?.enabled; + function saveSettingsAndCloseDialog() { if (settingsToReturnLater) { // If nothing changed, we don't get any...and don't need to make this call. @@ -479,6 +497,36 @@ export const BookSettingsDialog: React.FunctionComponent<{ /> +
+ ( + `fullBleed`, + )} + disabled={ + appearanceDisabled || + !tierAllowsFullBleed || + !pageSizeSupportsFullBleed + } + /> +
+ +
+
- ( - // Wants to be - // BookInfo.AppearanceSettings.FullBleed - // but we haven't put that in the book settings yet. - BookData.GetVariableOrNull("fullBleed", "*").Xml == "true" - || CoverIsImage - ) + PageSizeSupportsFullBleed() + && BookInfo.AppearanceSettings.FullBleed && FeatureStatus .GetFeatureStatus(CollectionSettings.Subscription, FeatureName.PrintShopReady, this) .Enabled; @@ -4641,6 +4637,12 @@ public virtual Layout GetLayout() return Layout.FromDom(OurHtmlDom, Layout.A5Portrait); } + public bool PageSizeSupportsFullBleed() + { + var layout = GetLayout(); + return layout?.SizeAndOrientation?.SupportsFullBleed() ?? false; + } + public IEnumerable GetSizeAndOrientationChoices() { try diff --git a/src/BloomExe/Book/SizeAndOrientation.cs b/src/BloomExe/Book/SizeAndOrientation.cs index 743ee04241c1..4e5f413634b6 100644 --- a/src/BloomExe/Book/SizeAndOrientation.cs +++ b/src/BloomExe/Book/SizeAndOrientation.cs @@ -72,6 +72,18 @@ private static string ExtractPageSizeName(string nameLower, int startOfOrientati return name; } + /// + /// Determines whether this page size and orientation supports full bleed printing. + /// + /// True if full bleed is supported for this size and orientation, false otherwise + public bool SupportsFullBleed() + { + return Bloom.Publish.PDF.MakePdfUsingExternalPdfMakerProgram.GetFullBleedPageSize( + PageSizeName, + IsLandScape + ) != null; + } + public static void AddClassesForLayout(HtmlDom dom, Layout layout) { UpdatePageSizeAndOrientationClasses(dom.RawDom, layout); diff --git a/src/BloomExe/Publish/PDF/MakePdfUsingExternalPdfMakerProgram.cs b/src/BloomExe/Publish/PDF/MakePdfUsingExternalPdfMakerProgram.cs index 3d34aab9e5c2..67bb0a683918 100644 --- a/src/BloomExe/Publish/PDF/MakePdfUsingExternalPdfMakerProgram.cs +++ b/src/BloomExe/Publish/PDF/MakePdfUsingExternalPdfMakerProgram.cs @@ -337,14 +337,21 @@ void SetArguments(StringBuilder bldr, PdfMakingSpecs specs) //bldr.Append(" --debug"); } - private static void ConfigureFullBleedPageSize(StringBuilder bldr, PdfMakingSpecs specs) + /// + /// Returns the height and width (in mm) for page sizes that support full bleed printing. + /// Returns null if the page size does not support full bleed. + /// + /// The name of the paper size (e.g., "A4", "USComic", etc.) + /// True if landscape orientation, false if portrait + /// A tuple of (height, width) in mm, or null if the page size doesn't support full bleed + public static (double height, double width)? GetFullBleedPageSize( + string paperSizeName, + bool landscape + ) { - // We will make a non-standard page size that is 6mm bigger in each dimension than the size indicated - // by the paperSizeName. Unfortunately doing that means we can't just pass the name, we have to figure - // out the size. double height; double width; - switch (specs.PaperSizeName.ToLowerInvariant()) + switch (paperSizeName.ToLowerInvariant()) { case "a5": height = A4PortraitWidth + bleedExtra; @@ -373,21 +380,35 @@ private static void ConfigureFullBleedPageSize(StringBuilder bldr, PdfMakingSpec width = Size6x9PortraitWidth + bleedExtra; break; default: - var exception = new ArgumentException( - "Full bleed printing of paper sizes other than A5, A4, A3, USComic, and Size6x9 is not yet implemented" - ); - exception.Data["argument"] = "specs.PaperSizeName"; - throw exception; + return null; // Page size doesn't support full bleed } - if (specs.Landscape) + if (landscape) { var temp = height; height = width; width = temp; } - bldr.Append($" -h {height} -w {width}"); + return (height, width); + } + + private static void ConfigureFullBleedPageSize(StringBuilder bldr, PdfMakingSpecs specs) + { + // We will make a non-standard page size that is 6mm bigger in each dimension than the size indicated + // by the paperSizeName. Unfortunately doing that means we can't just pass the name, we have to figure + // out the size. + var dimensions = GetFullBleedPageSize(specs.PaperSizeName, specs.Landscape); + if (dimensions == null) + { + var exception = new ArgumentException( + $"Full bleed printing of paper size '{specs.PaperSizeName}' is not yet implemented. Supported sizes are: A5, A4, A3, USComic, HalfFolio, and Size6x9." + ); + exception.Data["argument"] = "specs.PaperSizeName"; + throw exception; + } + + bldr.Append($" -h {dimensions.Value.height} -w {dimensions.Value.width}"); } } diff --git a/src/BloomExe/web/controllers/BookSettingsApi.cs b/src/BloomExe/web/controllers/BookSettingsApi.cs index f6f1639cff70..9feb2fae1e39 100644 --- a/src/BloomExe/web/controllers/BookSettingsApi.cs +++ b/src/BloomExe/web/controllers/BookSettingsApi.cs @@ -62,6 +62,12 @@ public void RegisterWithApiHandler(BloomApiHandler apiHandler) HandleDeleteCustomBookStyles, false ); + apiHandler.RegisterBooleanEndpointHandler( + "book/settings/pageSizeSupportsFullBleed", + request => _bookSelection.CurrentSelection.PageSizeSupportsFullBleed(), + null, + false + ); } private void HandleGetOverrides(ApiRequest request)