About vector format in output supported by Aspose.BarCode

Does the output in vector format only support SVG?
Are there any plans to support PDF or other formats?

The reason why I hear this kind of thing is
The created barcode is often printed.
However, since SVG is a format for displaying on the WEB, it only supports RGB.
I would like to know if there is a way to output in CMYK mode.

Best regard.

@yuya,

Aspose.BarCode does support to render in vector format like EMF, PNG, etc., so you may choose one for your needs. See the document on supported file formats for your reference.

Regarding rendering barcode to PDF, you may do that easily. You can generate barcode using Aspose.BarCode API and use Aspose.PDF to add an empty document page and insert the generated barcode image to it. See the document on how to add barcode image to the PDF document for your reference.

Hope, this helps a bit.

Hi, thank you for your answer.

EMF is a vector image, isn’t it? Isn’t PNG a raster image?
Thank you for the document link.
I tried it, but when I embedded it in PDF, it changed from vector to raster.

However, it seems that CMYK for printing cannot output.

  • When printing as black, it must be C0, M0, Y0, K100.
    If all are 100, the colors will overlap and be printed.

As mentioned above, is there a way to change to K100 only or to grayscale?
Should I ask this in Aspose.PDF?

Best regard.

Could you please share sample code and sample files to show the issue? We will check your issue soon.

EMF is vector image but it uses RGB colors for all vector shapes and text
[[MS-WMF]:Windows Metafile Format]
2.2.2.8 ColorRef Object
The ColorRef Object defines the RGB color.

CMYK colors are currently supported by TiffInCmyk, but tiff is raster image. Also TiffInCmyk is supported only in Windows, in Linux it is saved as ordinary Tiff.

Thank you for your reply.

I was referring to the following URL, I was taught from you.

The source is as follows.

var generator = new BarcodeGenerator(EncodeTypes.GS1Code128, barcode);
generator.Parameters.Barcode.XDimension.Millimeters = 1f;

var ms = new MemoryStream();
generator.Save(ms, BarCodeImageFormat.Emf);

var doc = new Aspose.Pdf.Document();
var page = doc.Pages.Add();

var mender = new PdfFileMend();
mender.BindPdf(doc);
mender.AddImage(ms, 1, 100, 600, 200, 700);
mender.Save(Path.Combine(Path.GetDirectoryName(outPath), "AddImage_out.pdf"));
mender.Close();

If you look at the finished PDF, you can see that the image is rough and the bar code is a raster image.

Thank you for your reply.

Can’t save in vector formatted images compatible with CMYK?
If it is a raster image, the printing machine causes the image to collapse or blur.

Yes it is raster image, but you can generate it in high resolution mode 1200 dpi or more. This can solve blur problem.

About vector image embedding into pdf, I will update some later.

Barcode image generation as CMYK pdf could be implemented in 22Q1. This task is received high status.

thank you for your reply.

There seems to be no problem if the raster is 1200dpi or higher.
The file size is likely to increase.

Is 22Q1 the ID of the question that was different from me?
Certainly, I was able to create a PDF in vector format there.
However, although I was able to convert to PDF in CMYK mode, I was not able to change the actual CMYK values.
When printing with one black color, I want the CMY value to be 0.

Best regard.

@yuya,
We are looking into these details and will share our feedback soon.

1 Like

Hi. Thank you for your reply.

Thank you for your confirmation.

@yuya,
We have logged a ticket for Barcode image generation as CMYK PDF in our database. You will be notified here once any update is ready for sharing.

This feature request is logged as:
BARCODENET-37926 - Barcode image generation as CMYK PDF

We are preparing solution for embedding vector image into PDF and will share it soon.

To solve your problem, I should describe some technical information:

  1. Pdf format doesn’t embed vector images it can embed only raster images with different compression. Pdf supports vector drawing but this drawing has different format from other vector formats and other vector formats cannot be converted to pdf vector paths automatically.

In this way, Aspose.PDF converts any images from vector formats into the raster image format and add it in RGB colors (yes, the theoretical possibility to translate one vector format into pdf vector shapes exists, but it is not implemented in Aspose.PDF).

Also, images, which have CMYK colors, are converted into RGB by Aspose.PDF. So, it is no sense to create image in CMYK because it will be converted into RGB.

  1. Aspose.PDF support many pdf formats, one of them is PDF/X−1a. This format is developed only for printing and supports only CMYK colors. So, if you create pdf document in this format all RGB colors is converted into CMYK colors.

  2. The best solution before Aspose.Barcode which can generate barcode in pdf format (this could happen in first quarter of 2022) to create barcode images in pdf in CMYK can be:

  1. Create barcode image in RGB in format without compression or with lossless compression with high resolution
  2. Add it to pdf document as RGB image
  3. Save the pdf document as PDF/X−1a

Here is the code which demonstrates the solution:

string filename = @"d:\save\rec\test.pdf";

var generator = new BarcodeGenerator(EncodeTypes.Code128, "123456");
// resolution is 300 dpi, can be more
generator.Parameters.Resolution = 300;
generator.Parameters.Barcode.XDimension.Millimeters = 1f;

MemoryStream ms = new MemoryStream();
// save in BMP because Aspose.PDF convert all images into RGB in any way
// in this way CMYK image also is converted into RGB image
// also you can try png or tiff becaue them has lossless compression
generator.Save(ms, BarCodeImageFormat.Bmp);
ms.Position = 0;

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Aspose.Pdf.Page page = doc.Pages.Add();


Aspose.Pdf.Facades.PdfFileMend mender = new Aspose.Pdf.Facades.PdfFileMend();
mender.BindPdf(doc);
// ImageFilterType.CCITTFax is lossless compression compatible with CMYK. It is developed for CMYK colors
// Jpeg is lossy compression also can use lossless LZW compression. Compatible with CMYK
// ImageFilterType.Flate is also lossless compression. Does not compatible with CMYK.
// Jpeg2000 is lossy compression but it is based on Wavelet and can be lossless. Does not compatible with CMYK.
mender.AddImage(ms, 1, 100, 600, 200, 700, new Aspose.Pdf.CompositingParameters(BlendMode.Normal, ImageFilterType.CCITTFax));
// convert into printing pdf with CMYK colors
// all RGB images are converted to CMYK colors
doc.Convert(new Aspose.Pdf.PdfFormatConversionOptions(PdfFormat.PDF_X_1A));
mender.Save(filename);
mender.Close();
1 Like

Hi. Thank you for your reply.

Aspose.Barcode may be available in the first quarter of 2022.
That’s a pleasure.
It’s coming soon, so I’m looking forward to it.

I didn’t know that vector images in PDF are in a different format than other vector images.
Is it Adobe’s own specification?

The high-resolution, uncompressed raster image presented
Is there any problem in printing by saving as PDF in CMYK format?
I will check with the printing staff of the company.

@yuya,
We have noted your feedback and will share our comments on your queries soon.

Yes. PDF 1.7 specification is free, 2.0 is standardized by ISO (it has very few differences from 1.7) and this specification is not free, but without any royalties.
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdf_reference_archive/pdf_reference_1-7.pdf
https://www.iso.org/standard/75839.html

The high-resolution, uncompressed raster image presented
Is there any problem in printing by saving as PDF in CMYK format?

I am not too common with professional printing and their requirements, but [PDF/X−1a] format is created strongly for professional printing from pdf. And I checked the file, generated but upper code, with Adobe Acrobat, it shows that it is fully [PDF/X−1a] compliant.