我想在Python中将以下HTML转换为PNG图像.
<html>
<b>Bold text</b>
</html>
Run Code Online (Sandbox Code Playgroud)
当然,这个HTML就是一个例子.
我尝试了'pisa',但它将html转换为PDF,而不是图像.我可以将HTML转换为PDF然后将PDF转换为PNG,但我想知道是否有任何直接解决方案(即HTML到PNG).任何内置或外置模块都可以很好地工作.
如果这可以在Graphicsmagick或Imagemagick中完成,那么它将是完美的.
我在函数名myalloc()中分配一些内存,并在main()中使用和释放它.我使用双指针来做这个,这里的代码工作正常,
//Example # 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void myalloc( char ** ptr)
{
*ptr = malloc(255);
strcpy( *ptr, "Hello World");
}
int main()
{
char *ptr = 0;
myalloc( &ptr );
printf("String is %s\n", ptr);
free(ptr);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是下面的代码不起作用并给出了分段错误.我认为这是使用双指针的另一种方法.
//Example # 2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void myalloc( char ** ptr)
{
*ptr = malloc(255);
strcpy( *ptr, "Hello World");
}
int main()
{
char **ptr = 0;
myalloc( ptr );
printf("String is %s\n", *ptr); …Run Code Online (Sandbox Code Playgroud)