In my embedded project, I'm using emWin for capturing the screenshot. The image saved is in .bmp format.
Now my requirement is to convert this image into a pdf file.
Since there is no option in emWin to save as pdf, I'm thinking of using libharu library.
Does this library have the option to convert bmp to pdf? If it is not useful, how can I achieve this?
Please guide me.
Normaly, emWin can save image into a png format. There is a function in libharu to insert a png file in your pdf.
Ex:
HPDF_Doc Pdf = HPDF_New ( error_handler , NULL ) ;
HPDF_Page Page = HPDF_AddPage ( Pdf ) ;
HPDF_Image MyImage = HPDF_LoadPngImageFromFile ( Pdf ,"tmp//image.png" ) ;
HPDF_REAL Width = HPDF_Image_GetWidth ( MyImage ) ;
HPDF_REAL Height = HPDF_Image_GetHeight ( MyImage ) ;
HPDF_Page_DrawImage ( Page , MyImage , x , y , Width , Height ) ;
Related
I have to download the XML generated in this page:
https://www.backend-rates.ezv.admin.ch/api/xmldaily?d=20210923&locale=it
The only parameter is the date in YYYYMMDD format.
I know there are some SQL function to do this, but I don't know how to approce the problem.
EDIT:
I try this:
SELECT * FROM XMLTABLE(
XMLNAMESPACES (DEFAULT 'https://www.backend-rates.ezv.admin.ch/xmldaily',
'https://www.backend-rates.ezv.admin.ch/api/xmldaily?d=20210922&locale=it' AS "doc" ) ,
'doc/wechselkurse/devise' PASSING XMLPARSE
( DOCUMENT SYSTOOLS.HTTPGETBLOB
('https://www.backend-rates.ezv.admin.ch/dailyrates.xsd'
, ''))
COLUMNS
code Char(3) PATH 'code',
waehrung char(10) PATH 'waehrung' ,
kurs decfloat PATH 'kurz'
)
where code = 'USD'
But I obtain an empty result, can you help me find the error?
Multiple problems, listed below the queries because they kill formatting when not below
SELECT * from
XMLTABLE(
XMLNAMESPACES (DEFAULT 'https://www.backend-rates.ezv.admin.ch/xmldaily'),
'$doc/wechselkurse/devise'
PASSING XMLPARSE
(DOCUMENT SYSTOOLS.HTTPGETCLOB('https://www.backend-rates.ezv.admin.ch/api/xmldaily?d=20210922&locale=it', '')) as "doc"
COLUMNS
code Char(3) PATH '#code',
waehrung char(10) PATH 'waehrung' ,
kurs decfloat PATH 'kurs'
)
where code = 'usd'
You don't need to add your document to namespaces since it's not a namesspace
What you download and parse is not the document but the schema that can validate it
You have to give a name to your document in the xpath expression, that's the use of as 'doc' (and not '$doc' like in my previous answer)
You can refer to that name as $doc in the xpath expression
code is an attribute, you can get it's value using #code
code values are lowercase
Unfortunately I have had issues with my storage and was forced to reacquire data. However, this came in many .csv files and don't know how to import all of them without doing it one by one. I would like to have the 10000+ .csv files into one table and would like help with coding all imports one time.
All of the files have the same schema:
'Symbol' (varchar(15))
'Date' (Date)
'Open' (Float)
'High' (Float)
'Low' (Float)
'Close' (Float)
'Volume' (Int)
Also: All files will have the same structure for their naming:
XXXXXX_YYYYMMDD
(XXXXXX is the name of the market; I have 7 unique names)
Create Table [investment data 1].dbo.AA
(
Symbol varchar(15),
[Date] Date,
[Open] Float,
High Float,
Low Float,
[Close] Float,
Volume Int
)
At this point I do not know how to generate a loop that will look at all files in the "Investment Data" folder; the below example is the sample code for one .csv file. If there is a better way than "bulk insert" then I will modify the statement below.
bulk insert [investment data 1].dbo.AA
from 'R:\Investment Data\NASDAQ_20090626.csv'
with
(
firstrow=2
,rowterminator = '\n'
,fieldterminator = ','
)
Any help is appreciated; if I can be more clear please let me know. Thanks for your time.
Does what you wrote (for that one file) work ?
Great.
Open a dos prompt
Navigate to the folder with your 10,000 files
type DIR /b >c:\temp\files.txt
Now install a decent text editor, like Notepad++ (these instructions are for notepad ++)
Open c:\temp\files.txt in that editor
Open the find/replace dialog, place a tick next to "Extended (\n, \r..." - this makes it match newlines, and support newlines in replacements
Put this in Find: \r\n
Put this in Replace: ' with(firstrow=2,rowterminator = '\\n',fieldterminator = ',');\r\nbulk insert [investment data 1].dbo.AA from 'R:\Investment Data\
This will make your list of files that used to look like this:
a.txt
b.txt
c.txt
d.txt
Look like this:
a.txt' with(firstrow=2,rowterminator = '\n',fieldterminator = ',')
bulk insert [investment data 1].dbo.AA from 'R:\Investment Data\b.txt' with(firstrow=2,rowterminator = '\n',fieldterminator = ',');
bulk insert [investment data 1].dbo.AA from 'R:\Investment Data\c.txt' with(firstrow=2,rowterminator = '\n',fieldterminator = ',');
bulk insert [investment data 1].dbo.AA from 'R:\Investment Data\d.txt' with(firstrow=2,rowterminator = '\n',fieldterminator = ',');
bulk insert [investment data 1].dbo.AA from 'R:\Investment Data\
Now just clean up the first and last lines so it's a proper SQL. Paste and run in SSMS
I have a table and a form for shoe sizes. As of now, my form displays all the elements (sizes) as integers. I'd like to see all the elements as reals.
Job for populating the shoe size table is following:
static void insertShoeSizes(Args _args)
{
SycShoeSizeTable shoeSizeTable;
container sizes, conTake;
int i;
;
sizes = [[35.0 , 3.5]];
sizes +=[[35.5 , 4.0]];
sizes +=[[36.0 , 4,5]];
sizes +=[[37.0 , 5.0]];
sizes +=[[37.5 , 5.5]];
sizes +=[[38.0 , 6.0]];
sizes +=[[38.5 , 6.5]];
sizes +=[[39.0 , 7.0]];
sizes +=[[40.0 , 7.5]];
sizes +=[[41.0 , 8.0]];
sizes +=[[42.0 , 8.5]];
sizes +=[[43.0 , 9.0]];
sizes +=[[44.0 , 10.5]];
sizes +=[[45.0 , 11.5]];
sizes +=[[46.5 , 12.5]];
sizes +=[[48.5 , 14.0]];
for(i=1; i<=conLen(sizes); i++)
{
conTake = conPeek(sizes,i);
shoeSizeTable.clear();
shoeSizeTable.SycSizeEurope = conPeek(conTake,1);
shoeSizeTable.SycSizeUSandCanada = conPeek(conTake,2);
shoeSizeTable.insert();
}
}
You should try to do a little more debugging to solve some of these issues before posting. Put a breakpoint on the line where you insert and see what values were read from the container into the fields. Check if the fields are integers.
Since you use containers a lot (not sure why), you should know about a function called conView(). It's already let me see an error with your data entry.
You can see though that reals are being stored and accessed, so if they're becoming integers, it's likely the table/form.
Make sure your table and form fields have the type Real.
I have an SQL table called buzzinga_menulist with an image column containing values like:
x1.jpg
x2.jpg
x3.jpg
x4.jpg
How do I update all values ending with .jpg suffixes to have .png suffixes instead? I've tried the following but it gives me a syntax error.
UPDATE buzzinga_menulist
SET image = replace(*, '.png', '.jpg')
WHERE image = '.jpg';
Use this query
UPDATE `buzzinga_menulist`
SET `image` = REPLACE(`image`, '.jpg', '.png');
I'm writing a little program that inserts and retrieves movie information in a database. If I type the info into the .db file manually, the program retrieves it and displays it perfectly in my GUI's textboxes. However, if I try to insert data from those textboxes into my database, it adds a linebreak to the end of each field. When I retrieve it again, it has "\n" at the end. The retrieving works great, but somehow linebreaks are being included in my inserts. Here is my insert function:
def addRecord(self):
newTitle = self.text_title.get(1.0, 'end')
newSynopsis = self.text_summary.get(1.0, 'end')
newCast = self.text_cast.get(1.0, 'end')
newRuntime = self.text_runtime.get(1.0, 'end')
newRating = self.text_rating.get(1.0, 'end')
newTrailer = self.text_trailer.get(1.0, 'end')
newDates = self.text_date2d.get(1.0, 'end')
newImage = self.text_image.get(1.0, 'end')
c.execute("INSERT INTO Movies (Title, Synopsis, Actors, Runtime, Rating, Trailer, Dates, Image) VALUES ('{}','{}','{}','{}','{}','{}','{}','{}');"
.format(newTitle, newSynopsis, newCast, newRuntime, newRating, newTrailer, newDates, newImage))
conn.commit()
Tkinter automatically adds a newline as the last character in the text widget. The proper way to get only the contents of the text widget that you or the user inserted you should use "end-1c" ("end" minus one character) rather than "end" or END.
Also, to be pedantic, the first index should be a string, not a float. In the case of 1.0 it doesn't matter, but you should be in the habit of always using strings for the indexes in a text widget.
For example:
newTitle = self.text_title.get("1.0", 'end-1c')