Please check the attached output PDF that was generated in our environment using Aspose.Pdf.Drawing 24.4. We could not notice any issues in it: ImagetoPDF.pdf (272.2 KB)
This is a comparison between the PDF you provided and the original image.
Please check the position of the arrow.
There is indeed a color difference 图片.jpg (237.7 KB)
This output pdf is generated from Aspose.pdf for .net 24.4, with the same code.
And it has different color too. 0-1(1).jpg.ImagetoPDF.pdf (2.0 MB)
@asad.ali
The images displayed by these viewers above are consistent. Personally, I usually use Windows Photos or WPS to view images.
But from what you previously sent, the Windows photos on your end show something different from mine.
So WPS or PhotoShop is OK.
This is how the photo is rendered in Edge, Photos (MS) and WPS in our environment. image.jpg (285.2 KB)
You can notice that we are seeing same color in each photo viewer that we have tried. It is quite possible that you are noticing this color because of different color profile on your machine or OS. Also, color temperature on your device may take part in showing different color shades. Can you please try to use another system to view the image?
It seems when color is cmyk, something like below should to be setting in pdf.
/Decode[1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0]
These are my testing OS list:
Windows 7 Professional sp1 64-bit Edition 6.1.7601
Windows 10 Enterprise 1909 64-bit Edition 10.0.18363.1679
Windows 10 Home 22H2 64-bit Edition 10.0.19045.4170
Windows 10 Professional 22H2 64-bit Edition 10.0.19045.2846
I tested another code, it still got black.
void testJpgToPdfAddImage(string filename)
{
// Load input JPG image file
System.Drawing.Image srcImage = System.Drawing.Image.FromFile(filename);
// Read Height of input image
int h = srcImage.Height;
// Read Height of input image
int w = srcImage.Width;
// Initialize a new PDF document
Document doc = new Document();
// Add an empty page
Page page = doc.Pages.Add();
// Set page dimensions and margins
page.PageInfo.Height = (h);
page.PageInfo.Width = (w);
page.PageInfo.Margin.Bottom = (0);
page.PageInfo.Margin.Top = (0);
page.PageInfo.Margin.Right = (0);
page.PageInfo.Margin.Left = (0);
page.SetPageSize(w, h);
page.AddImage(filename, new Rectangle(0, 0, w, h));
// Save output PDF file
doc.Save(filename + ".AddImage.ImagetoPDF.pdf");
}
Maybe the image is being changed after you are uploading it here to share it. Is it possible if you can upload the image to some public file sharer and share the link with us?
We were now able to replicate the issue in our environment as shown in the screenshot. picture886-1.jpg (229.8 KB)
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-57099
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.