PDFLib fails to create PDF file in pvf - visual-c++

mpdf.create_pvf(card, mpImgBytes, mlen, L"");
int inDoc = mpdf.open_pdi_document(card, L"");
I am using pdflib version 9.3.
open_pdi_document returns -1
create_pvf creates an empty file of size 0.
Any idea on what could be wrong?
I am running pdflib on Windows 10, using C++.

I would recommend that you also retrieve the error reason in case of an error (open_pdi_document() returns -1) or work with the PDFlib errorpolicy "exception". Then you will get a first impression what the problem might be, then your code could looks like
/* Open the input PDF */
indoc = mpdf.open_pdi_document(card, L"");
if (indoc == -1) {
wcerr << L"Error: " << mpdf.get_errmsg() << endl;
return 2;
}
create_pvf creates an empty file of size 0.
how did you identify that?

Not sure how relevant my answer is, but this could help someone.
Installing ghostscript on my machine, resolved the error.

Related

Import SSL certificate by certutil in InstallShield

I have a function as below :
function LONG ImportSSL(hMSI)
STRING exeDir;
STRING sslDir;
NUMBER nvSize;
LONG ret;
begin
nvSize = 256;
MsiGetProperty (hMSI, "SETUPEXEDIR", exeDir, nvSize);
sslDir = exeDir ^ "ssl\\myCertificate.pfx";
ret = LaunchAppAndWait(WINDIR, "certutil -f -p \"\" -importpfx \"" + sslDir + "\"", WAIT);
if (ret != 0) then return ret; endif;
return 0;
end;
by running Setup.exe as below:
MySetup.exe /v"/l*v c:\SetupLog.log"
I see the below error in log file :
CustomAction ImportSSL returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 16:25:25: ImportSSL. Return value 3.
but when I execute certutil -f -p "" -importpfx "C:\myCertificate.pfx" by command prompt there is no any error , and that certeficate imported into IIS.
How can I know the details of error?
Any help will be truly appreciated.
The problem solution will depend on the following: 1)Is certificate file being delivered by the installer, or is it supposed to be present on the target machine? Check that the installer delivers it as a permanent file, or support file (in [SUPPORTDIR]), or if the file really exists; 2) where this custom action is located? Normally actions like that should be placed after InstallFinalize.

C++ String output from MySQL connector with graphics interface either crashes or prints garbage

