PDFSharp を介して PDF を生成する複雑なアプリケーションがあります。解決するのが非常に難しいことがわかっている問題に直面しています。
画像 (テキストも画像です) を回転してレンダリングすると、作成された PDF はきれいに見えますが、印刷すると端がぎざぎざになり、一般的にめちゃくちゃになります。添付ファイルを参照してください。
関連するコードは次のとおりです。
// determine how big the image should be
double destinationWidth = Math.Round(pageWidth * imageInfo.WidthFactor);
double destinationHeight = destinationWidth;
// rescale the image to needed size
imageInfo.Image = ImageHelper.ResizeImage(imageInfo.Image, (int)(destinationWidth * 3), (int)(destinationHeight * 3));
// get image
XImage xImage = XImage.FromGdiPlusImage(imageInfo.Image);
// define fill area
XRect destination = new XRect();
destination.X = imageInfo.XFactor * pageWidth;
destination.Y = imageInfo.YFactor * pageHeight;
destination.Width = destinationWidth; //pageWidth * imageInfo.WidthFactor;
destination.Height = destinationHeight; //destination.Width; // shouldn't this use the page height and height factor?
// save state before rotate
XGraphicsState previousState = gfx.Save();
// rotate canvas
gfx.RotateAtTransform(imageInfo.RotationAngle, new XPoint(destination.X + destination.Width / 2, destination.Y + destination.Height / 2));
// render image
gfx.DrawImage(xImage, destination);
// undo transforms
gfx.Restore(previousState);
お願い、お願い、助けて。それだけの価値があるため、Chrome の PDF ビューアからは問題なく印刷されます。
画像を SVG (ピクセル単位) に変換してレンダリングしようとしましたが、うまくいきましたが、パフォーマンスが高くて実現できませんでした。もっとエレガントな解決策を見つける必要があります。
本当にありがとう!