0

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 (ピクセル単位) に変換してレンダリングしようとしましたが、うまくいきましたが、パフォーマンスが高くて実現できませんでした。もっとエレガントな解決策を見つける必要があります。

本当にありがとう!

PDF: https://dl.dropbox.com/u/49564994/PDF.pdf

プリントアウト: https://dl.dropbox.com/u/49564994/Print.jpg

4

1 に答える 1

0

ほぼ2年前、私は同様の問題を抱えていました。生成された PDF を印刷すると、すべて文字化けしました。それは単なるレポートで、画像は含まれていませんでしたが、いくつかの文または単語が欠落していました。

Word テンプレートを使用し、いくつかのプレースホルダーを置き換えてレポートを生成し、Office Save As PDF アドインを使用して Word ドキュメントを PDF に保存しました。

PDF を PCL プリンター ドライバーで印刷する場合と PostScript プリンター ドライバーで印刷する場合には違いがあります。それらの間に違いがあるかどうかを確認してください。フォントの問題かもしれません。フォントエンコーディングが正しく設定されていることを確認してください。

その時、私は解決策を見つけられませんでした。最後に、PDFを画像に変換してプリンターに送信することにしました。うまくいきました。

これは、 GhostScript を呼び出して PDF ページから画像を作成することにより、PDFSharp を使用して行うこともできます。

于 2012-06-19T18:32:40.390 に答える