Files
mmd-pdf/third_party/PdfSharpCore/Pdf.Advanced/PdfExtGStateTable.cs
kua-agent 6610acfa44 feat: rebrand to MMD PDF, single corporate theme, and remove original text under an edit
- Services/PdfRedactText.cs: strip text whose origin falls inside a CoverAnnotation
  from the page content stream at save time, hooked into PdfBurn.DrawAnnotationsIntoDoc.
  Fixes edited values staying recoverable by text extraction.
- Themes/MMD.xaml replaces all thirteen themes; picker and accent strip removed; no dark mode.
- Rename KillerPDF -> MMD PDF across code, resources, packaging and locale strings; new icon.
- Remove the upstream author credit and the in-app install button.
2026-08-27 07:37:09 +02:00

113 lines
4.5 KiB
C#

#region PDFsharp - A .NET library for processing PDF
//
// Authors:
// Stefan Lange
//
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
//
// http://www.PdfSharpCore.com
// http://sourceforge.net/projects/pdfsharp
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#endregion
using System.Collections.Generic;
namespace PdfSharpCore.Pdf.Advanced
{
/// <summary>
/// Contains all used ExtGState objects of a document.
/// </summary>
public sealed class PdfExtGStateTable : PdfResourceTable
{
/// <summary>
/// Initializes a new instance of this class, which is a singleton for each document.
/// </summary>
public PdfExtGStateTable(PdfDocument document)
: base(document)
{ }
/// <summary>
/// Gets a PdfExtGState with the key 'CA' set to the specified alpha value.
/// </summary>
public PdfExtGState GetExtGStateStroke(double alpha, bool overprint)
{
string key = PdfExtGState.MakeKey(alpha, overprint);
PdfExtGState extGState;
if (!_strokeAlphaValues.TryGetValue(key, out extGState))
{
extGState = new PdfExtGState(Owner);
//extGState.Elements[PdfExtGState.Keys.CA] = new PdfReal(alpha);
extGState.StrokeAlpha = alpha;
if (overprint)
{
extGState.StrokeOverprint = true;
extGState.Elements.SetInteger(PdfExtGState.Keys.OPM, 1);
}
_strokeAlphaValues[key] = extGState;
}
return extGState;
}
/// <summary>
/// Gets a PdfExtGState with the key 'ca' set to the specified alpha value.
/// </summary>
public PdfExtGState GetExtGStateNonStroke(double alpha, bool overprint)
{
string key = PdfExtGState.MakeKey(alpha, overprint);
PdfExtGState extGState;
if (!_nonStrokeStates.TryGetValue(key, out extGState))
{
extGState = new PdfExtGState(Owner);
//extGState.Elements[PdfExtGState.Keys.ca] = new PdfReal(alpha);
extGState.NonStrokeAlpha = alpha;
if (overprint)
{
extGState.NonStrokeOverprint = true;
extGState.Elements.SetInteger(PdfExtGState.Keys.OPM, 1);
}
_nonStrokeStates[key] = extGState;
}
return extGState;
}
/// <summary>
/// MmdPdf patch (#200): gets a PdfExtGState carrying only the /BM blend mode
/// (e.g. "Multiply"), cached per mode. Alpha is not touched here - the color
/// realizer's own CA/ca states compose with it.
/// </summary>
public PdfExtGState GetExtGStateBlend(string blendMode)
{
PdfExtGState extGState;
if (!_blendStates.TryGetValue(blendMode, out extGState))
{
extGState = new PdfExtGState(Owner);
extGState.Elements.SetName(PdfExtGState.Keys.BM, "/" + blendMode);
_blendStates[blendMode] = extGState;
}
return extGState;
}
readonly Dictionary<string, PdfExtGState> _strokeAlphaValues = new Dictionary<string, PdfExtGState>();
readonly Dictionary<string, PdfExtGState> _nonStrokeStates = new Dictionary<string, PdfExtGState>();
readonly Dictionary<string, PdfExtGState> _blendStates = new Dictionary<string, PdfExtGState>();
}
}