Dear all, just a little resume:
PDFNET-40901 resolved an issue with some PSD files converted into PDF and then PDF into PNG
BUT this PDFNET-40901 and/or the new 17.x libraries (it’s not our job to establish) introduces a new BUG, signed as IMAGINGNET-2520 and now the resulting PDF or PNG created from PSD are of very poor quality and wrong text layers
MOREOVER the introduction of the option
_PngDeviceP.RenderingOptions = new Aspose.Pdf.RenderingOptions() { ScaleImagesToFitPageWidth = true };
causes a wrong resize in all PDF documents converted into images.
Now I attach (again for third time) our code and all the sample files (again for third time) we reproduce with resulting images with and without that option you introduce
Please, we expect some news in a short time
Thanks a lot
C# code for converting PDF to images (note that new option for now is commented)
Aspose.Pdf.Devices.Resolution ResolutionP = new Aspose.Pdf.Devices.Resolution(m_iResolution);
Aspose.Pdf.Devices.PngDevice PngDeviceP = new Aspose.Pdf.Devices.PngDevice(ResolutionP);
//PngDeviceP.RenderingOptions = new Aspose.Pdf.RenderingOptions() { ScaleImagesToFitPageWidth = true };
PngDeviceP.Process(((Aspose.Pdf.Document)m_oDocument).Pages[++_iPageIndex], _oOutputStream)
C# code for PSD to PDF conversion
Aspose.Imaging.ImageOptions.PngOptions OptionsI = new Aspose.Imaging.ImageOptions.PngOptions();
OptionsI.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
//OptionsI.TransparentColor = new Aspose.Imaging.TransparentColorSetting(Aspose.Imaging.Color.Transparent);
Aspose.Imaging.ResolutionSetting oResI = new Aspose.Imaging.ResolutionSetting(Convert.ToDouble(m_iResolution), Convert.ToDouble(m_iResolution));
OptionsI.ResolutionSettings = oResI;
using (MemoryStream oMTempStream = new MemoryStream())
{
((Aspose.Imaging.Image)m_oDocument).Save(oMTempStream, OptionsI);
Aspose.Pdf.Document oPdf = new Aspose.Pdf.Document();
Aspose.Pdf.Page oPage = oPdf.Pages.Add();
oPage.PageInfo.Width = m_OPageSize.Width;
oPage.PageInfo.Height = m_OPageSize.Height;
oPage.PageInfo.Margin.Bottom = 0;
oPage.PageInfo.Margin.Top = 0;
oPage.PageInfo.Margin.Left = 0;
oPage.PageInfo.Margin.Right = 0;
double dResizeFactor = 0;
double dXsize = 0;
double dYsize = 0;
dResizeFactor = (((Aspose.Imaging.Image)m_oDocument).Width / m_OPageSize.Width > ((Aspose.Imaging.Image)m_oDocument).Height / m_OPageSize.Height) ? ((Aspose.Imaging.Image)m_oDocument).Width / m_OPageSize.Width : ((Aspose.Imaging.Image)m_oDocument).Height / m_OPageSize.Height;
dXsize = ((Aspose.Imaging.Image)m_oDocument).Width / dResizeFactor;
dYsize = ((Aspose.Imaging.Image)m_oDocument).Height / dResizeFactor;
if (((Aspose.Imaging.Image)m_oDocument).Width > ((Aspose.Imaging.Image)m_oDocument).Height)
{
//doc.PageInfo.IsLandscape = true;
double iW = oPage.PageInfo.Width;
double iH = oPage.PageInfo.Height;
oPage.PageInfo.Width = iH;
oPage.PageInfo.Height = iW;
if ((((Aspose.Imaging.Image)m_oDocument).Width > oPage.PageInfo.Width) && (((Aspose.Imaging.Image)m_oDocument).Height > oPage.PageInfo.Height))
{
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
}
else
{
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
}
}
else
{
if ((((Aspose.Imaging.Image)m_oDocument).Width > oPage.PageInfo.Width) && (((Aspose.Imaging.Image)m_oDocument).Height > oPage.PageInfo.Height))
{
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, dXsize, dYsize);
}
else
{
oPage.PageInfo.Width = ((Aspose.Imaging.Image)m_oDocument).Width;
oPage.PageInfo.Height = ((Aspose.Imaging.Image)m_oDocument).Height;
oPage.MediaBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
oPage.CropBox = new Aspose.Pdf.Rectangle(0, 0, ((Aspose.Imaging.Image)m_oDocument).Width, ((Aspose.Imaging.Image)m_oDocument).Height);
}
}
Aspose.Pdf.Image oImage = new Aspose.Pdf.Image();
oPage.Paragraphs.Add(oImage);
oImage.ImageStream = new MemoryStream(oMTempStream.ToArray());
oPdf.Save(_oOutputStream);
} //using
attached files
Imgtest2000x300.psd (original file PSD)
Imgtest2000x300.pdf (PDF conversion from PSD)
Imgtest2000x300 no new opt.png (wrong conversion)
Imgtest2000x300 with new opt.png (correct conversion without blank extra space due to the new ScaleImagesToFitPageWidth
option)
PLEASE NOTICE THERE IS NO EXACT CORRESPONDENCE OF GRAPHICS BETWEEN ORIGINAL PSD AND RESULTANT PDF or PNG FILES
2016.03.01_PriceList_ITA.pdf (original PDF)
2016.03.01_PriceList_ITA with new opt.png (wrong converted WITH NEW ScaleImagesToFitPageWidth
option)
2016.03.01_PriceList_ITA no opt.png (correct converted without new option)
Archive.zip (1.5 MB)