Add a grafic like JPG or BMP on a page
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, 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.
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.
Add a grafic like JPG or BMP on a page
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;
}
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
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
Check out the CoreAPIDemo application - it holds plenty of samples:
https://github.com/tracker-software/PDF ... oreAPIDemo
Cheers,
Alex
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
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
i use the sample code from the c# example, but i get a empty page.
Cheers
i use the sample code from the c# example, but i get a empty page.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
Have you tried using that sample directly? Does it give correct results with your image?
Cheers,
Alex
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
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
i have translated from c# to c++ and the code is in the first post.
Cheers
i have translated from c# to c++ and the code is in the first post.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
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
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
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Thanks, i will check it.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Add a grafic like JPG or BMP on a page
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hi Alex,
i have check the source code and it works with Windows 21H1 and Visual Studio 2019 (for the check), but not with Windows 2004 and Visual Studio 2008. So i mean, it is a version problem. i habe check it with the PdfXChange version "8.0.337.0" and "8.0.341.0" and VS2008.
So my question is: What is the right version for using with VS2008? Better a older version or a newer one?
Thanks, for your support.
Cheers
i have check the source code and it works with Windows 21H1 and Visual Studio 2019 (for the check), but not with Windows 2004 and Visual Studio 2008. So i mean, it is a version problem. i habe check it with the PdfXChange version "8.0.337.0" and "8.0.341.0" and VS2008.
So my question is: What is the right version for using with VS2008? Better a older version or a newer one?
Thanks, for your support.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
Does it work with the latest Windows version and the VS2008? Because I'm afraid that it's outdated for correct usage.
Cheers,
Alex
Does it work with the latest Windows version and the VS2008? Because I'm afraid that it's outdated for correct usage.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hallo Alex,
it works with Windows 10 (Version from this year) and Visual Studio 2019, but not on the PC with Windows 10 (Version from last year) and Visual Studio 2008. We use C++ on both machines.
On the machine with VS2008 i can read the sizes from the picture but the insert is not correct (nothing to see from the picture on the page and the size from the pdf file is 4KB = 4071 byte = to small with the picture).
The VS2008 is an older version and the question is: Is it a version issue from VS2008 (not Windows 10)?
Cheers
it works with Windows 10 (Version from this year) and Visual Studio 2019, but not on the PC with Windows 10 (Version from last year) and Visual Studio 2008. We use C++ on both machines.
On the machine with VS2008 i can read the sizes from the picture but the insert is not correct (nothing to see from the picture on the page and the size from the pdf file is 4KB = 4071 byte = to small with the picture).
The VS2008 is an older version and the question is: Is it a version issue from VS2008 (not Windows 10)?
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
Well I'm afraid that you will have to debug this for yourself, as we don't know what the issue is exactly.
Cheers,
Alex
Well I'm afraid that you will have to debug this for yourself, as we don't know what the issue is exactly.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hallo Alex,
please, give me a short example for create a new pdf file with insert a jpg grafic.
Cheers
please, give me a short example for create a new pdf file with insert a jpg grafic.
Cheers
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
this is the Preview from the MSC C++ example: Then i added the code to save it to a Pdf file and this is the result: and all resultcode from the functions are S_OK.
Please tell me what is wrong? Thanks.
Cheers
this is the Preview from the MSC C++ example: Then i added the code to save it to a Pdf file and this is the result: and all resultcode from the functions are S_OK.
Please tell me what is wrong? Thanks.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
OK, I don't get it now. You said that your code is working perfectly for VisualStudio2019. Are you trying the same code with VS2008 and it does not work? If so, that the problem is not with the SDK, but with the VS, settings and environment.
Cheers,
Alex
OK, I don't get it now. You said that your code is working perfectly for VisualStudio2019. Are you trying the same code with VS2008 and it does not work? If so, that the problem is not with the SDK, but with the VS, settings and environment.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
the hardcopy are from the pc with Visual Studio 2019 and c++.
The first hardcopy shows the preview from the c++ example, with the picture.
The preview is ok.
Than i added the source code to save the pdf file.
The second hardcopy shows the pdf file, it is empty and the size is 4KB.
Cheers
the hardcopy are from the pc with Visual Studio 2019 and c++.
The first hardcopy shows the preview from the c++ example, with the picture.
The preview is ok.
Than i added the source code to save the pdf file.
The second hardcopy shows the pdf file, it is empty and the size is 4KB.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
OK, and if you take the built exe file from the 2019 PC and try it on the 2008 one? And the reversed case - take the exe from the 2008 and try it on the 2019 PC.
Cheers,
Alex
OK, and if you take the built exe file from the 2019 PC and try it on the 2008 one? And the reversed case - take the exe from the 2008 and try it on the 2019 PC.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
the same problem = empty page.
Cheers
the same problem = empty page.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
In two cases that I mentioned earlier?
Cheers,
Alex
In two cases that I mentioned earlier?
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
but what is wrong?
Cheers
but what is wrong?
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
Well, we'll still need an answers for the behavior in both cases - then we can tell more.
Cheers,
Alex
Well, we'll still need an answers for the behavior in both cases - then we can tell more.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,rlcgm wrote: ↑Tue Jun 29, 2021 1:07 pm Hallo Alex,
it works with Windows 10 (Version from this year) and Visual Studio 2019, but not on the PC with Windows 10 (Version from last year) and Visual Studio 2008. We use C++ on both machines.
On the machine with VS2008 i can read the sizes from the picture but the insert is not correct (nothing to see from the picture on the page and the size from the pdf file is 4KB = 4071 byte = to small with the picture).
The VS2008 is an older version and the question is: Is it a version issue from VS2008 (not Windows 10)?
Cheers
the same problem = empty page.
Cheers
Re: Add a grafic like JPG or BMP on a page
Hallo Alex,
are there any new findings on the subject?
Cheers
are there any new findings on the subject?
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
Nope - as we did not get an answer prior to both cases:
1) Does it work correctly if you take the built exe file from the VS2019 PC and try it on the VS2008 one?
2) Does it work correctly if you take the built exe file from the VS2008 PC and try it on the VS2019 one?
Cheers,
Alex
Nope - as we did not get an answer prior to both cases:
1) Does it work correctly if you take the built exe file from the VS2019 PC and try it on the VS2008 one?
2) Does it work correctly if you take the built exe file from the VS2008 PC and try it on the VS2019 one?
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hallo Alex,
1) Does it work correctly if you take the built exe file from the VS2019 PC and try it on the VS2008 one?
No
2) Does it work correctly if you take the built exe file from the VS2008 PC and try it on the VS2019 one?
No
Please use the c++ example from the delivery path and add the code lines from my post from "Thu Jun 10, 2021 2:31 pm".
Use your own jpg or bmp grafic file and look at the preview. It shows the grafic file (see hardcopy from posr).
Go to the end of the function and save the pdf file to the file system. Open it with a pdf viewer and you habe a empty page.
The file on the filesystem is 4 KB big without any text or the grafic.
I hope this helps to understand my problem.
Cheers
1) Does it work correctly if you take the built exe file from the VS2019 PC and try it on the VS2008 one?
No
2) Does it work correctly if you take the built exe file from the VS2008 PC and try it on the VS2019 one?
No
Please use the c++ example from the delivery path and add the code lines from my post from "Thu Jun 10, 2021 2:31 pm".
Use your own jpg or bmp grafic file and look at the preview. It shows the grafic file (see hardcopy from posr).
Go to the end of the function and save the pdf file to the file system. Open it with a pdf viewer and you habe a empty page.
The file on the filesystem is 4 KB big without any text or the grafic.
I hope this helps to understand my problem.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
I've made a working sample that generates a one page document with one image content item that's being loaded from file Figures.png. To try this you should unpack the archive, put the PDFXCoreAPI.x64.dll in the unpacked folder and launch the exe.
The result of this should be a Test.pdf document that would be generated in the exe directory. If this works correctly on both machines then I will share the project code.
Cheers,
Alex
I've made a working sample that generates a one page document with one image content item that's being loaded from file Figures.png. To try this you should unpack the archive, put the PDFXCoreAPI.x64.dll in the unpacked folder and launch the exe.
The result of this should be a Test.pdf document that would be generated in the exe directory. If this works correctly on both machines then I will share the project code.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
sorry, for the late reaction.
It works on both machines. But we use VS2008 and the 32 bit version from PdfXChange. I this a problem?
Thanks.
Cheers
sorry, for the late reaction.
It works on both machines. But we use VS2008 and the 32 bit version from PdfXChange. I this a problem?
Thanks.
Cheers
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Add a grafic like JPG or BMP on a page
Hello rlcgm,
Here's a fully working project for this sample. Also, we've tried extracting the code and launching this on VS2012 - everything worked as expected:
https://github.com/tracker-software/PDF ... eAPISample
Cheers,
Alex
Here's a fully working project for this sample. Also, we've tried extracting the code and launching this on VS2012 - everything worked as expected:
https://github.com/tracker-software/PDF ... eAPISample
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
i have i short question:
The second lines are setting the position to 0,0.
bbox.left = 0;
bbox.bottom = 0;
I want to set i to 100, 200.
This lines are setting the size from the image:
bbox.right = nW * 72.0 / 96.0;
bbox.top = nH * 72.0 / 96.0;
This line set the right top position:
pMH->Matrix_Scale(&im, bbox.right, bbox.top, &im);
In the documentation i can not find the information. What is todo, to set the position to 100, 200?
In the source code from the example i can not find it.
Cheers
i have i short question:
The second lines are setting the position to 0,0.
bbox.left = 0;
bbox.bottom = 0;
I want to set i to 100, 200.
This lines are setting the size from the image:
bbox.right = nW * 72.0 / 96.0;
bbox.top = nH * 72.0 / 96.0;
This line set the right top position:
pMH->Matrix_Scale(&im, bbox.right, bbox.top, &im);
In the documentation i can not find the information. What is todo, to set the position to 100, 200?
In the source code from the example i can not find it.
Cheers
Re: Add a grafic like JPG or BMP on a page
Hello Alex,
i have found it.
Cheers
i have found it.
Cheers
- Tracker Supp-Stefan
- Site Admin
- Posts: 17889
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact: