Fix PR #552 failing integration tests (#580)

This commit is contained in:
BobLd
2023-03-25 16:29:28 +00:00
committed by GitHub
parent a3a9d1a2b5
commit 3dd9a5685d

View File

@@ -838,71 +838,80 @@ namespace UglyToad.PdfPig.Writer
} }
return childObjectNumbers; return childObjectNumbers;
}
static ArrayToken CreateExplicitDestinationToken(ExplicitDestination destination, IndirectReferenceToken page) private static ArrayToken CreateExplicitDestinationToken(ExplicitDestination destination, IndirectReferenceToken page)
{ {
return destination.Type switch switch (destination.Type)
{ {
ExplicitDestinationType.XyzCoordinates => new ArrayToken(new IToken[] case ExplicitDestinationType.XyzCoordinates:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.XYZ, NameToken.XYZ,
new NumericToken(destination.Coordinates.Left ?? 0), new NumericToken(destination.Coordinates.Left ?? 0),
new NumericToken(destination.Coordinates.Top ?? 0), new NumericToken(destination.Coordinates.Top ?? 0)
}), });
ExplicitDestinationType.FitPage => new ArrayToken(new IToken[] case ExplicitDestinationType.FitPage:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.Fit, NameToken.Fit
}), });
ExplicitDestinationType.FitHorizontally => new ArrayToken(new IToken[] case ExplicitDestinationType.FitHorizontally:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.FitH, NameToken.FitH,
new NumericToken(destination.Coordinates.Top ?? 0), new NumericToken(destination.Coordinates.Top ?? 0)
}), });
ExplicitDestinationType.FitVertically => new ArrayToken(new IToken[] case ExplicitDestinationType.FitVertically:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.FitV, NameToken.FitV,
new NumericToken(destination.Coordinates.Left ?? 0), new NumericToken(destination.Coordinates.Left ?? 0)
}), });
ExplicitDestinationType.FitRectangle => new ArrayToken(new IToken[] case ExplicitDestinationType.FitRectangle:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.FitR, NameToken.FitR,
new NumericToken(destination.Coordinates.Left ?? 0), new NumericToken(destination.Coordinates.Left ?? 0),
new NumericToken(destination.Coordinates.Top ?? 0), new NumericToken(destination.Coordinates.Top ?? 0),
new NumericToken(destination.Coordinates.Right ?? 0), new NumericToken(destination.Coordinates.Right ?? 0),
new NumericToken(destination.Coordinates.Bottom ?? 0), new NumericToken(destination.Coordinates.Bottom ?? 0)
}), });
ExplicitDestinationType.FitBoundingBox => new ArrayToken(new IToken[] case ExplicitDestinationType.FitBoundingBox:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.FitB, NameToken.FitB,
}), });
ExplicitDestinationType.FitBoundingBoxHorizontally => new ArrayToken(new IToken[] case ExplicitDestinationType.FitBoundingBoxHorizontally:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.FitBH, NameToken.FitBH,
new NumericToken(destination.Coordinates.Left ?? 0), new NumericToken(destination.Coordinates.Left ?? 0)
}), });
ExplicitDestinationType.FitBoundingBoxVertically => new ArrayToken(new IToken[] case ExplicitDestinationType.FitBoundingBoxVertically:
return new ArrayToken(new IToken[]
{ {
page, page,
NameToken.FitBV, NameToken.FitBV,
new NumericToken(destination.Coordinates.Left ?? 0), new NumericToken(destination.Coordinates.Left ?? 0)
}), });
_ => throw new NotSupportedException($"{destination.Type} is not a supported bookmark destination type."), default:
}; throw new NotSupportedException($"{destination.Type} is not a supported bookmark destination type.");
} }
} }