THE PROBLEM:
I have the my sql query running correctly when the output is console, but I get ^^^!^^^^^! on the graphics interface or it crashes.
My program is compiled on Visual Studio 2005 and I use Allegro.cc library This is a old project that must be revived.
What I want to do is:
1- Run a graphics interface, have some action going, them save the data on MySQL.
2- Every now and them, I need to query the DB and get some data.
3- I want to display the data queried onto the graphics screen.
MySQl Connector is 1.1.7 with binaries from site.
MySQL is running on XAMP Turnkey Linux box 5.5.33-0+wheezy1
The Schema engine is: InnoDB
The table collation is utf-8 default collation
The PK is NN, AI.
One column name is PointOfSaleID, VARCHAR (9)
Another column name is cardIndex, INT(11)
The piece of code is below:
std::stringstream OutputStream;
(...)
prep_stmt = con -> prepareStatement ("SELECT * FROM `Triangulo`.`CardsSold` WHERE HitsA > 4 AND HitsB > 4 AND HitsC >4");
res = prep_stmt -> executeQuery();
con -> commit();
while (res -> next()) {
OutputStream << res -> getInt("idCardsSold");
textprintf_ex(OUTPUT, font, 10, 10, makecol(255,255,255),
makecol(0,0,0), "Winner Card %s", OutputStream.str().c_str() );
OutputStream.str(std::string()); // clear the string stream
CRASHES HERE! OutputStream << res -> getString("PointOfSaleID");
textprintf_ex(OUTPUT, font, 10, 300, makecol(255,255,255), makecol(0,0,0), "PointOfSaleID %s", OutputStream.str().c_str() );
When I do the same thing on the console - text output - the program runs correctly.
prep_stmt = con -> prepareStatement ("SELECT * FROM `Triangulo`.`CardsSold` WHERE HitsA > 4 AND HitsB > 3 AND HitsC >4");
res = prep_stmt -> executeQuery();
con -> commit();
/* fetch the data : retrieve all the rows in the result set */
while (res -> next()) {
cout << Card: ";
cout << res -> getInt("idCardsSold") << endl;
OutputStream << res -> getString("PointOfSaleID");
std::string resultstr = OutputStream.str();
const char* cstr2 = resultstr.c_str();
cout << "Loja Venda: ";
cout << cstr2 << endl;
cout << res -> getString("PointOfSaleID") << endl;
}
It seems to be a problem with the std::stringstream OutputStream, but I can not find out what is going on.
Any help appreciated.
The error was mine. I used the wrong library settings and combinations in Visual Studio. For those who would like to know, it was a mish mash of libraries from MySQL Connector for cpp with the other libraries from MySQL server. I re-read the instructions and found that there were mistakes.
The catch is that the connector worked for getInt() even with the wrong library settings, elements and combinations and did not work for getString().
The method I used maybe of importance to newbies like me, thus it is listed below:
1- Reduce the code to the minimum required to reproduce the error.
2- Read the documentation of the products you want to use.
3- Try to explain to others, in writing and verbose form, how you want to accomplish what.
4- Revise your own question after some sleep.
This worked for me.

VTK using VoxelModeller to build Voxel Space of Point Cloud

Here's what I'd like to do: I have a .pcd (PCL standard format) file in which it's stored a Point Cloud, I would like to build a voxel representation of it and then extract an isosurface. If I'm not wrong, I should follow this example http://www.vtk.org/Wiki/VTK/Examples/Cxx/Modelling/MarchingCubes, where I should set my pcd as input to vtkVoxelModeller instead of the sphere.
So I tried in this way:
//-------------------------------------------------------------------------
// loading Point Cloud
//-------------------------------------------------------------------------
pcl::PointCloud<PointType>::Ptr cloud (new pcl::PointCloud<PointType>);
std::string inputFilename = "GiraffeHead_2.pcd";
if (pcl::io::loadPCDFile<PointType> (inputFilename.c_str(), *cloud) == -1)
{
PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
return (-1);
}
PointType min_pt,max_pt;
pcl::getMinMax3D(*cloud,min_pt,max_pt);
...
//-------------------------------------------------------------------------
// copying Point Cloud into PolyData
//-------------------------------------------------------------------------
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
for (size_t i = 0; i < cloud->points.size (); ++i)
points->InsertNextPoint(cloud->points[i].x,cloud->points[i].y,cloud->points[i].z);
vtkSmartPointer<vtkPolyData> PCData = vtkSmartPointer<vtkPolyData>::New();
PCData->SetPoints(points);
the rest of the code is taken from the example and the only modifications I make is to set the bounds according to my surface and:
voxelModeller->SetInputConnection(PCData->GetProducerPort());
when I run the executable I get an empty window :(
Since I'm a newbie with VTK and I strongly need it for my research project I'd be very glad if someone could explain me what I'm doing wrong and point out a correct solution.
Thanks
I found out that this tutorial was deprecated.
Following:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ImplicitModeller
and
http://www.paraview.org/Wiki/ParaView/PCL_Plugin
made the trick!

header file for cuda event functions

Which header file to be included for following code snippet to measure time using cuda event mathods?
cudaEvent_t start,stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
float Elapsed=0,Cycle;
for (int p=1; p<=MSG_NUM; p++)
{
cudaEventRecord(start,0);
add<<<R, (M+R), (M+R)* sizeof(int)>>>( d_msg, d_checkSumArray );
cudaEventRecord(stop,0);
cudaEventSynchronize(stop);
cudaElapsedTime(&Cycle,start,stop);
Elapsed += Cycle;
}
printf("Time = %f",Elapsed);
My program show following error as no header file included.
error : identifier "cudaElapsedTime" is undefined
Can someone give the solution please?
The correct API call is cudaEventElapsedTime(...).
Other than that your parameters look correct.
You don't need any special include headers if you are compiling with nvcc.

Python 3 C-API IO and File Execution

I am having some serious trouble getting a Python 2 based C++ engine to work in Python3. I know the whole IO stack has changed, but everything I seem to try just ends up in failure. Below is the pre-code (Python2) and post code (Python3). I am hoping someone can help me figure out what I'm doing wrong.I am also using boost::python to control the references.
The program is supposed to load a Python Object into memory via a map and then upon using the run function it then finds the file loaded in memory and runs it. I based my code off an example from the delta3d python manager, where they load in a file and run it immediately. I have not seen anything equivalent in Python3.
Python2 Code Begins here:
// what this does is first calls the Python C-API to load the file, then pass the returned
// PyObject* into handle, which takes reference and sets it as a boost::python::object.
// this takes care of all future referencing and dereferencing.
try{
bp::object file_object(bp::handle<>(PyFile_FromString(fullPath(filename), "r" )));
loaded_files_.insert(std::make_pair(std::string(fullPath(filename)), file_object));
}
catch(...)
{
getExceptionFromPy();
}
Next I load the file from the std::map and attempt to execute it:
bp::object loaded_file = getLoadedFile(filename);
try
{
PyRun_SimpleFile( PyFile_AsFile( loaded_file.ptr()), fullPath(filename) );
}
catch(...)
{
getExceptionFromPy();
}
Python3 Code Begins here: This is what I have so far based off some suggestions here... SO Question
Load:
PyObject *ioMod, *opened_file, *fd_obj;
ioMod = PyImport_ImportModule("io");
opened_file = PyObject_CallMethod(ioMod, "open", "ss", fullPath(filename), "r");
bp::handle<> h_open(opened_file);
bp::object file_obj(h_open);
loaded_files_.insert(std::make_pair(std::string(fullPath(filename)), file_obj));
Run:
bp::object loaded_file = getLoadedFile(filename);
int fd = PyObject_AsFileDescriptor(loaded_file.ptr());
PyObject* fileObj = PyFile_FromFd(fd,fullPath(filename),"r",-1,"", "\n","", 0);
FILE* f_open = _fdopen(fd,"r");
PyRun_SimpleFile( f_open, fullPath(filename) );
Lastly, the general state of the program at this point is the file gets loaded in as TextIOWrapper and in the Run: section the fd that is returned is always 3 and for some reason _fdopen can never open the FILE which means I can't do something like PyRun_SimpleFile. The error itself is a debug ASSERTION on _fdopen. Is there a better way to do all this I really appreciate any help.
If you want to see the full program of the Python2 version it's on Github
So this question was pretty hard to understand and I'm sorry, but I found out my old code wasn't quite working as I expected. Here's what I wanted the code to do. Load the python file into memory, store it into a map and then at a later date execute that code in memory. I accomplished this a bit differently than I expected, but it makes a lot of sense now.
Open the file using ifstream, see the code below
Convert the char into a boost::python::str
Execute the boost::python::str with boost::python::exec
Profit ???
Step 1)
vector<char> input;
ifstream file(fullPath(filename), ios::in);
if (!file.is_open())
{
// set our error message here
setCantFindFileError();
input.push_back('\0');
return input;
}
file >> std::noskipws;
copy(istream_iterator<char>(file), istream_iterator<char>(), back_inserter(input));
input.push_back('\n');
input.push_back('\0');
Step 2)
bp::str file_str(string(&input[0]));
loaded_files_.insert(std::make_pair(std::string(fullPath(filename)), file_str));
Step 3)
bp::str loaded_file = getLoadedFile(filename);
// Retrieve the main module
bp::object main = bp::import("__main__");
// Retrieve the main module's namespace
bp::object global(main.attr("__dict__"));
bp::exec(loaded_file, global, global);
Full Code is located on github:

Resources