PDF-Writer
PDF-Writer copied to clipboard
Color inversion problem occurs when exporting images
Thank you for developing this library! When our program uses your library, some pictures appear to be exported to pdf. When opening this file with CorelDraw, the picture has an inverted color problem.😂I try different version of pdf, all have this problem. I don't know how to sovle it.🤣Could this problem be caused by LibJpeg? raw picture
happen inverted color problem in CorelDraw 2019:
I use this code and build with Visual Studio 2022,
#include <iostream>
#include<PDFWriter/PDFWriter.h>
#include<PDFWriter/PDFPage.h>
#include<PDFWriter/AbstractContentContext.h>
#include<PDFWriter/PageContentContext.h>
using namespace std;
int main()
{
PDFWriter pdfWriter;
string filePath = "helloPDF.pdf";
if (pdfWriter.StartPDF(filePath.c_str(), ePDFVersion13) != eSuccess)
{
throw std::runtime_error("pdf create failed!");
}
string imagePath = "image/1.jpg";
DoubleAndDoublePair jpgDimensions = pdfWriter.GetImageDimensions(imagePath);
PDFPage* page = new PDFPage();
page->SetMediaBox(PDFRectangle(0, 0, jpgDimensions.first, jpgDimensions.second));
PageContentContext* cxt = pdfWriter.StartPageContentContext(page);
cxt->DrawImage(10, 10, imagePath.c_str());
pdfWriter.EndPageContentContext(cxt);
pdfWriter.WritePageAndRelease(page);
pdfWriter.EndPDF();
string cmd = "start " + filePath;
system(cmd.c_str());
return 0;
}
the problem pic is below.
Thanks a lot!