Add a grafic like JPG or BMP on a page

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Chris - Tracker Supp, Vasyl-Tracker Dev Team, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
rlcgm
User
Posts: 8
Joined: Thu Jun 10, 2021 11:00 am

Add a grafic like JPG or BMP on a page

Post by rlcgm » Thu Jun 10, 2021 12:31 pm

Hello,
I have a little problem and I need support:
I want to add a grafic like JPG or BMP on a page, but it is not visible. The values from x, y and the size are correct. What is wrong on my c++ code? All return values are OK (S_OK).
hr = pdfInt.pdfContentCreator_->SaveState();
if ( hr != S_OK )
{
pdfInt.error_ = hr;
pdfInt.errorText_ = getErrorDesc( pdfInt.error_ );
return false;
}
PXC::IPXC_Image* img;
PXC::ULONG_T size;
PXC::PXC_Matrix im = { 0 };

hr = pdfInt.pdfFile_->AddImageFromFile(wstrFileName, 0, 0, &img);
if ( hr != S_OK )
{
pdfInt.error_ = hr;
pdfInt.errorText_ = getErrorDesc( pdfInt.error_ );
return false;
}
// get image width
hr = img->get_Width(&size);
if ( hr != S_OK )
{
pdfInt.error_ = hr;
pdfInt.errorText_ = getErrorDesc( pdfInt.error_ );
return false;
}
// get image heigth
hr = img->get_Height(&size);
if ( hr != S_OK )
{
pdfInt.error_ = hr;
pdfInt.errorText_ = getErrorDesc( pdfInt.error_ );
return false;
}
// set position and size
im.a = width; //Image Width
im.d = height; //Image Height
im.e = calcX( x ); //Location x
im.f = calcY( y ); //Location y

hr = pdfInt.pdfContentCreator_->ConcatCS(&im);
if ( hr != S_OK )
{
pdfInt.error_ = hr;
pdfInt.errorText_ = getErrorDesc( pdfInt.error_ );
return false;
}
hr = pdfInt.pdfContentCreator_->PlaceImage(img);
if ( hr != S_OK )
{
pdfInt.error_ = hr;
pdfInt.errorText_ = getErrorDesc( pdfInt.error_ );
return false;
}
hr = pdfInt.pdfContentCreator_->RestoreState();
if ( hr != S_OK )
{
pdfInt.error_ = hr;
pdfInt.errorText_ = getErrorDesc( pdfInt.error_ );
return false;
}

User avatar
Sasha - Tracker Dev Team
User
Posts: 5496
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Add a grafic like JPG or BMP on a page

Post by Sasha - Tracker Dev Team » Thu Jun 10, 2021 12:36 pm

Hello rlcgm,

Check out the CoreAPIDemo application - it holds plenty of samples:
https://github.com/tracker-software/PDF ... oreAPIDemo

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

rlcgm
User
Posts: 8
Joined: Thu Jun 10, 2021 11:00 am

Re: Add a grafic like JPG or BMP on a page

Post by rlcgm » Thu Jun 10, 2021 1:26 pm

Hello Alex,

i use the sample code from the c# example, but i get a empty page.

Cheers

User avatar
Sasha - Tracker Dev Team
User
Posts: 5496
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Add a grafic like JPG or BMP on a page

Post by Sasha - Tracker Dev Team » Thu Jun 10, 2021 1:46 pm

Hello rlcgm,

Have you tried using that sample directly? Does it give correct results with your image?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

rlcgm
User
Posts: 8
Joined: Thu Jun 10, 2021 11:00 am

Re: Add a grafic like JPG or BMP on a page

Post by rlcgm » Thu Jun 10, 2021 2:14 pm

Hello Alex,

i have translated from c# to c++ and the code is in the first post.

Cheers

User avatar
Sasha - Tracker Dev Team
User
Posts: 5496
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Add a grafic like JPG or BMP on a page

Post by Sasha - Tracker Dev Team » Fri Jun 11, 2021 7:23 am

Hello rlcgm,

I meant using the code from the C# sample with your file and looking at the results.
If it all works correctly - then it's the problem with the translation.
If it behaves the same as your C++ code - then the problem is with the file itself.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

rlcgm
User
Posts: 8
Joined: Thu Jun 10, 2021 11:00 am

Re: Add a grafic like JPG or BMP on a page

Post by rlcgm » Fri Jun 11, 2021 7:52 am

Thanks, i will check it.

User avatar
Sasha - Tracker Dev Team
User
Posts: 5496
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Add a grafic like JPG or BMP on a page

Post by Sasha - Tracker Dev Team » Fri Jun 11, 2021 1:08 pm

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply