Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions DistFiles/localization/en/BloomMediumPriority.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,19 @@
<trans-unit id="BookSettings.CoverIsImage.Description" sil:dynamic="true">
<source xml:lang="en">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.</source>
<note>BookSettings.CoverIsImage.Description</note>
<note>obsolete as of Bloom 6.3</note>
</trans-unit>
<trans-unit id="BookSettings.CoverIsImage.Description.V2" sil:dynamic="true">
<source xml:lang="en">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.</source>
<note>BookSettings.CoverIsImage.Description.V2</note>
</trans-unit>
<trans-unit id="BookSettings.FullBleed" sil:dynamic="true">
<source xml:lang="en">Use full bleed page layout</source>
<note>BookSettings.FullBleed</note>
</trans-unit>
<trans-unit id="BookSettings.FullBleed.Description" sil:dynamic="true">
<source xml:lang="en">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.</source>
<note>BookSettings.FullBleed.Description</note>
</trans-unit>
<trans-unit id="BookSettings.ContentPagesGroupLabel" sil:dynamic="true">
<source xml:lang="en">Content Pages</source>
Expand Down
52 changes: 50 additions & 2 deletions src/BloomBrowserUI/bookEdit/bookSettings/BookSettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import {
DialogResult,
} from "../../react_components/color-picking/colorPickerDialog";
import {
get,
post,
postJson,
useApiBoolean,
useApiObject,
useApiStringState,
} from "../../utils/bloomApi";
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -479,6 +497,36 @@ export const BookSettingsDialog: React.FunctionComponent<{
/>
</div>
</div>
<div>
<ConfigrBoolean
label={fullBleedLabel}
description={fullBleedDescription}
{...getAdditionalProps<boolean>(
`fullBleed`,
)}
disabled={
appearanceDisabled ||
!tierAllowsFullBleed ||
!pageSizeSupportsFullBleed
}
/>
<div
css={css`
display: flex;
padding-bottom: 5px;
font-size: 12px;
font-weight: bold;
`}
>
<BloomSubscriptionIndicatorIconAndText
feature="PrintshopReady"
css={css`
margin-left: auto;
`}
disabled={appearanceDisabled}
/>
</div>
</div>
<FieldVisibilityGroup
field="cover-title"
labelFrame="Show Title in {0}"
Expand Down
16 changes: 7 additions & 9 deletions src/BloomExe/Book/AppearanceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,8 @@ public string FirstPossiblyOffendingCssFile
requiresXmatterUpdate: true,
valueRequiredIfLegacyTheme: false
), // If true, cover page is just a full bleed image.
// Not implemented yet. When it is, it needs to be tied together with the coverIsImage setting
// such that coverIsImage cannot be true unless fullBleed is also true.
//new BooleanPropertyDef("fullBleed", "fullBleed", false), // If true, book is full bleed.

// If true, book uses full bleed page layout in edit mode. Printing that way is still optional.
new BooleanPropertyDef("fullBleed", "fullBleed", defaultValue: false),
// Does not correspond to a css variable. We will set the relevant page number css variables based on this setting.
new StringPropertyDef(kPageNumberPositionVar, null, PageNumberPosition.Automatic),
new CssStringVariableDef("cover-background-color", "colors"),
Expand Down Expand Up @@ -229,11 +227,11 @@ public bool CoverIsImage
get { return _properties.coverIsImage; }
}

//public bool FullBleed
//{
// get { return _properties.fullBleed; }
// set { _properties.fullBleed = value; }
//}
public bool FullBleed
{
get { return _properties.fullBleed; }
set { _properties.fullBleed = value; }
}

// When this is set to true, we ensure that the xmatter is updated before saving the book.
public bool PendingChangeRequiresXmatterUpdate;
Expand Down
20 changes: 11 additions & 9 deletions src/BloomExe/Book/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,9 @@ private void CreateOrUpdateDefaultLangStyles()
{
var lang = line.Substring(kLangTag.Length, idxQuote - kLangTag.Length);
// Don't let empty language tag creep in (or stay in). (BL-15784)
copyCurrentRule = !String.IsNullOrEmpty(lang) && !languagesWeAlreadyHave.Contains(lang);
copyCurrentRule =
!String.IsNullOrEmpty(lang)
&& !languagesWeAlreadyHave.Contains(lang);
languagesWeAlreadyHave.Add(lang); // don't copy if another css block has crept in.
}
}
Expand Down Expand Up @@ -4048,15 +4050,9 @@ public void InsertFullBleedMarkup(SafeXmlElement body)
this
)
.Enabled;

public bool FullBleed =>
(
// 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;
Expand Down Expand Up @@ -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<Layout> GetSizeAndOrientationChoices()
{
try
Expand Down
12 changes: 12 additions & 0 deletions src/BloomExe/Book/SizeAndOrientation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ private static string ExtractPageSizeName(string nameLower, int startOfOrientati
return name;
}

/// <summary>
/// Determines whether this page size and orientation supports full bleed printing.
/// </summary>
/// <returns>True if full bleed is supported for this size and orientation, false otherwise</returns>
public bool SupportsFullBleed()
{
return Bloom.Publish.PDF.MakePdfUsingExternalPdfMakerProgram.GetFullBleedPageSize(
PageSizeName,
IsLandScape
) != null;
}

public static void AddClassesForLayout(HtmlDom dom, Layout layout)
{
UpdatePageSizeAndOrientationClasses(dom.RawDom, layout);
Expand Down
45 changes: 33 additions & 12 deletions src/BloomExe/Publish/PDF/MakePdfUsingExternalPdfMakerProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,21 @@ void SetArguments(StringBuilder bldr, PdfMakingSpecs specs)
//bldr.Append(" --debug");
}

private static void ConfigureFullBleedPageSize(StringBuilder bldr, PdfMakingSpecs specs)
/// <summary>
/// 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.
/// </summary>
/// <param name="paperSizeName">The name of the paper size (e.g., "A4", "USComic", etc.)</param>
/// <param name="landscape">True if landscape orientation, false if portrait</param>
/// <returns>A tuple of (height, width) in mm, or null if the page size doesn't support full bleed</returns>
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;
Expand Down Expand Up @@ -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}");
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/BloomExe/web/controllers/BookSettingsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down