Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Aug 28, 2017 1:09 pm

Hi!

Is there a way to tell Spire PDF to draw a Image with defined spot colors?
I have a QR Barcode Image and I want it to be placed in the center of my PDF document and I want to tell the PDF that this Image is drawn with some defined spot colors. But I cant find a way to do this.

Code: Select all
PdfImage imgQR = PdfImage.FromImage(MY_IMAGE_SOURCE);
page = pdfDocument.Pages[1];

float width = imgQR.Width * 0.75f;
float height = imgQR.Height * 0.75f;
float x = (page.Canvas.ClientSize.Width - width) / 2;
float y = (page.Canvas.ClientSize.Height - height) / 2;

page.Canvas.DrawImage(imgQR, x, y, width, height);


Here you can see my Image draw process. Everything is working but if you examine the pdf the Image is drawn with CMYK and not the defined spot colors. For me it is totaly clear why the Image is drawn in the CMYK Color space but it would be very very helpfull if someone knows a way to "convince" :P the Image to use the defined SpotColors (Of Course the Image uses only Colors which are defined as Spot Colors too).

Here you can see the relevant part of the Image creation, but this is another library just to show you the are using normal Colors to draw the Image.

Code: Select all
QRCodeForegroundColor = Color.FromArgb(69, 84, 99),
QRCodeBackgroundColor = Color.FromName("White")


If you need any extra Information, just feel free to ask.

best regards

Bado

bado
 
Posts: 4
Joined: Mon Aug 28, 2017 8:03 am

Tue Aug 29, 2017 6:43 am

Dear Bado,

Thanks for your inquiry.
Spire.PDF could keep spot colors when drawing the image on PDF, you need to use the class PdfJpegImage to load the image which has defined spot colors then draw it. After testing, I found there is a issue on the result document. And I have posted it to our Dev team. We will inform you when it is fixed. Sorry for the inconvenience.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Aug 29, 2017 9:27 am

Hi!

Again thank you for you fast response.
May you have a code example for me (I want to test if the problem you describe maybe is not occuring in our environment)?

best regards

BaDo

bado
 
Posts: 4
Joined: Mon Aug 28, 2017 8:03 am

Tue Aug 29, 2017 9:33 am

Dear Bado,

Thanks for your response.
Here is code for your reference.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            PdfPageBase page = pdf.Pages.Add();
            PdfJpegImage image = new PdfJpegImage(new MemoryStream(File.ReadAllBytes(@"F:\image\sample.jpg")));
            page.Canvas.DrawImage(image,0,10);
            pdf.SaveToFile("result.pdf");

Hope this helps. In addition, if you also encounter issue, please provide us with the input image so that we could solve your issue corresponding.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Sep 25, 2017 9:55 am

Dear Bado,

Thanks for waiting.
Now the issue has been fixed in Spire.PDF Pack(Hot Fix) Version:3.9.360. Welcome to download it and have a test.
Looking forward to your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Sep 27, 2017 8:52 am

Hello,

Has the issue get resolved? Could you please give us some feedback?

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Jan 08, 2018 10:35 am

Dear Bado,

We just adjust the code in Spire.PDF Pack(Hot Fix) Version:3.9.584. Sample code for your reference.
Code: Select all
PdfDocument pdf = new PdfDocument();
PdfPageBase page = pdf.Pages.Add();
PdfImage image = PdfImage.FromFile("path");
page.Canvas.DrawImage(image,0,0);
pdf.SaveToFile("SpotColorImage-2.pdf");

Looking forward to your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF