Convert image to PDF in C++ using Aspose.PDF - Orientation error and exceptions

Hi,

I’m testing Aspose.Pdf for C++ 2020.12

Found three problems:

  • Do not deal with orientation in exif. (Test file 1)
  • Do not support frames of images. (Test file 2)
  • Do not support old style tiff (Test file 2)
    • Error message:System::ArgumentException: __cdecl System::Drawing::Bitmap::Bitmap(const class System::SmartPtr<class System::IO::Stream> &,bool)

Here is my test code

void imageToPdf() {
    auto doc = System::MakeObject<Aspose::Pdf::Document>();
    auto page = doc->get_Pages()->Add();

    // 无法自动根据exif信息旋转图片
    System::String fileName = System::String(u"F:\\Users\\zhuying\\Desktop\\自带旋转的图片.jpg");

    auto fileStream = System::MakeObject<System::IO::FileStream>(fileName, System::IO::FileMode::Open, System::IO::FileAccess::Read);
    auto bmp = System::MakeObject<System::Drawing::Bitmap>(fileStream);
    auto r = System::MakeObject<Aspose::Pdf::Rectangle>(0.0, 0.0, (double)bmp->get_Width(), (double)bmp->get_Height());
    page->set_CropBox(r);

    // 设置页面大小
    auto pageInfo = page->get_PageInfo();
    pageInfo->get_Margin()->set_Bottom(0);
    pageInfo->get_Margin()->set_Top(0);
    pageInfo->get_Margin()->set_Left(0);
    pageInfo->get_Margin()->set_Right(0);
    page->SetPageSize(r->get_Width(), r->get_Height());

    page->AddImage(fileStream, r);
    fileStream->Close();
    doc->Save(u"imageToPdf.pdf");
}

Test files:

  1. 0024-WS·2019-D30-DTS-0001.jpg压缩模式.tif.zip (1.9 MB)
  2. 自带旋转的图片.zip (2.8 MB)

@kngstr

We were able to notice the issues at our side during JPG and TIFF conversion to the PDF using Aspose.PDF for C++ 20.12. Therefore, we have logged following issues:

  • PDFCPP-1499
  • PDFCPP-1500

Furthermore, we are trying to collect the related information about your above requirement and will soon get back to you. Please give us some time.

We are sorry for the inconvenience.

@asad.ali

OK. Thanks.

1 Like