aspose.pdf将pdf转为600DPI的JPEG图像放大后不清晰

我使用aspose.pdf将pdf转为分辨率为600的JPEG图像,放大后图片内的文字很模糊,请问需要添加什么参数吗?我用aspose提供的在线pdf转换图片网站得到的也是一样的结果。

这是我使用的pdf和经过转换的图片文件,图片分辨率均为600。
files.zip (3.1 MB)

@jidesheng

您能分享一下您用来将 PDF 转换为 JPG 的示例代码片段吗?

AspWordsWarningCallBack AspCallBack = new AspWordsWarningCallBack();

            string FileType = System.IO.Path.GetExtension(DocumentsFileName);

            //初始化一个临时参数,到时候重新初始化
            Aspose.Words.Saving.ImageSaveOptions TempWordImageSaveOption = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg);

            Aspose.Words.Document TempWordDocument = null;
            Aspose.Cells.Workbook TempExcelDocument = null;
            Aspose.Cells.Rendering.ImageOrPrintOptions TempExcelImageOPtion = new Aspose.Cells.Rendering.ImageOrPrintOptions();
            Aspose.Pdf.Document TempPdfDocument = null;
            Aspose.Pdf.Devices.ImageDevice TempPdfImageDevice = null;
            Aspose.Pdf.Devices.TiffDevice TempPdfTifDevice = null;
            Aspose.Pdf.Devices.Resolution TempPdfImageResolution = new Aspose.Pdf.Devices.Resolution(DpiValue);
            Aspose.Imaging.ImageOptions.JpegOptions TempConvertJpegOption = new JpegOptions();
            Aspose.Imaging.ImageOptions.PngOptions TempConvertPngOption = new PngOptions();
            Aspose.Imaging.ImageOptions.BmpOptions TempConvertBmpOption = new BmpOptions();

            //设置加载word文档的时候参数
            Aspose.Words.Loading.LoadOptions TempDocuemntLoadOption = new Aspose.Words.Loading.LoadOptions()
            {
                ConvertMetafilesToPng = false,
                MswVersion = Aspose.Words.Settings.MsWordVersion.Word2010,
            };
            TempDocuemntLoadOption.LanguagePreferences.AddEditingLanguage(Aspose.Words.Loading.EditingLanguage.ChinesePRC);

            switch (FileType)
            {
                case ".doc":
                    TempWordDocument = new Aspose.Words.Document(DocumentsFileName, TempDocuemntLoadOption);
                    TempWordDocument.WarningCallback = AspCallBack;
                    TempWordDocument.CompatibilityOptions.OptimizeFor(Aspose.Words.Settings.MsWordVersion.Word2010);
                    TempWordDocument.CompatibilityOptions.BalanceSingleByteDoubleByteWidth = true;//区分全角和半角字符
                    break;
                case ".docx":
                    TempWordDocument = new Aspose.Words.Document(DocumentsFileName, TempDocuemntLoadOption);
                    TempWordDocument.WarningCallback = AspCallBack;
                    TempWordDocument.CompatibilityOptions.OptimizeFor(Aspose.Words.Settings.MsWordVersion.Word2010);
                    TempWordDocument.CompatibilityOptions.BalanceSingleByteDoubleByteWidth = true;//区分全角和半角字符
                    break;
                case ".pdf":
                    TempPdfDocument = new Aspose.Pdf.Document(DocumentsFileName);
                    
                    break;
                case ".xls":
                    TempExcelDocument = new Aspose.Cells.Workbook(DocumentsFileName);
                    break;
                case ".xlsx":
                    TempExcelDocument = new Aspose.Cells.Workbook(DocumentsFileName);
                    break;
                case ".ppt":
                    _ = new Aspose.Slides.Presentation(DocumentsFileName);
                    break;
                case ".pptx":
                    _ = new Aspose.Slides.Presentation(DocumentsFileName);
                    break;
                default: break;
            }

            //根据不同导出类型进行预初始化处理
            switch (ConvertImageType)
            {
                case ".jpg":
                    TempWordImageSaveOption = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg)
                    {
                        JpegQuality = 100,
                        PrettyFormat = true,
                    };
                    TempPdfImageDevice = new Aspose.Pdf.Devices.JpegDevice(TempPdfImageResolution, 100);
                    TempExcelImageOPtion.ImageType = Aspose.Cells.Drawing.ImageType.Jpeg;
                    TempExcelImageOPtion.Quality = 100;
                    break;
                case ".png":
                    TempWordImageSaveOption = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Png);
                    TempPdfImageDevice = new Aspose.Pdf.Devices.PngDevice(TempPdfImageResolution);
                    TempExcelImageOPtion.ImageType = Aspose.Cells.Drawing.ImageType.Png;
                    break;
                case ".bmp":
                    TempWordImageSaveOption = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Bmp);
                    TempPdfImageDevice = new Aspose.Pdf.Devices.BmpDevice(TempPdfImageResolution);
                    TempExcelImageOPtion.ImageType = Aspose.Cells.Drawing.ImageType.Bmp;
                    break;
                case ".tif":
                    TempWordImageSaveOption = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Tiff);
                    TempPdfTifDevice = new Aspose.Pdf.Devices.TiffDevice(TempPdfImageResolution);
                    TempExcelImageOPtion.ImageType = Aspose.Cells.Drawing.ImageType.Tiff;
                    break;
                default: break;
            }

            //word转图片的设置
            TempWordImageSaveOption.UseHighQualityRendering = true;
            TempWordImageSaveOption.Resolution = DpiValue;
            TempWordImageSaveOption.ColorMode = Aspose.Words.Saving.ColorMode.Normal;
            TempWordImageSaveOption.UseAntiAliasing = true;
            TempWordImageSaveOption.AllowEmbeddingPostScriptFonts = true;

            //pdf转图片设置
            TempPdfImageDevice.RenderingOptions.DefaultFontName = "SimSun";

            //excel转图片的设置
            TempExcelImageOPtion.CheckWorkbookDefaultFont = true;
            TempExcelImageOPtion.HorizontalResolution = DpiValue;
            TempExcelImageOPtion.VerticalResolution = DpiValue;
            TempExcelImageOPtion.PixelFormat = System.Drawing.Imaging.PixelFormat.Format24bppRgb;
            TempExcelImageOPtion.CheckWorkbookDefaultFont = true;
            TempExcelImageOPtion.DefaultFont = "SimSun";

            if (PageExport)
            {
                if (FileType == ".doc" || FileType == ".docx")
                {
                    //逐页导出WORD图片
                    for (int pageIndex = 0; pageIndex < TempWordDocument.PageCount; pageIndex++)
                    {
                        string MutilPageFileName = SavedImageFileName.Replace(ConvertImageType, $"_第{pageIndex + 1}页{ConvertImageType}");
                        TempWordImageSaveOption.PageSet = new Aspose.Words.Saving.PageSet(pageIndex);
                        TempWordDocument.Save(MutilPageFileName, TempWordImageSaveOption);
                        if (SetGrayMode)
                        {
                            string SavedPath = Path.GetDirectoryName(SavedImageFileName);
                            string BMP_8BitPath = Path.Combine(SavedPath, "8_bmp_image");
                            Directory.CreateDirectory(BMP_8BitPath);
                            string ConvertedBmpFileName = BMP_8BitPath + "\\" + Path.GetFileName(MutilPageFileName).Replace(ConvertImageType, ".bmp");
                            using Bitmap TempBitMap = new Bitmap(MutilPageFileName);
                            using Bitmap ConvertedBitMap = ConvertTo256Color(TempBitMap);
                            ConvertedBitMap.Save(ConvertedBmpFileName, ImageFormat.Bmp);
                        }
                    }
                }
                else if (FileType == ".pdf")
                {
                    //逐页导出PDF的图片,tif图片需要单独处理,他不是imagedeivice类型
                    for (int PdfPageIndex = 0; PdfPageIndex < TempPdfDocument.Pages.Count; PdfPageIndex++)
                    {
                        string MutilPageFileName = SavedImageFileName.Replace(ConvertImageType, $"_第{PdfPageIndex + 1}页{ConvertImageType}");
                        if (ConvertImageType != ".tif")
                        {
                            TempPdfImageDevice.Process(TempPdfDocument.Pages[PdfPageIndex + 1], MutilPageFileName);
                        }
                        else
                        {
                            TempPdfTifDevice.Process(TempPdfDocument, PdfPageIndex + 1, PdfPageIndex + 1, MutilPageFileName);
                        }
                    }
                }

这是我将pdf转为图片的代码片段,中间有些别的格式转换图片,忽略即可,我使用的是device的方式导出图片。

@jidesheng

我们需要您为图像转换传递的分辨率/DPI 值。是600吗?请确认。

是的,我传入的值是600。

@jidesheng

我们已在内部问题跟踪系统中打开以下新票证,并将根据 Free Support Policies 中提到的条款提供修复。

问题 ID:PDFNET-56072

如果您需要优先支持,以及直接联系我们的付费支持管理团队,您可以获取 Paid Support Services

请问一下目前进度如何,今年有可能会修复吗?

@jidesheng

由于其他悬而未决的问题,我们担心该票证尚未解决,目前我们无法分享任何可靠的预计到达时间。我们将按照先到先得的原则优先处理此问题,一旦问题得到解决或我们有一些有关修复预计到达时间的信息,我们将在此论坛帖子中与您分享。请耐心等待并给我们一些时间。

对此造成的不便,我们表示歉意。