我有一个高图表区域范围图。当我使用itextsharp将其转换为灰度PDF(通过转换彩色PDF)时,图表没有显示。这是什么原因?
我已经使用evo pdf将html转换为彩色PDF并且它工作正常。当我使用itext sharp将此pdf转换为灰度时,它没有显示高图表区域图。
PdfContentToGrayscaleConverter grayScaleConverter = new PdfContentToGrayscaleConverter();
reader = new PdfReader(originalFileFullPath);
using (FileStream fsOutput = new FileStream(grayFileFullPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
{
document = new iTextSharp.text.Document(reader.GetPageSizeWithRotation(1));
writer = PdfWriter.GetInstance(document, fsOutput);
document.Open();
PdfContentByte cb = writer.DirectContent;
int numberOfPages = reader.NumberOfPages;
for (int pageNumber = 1; pageNumber <= numberOfPages; pageNumber++)
{
Rectangle pageSizeWithRotation = reader.GetPageSizeWithRotation(pageNumber);
document.SetPageSize(pageSizeWithRotation);
document.NewPage();
// >>> CONVERT CURRENT PAGE TO GRAYSCALE
grayScaleConverter.Convert(reader, pageNumber);
// <<<<
PdfImportedPage pip = writer.GetImportedPage(reader, pageNumber);
if (pageSizeWithRotation.Rotation == 90 || pageSizeWithRotation.Rotation == 270)
{
cb.AddTemplate(pip, 0, -1f, 1f, 0, 0, pageSizeWithRotation.Height);
}
else
{
cb.AddTemplate(pip, 1f, 0, 0, 1f, 0, 0);
}
}
if (document != null)
{
document.Close(); document.Dispose(); document = null;
}
if (writer != null)
{
writer.Close(); writer.Dispose(); writer = null;
}
if (reader != null)
{
reader.Close(); reader.Dispose(); reader = null;
}
}