Rendering: Add PDFRendering capability (#84438)

* Rendering: Add PDFRendering capability

* fix tests
This commit is contained in:
Agnès Toulet
2024-03-19 08:48:46 +01:00
committed by GitHub
parent d3571c399a
commit 58170d4141
6 changed files with 47 additions and 14 deletions
+16 -2
View File
@@ -125,9 +125,13 @@ func ProvideService(cfg *setting.Cfg, features *featuremgmt.FeatureManager, remo
semverConstraint: ">= 3.4.0",
},
{
name: SvgSanitization,
name: SVGSanitization,
semverConstraint: ">= 3.5.0",
},
{
name: PDFRendering,
semverConstraint: ">= 3.10.0",
},
},
Cfg: cfg,
features: features,
@@ -292,6 +296,16 @@ func (rs *RenderingService) render(ctx context.Context, renderType RenderType, o
return rs.renderUnavailableImage(), nil
}
if renderType == RenderPDF || opts.Encoding == "pdf" {
if !rs.features.IsEnabled(ctx, featuremgmt.FlagNewPDFRendering) {
return nil, fmt.Errorf("feature 'newPDFRendering' disabled")
}
if err := rs.IsCapabilitySupported(ctx, PDFRendering); err != nil {
return nil, err
}
}
rs.log.Info("Rendering", "path", opts.Path)
if math.IsInf(opts.DeviceScaleFactor, 0) || math.IsNaN(opts.DeviceScaleFactor) || opts.DeviceScaleFactor == 0 {
opts.DeviceScaleFactor = 1
@@ -327,7 +341,7 @@ func (rs *RenderingService) RenderCSV(ctx context.Context, opts CSVOpts, session
}
func (rs *RenderingService) SanitizeSVG(ctx context.Context, req *SanitizeSVGRequest) (*SanitizeSVGResponse, error) {
capability, err := rs.HasCapability(ctx, SvgSanitization)
capability, err := rs.HasCapability(ctx, SVGSanitization)
if err != nil {
return nil, err
}