Code Monkey home page Code Monkey logo

pdfgen's Introduction

PDFGen

PDFGen Logo

Buy Me A Coffee

Simple C PDF Creation/Generation library. All contained a single C-file with header and no external library dependencies.

Useful for embedding into other programs that require rudimentary PDF output.

Supports the following PDF features

  • Text of various fonts/sizes/colours/rotation
  • Primitive drawing elements
    • Lines
    • Rectangles
    • Filled Rectangles
    • Polygons
    • Filled Polygons
    • Bezier curves
  • Bookmarks
  • Barcodes (Code-128 & Code-39)
  • Embedded images
    • PPM/PGM (binary format only)
    • JPEG
    • PNG (Alpha Channels are not supported)
    • BMP

Example usage

#include "pdfgen.h"

int main(void) {
    struct pdf_info info = {
        .creator = "My software",
        .producer = "My software",
        .title = "My document",
        .author = "My name",
        .subject = "My subject",
        .date = "Today"
    };
    struct pdf_doc *pdf = pdf_create(PDF_A4_WIDTH, PDF_A4_HEIGHT, &info);
    pdf_set_font(pdf, "Times-Roman");
    pdf_append_page(pdf);
    pdf_add_text(pdf, NULL, "This is text", 12, 50, 20, PDF_BLACK);
    pdf_add_line(pdf, NULL, 50, 24, 150, 24, 3, PDF_BLACK);
    pdf_save(pdf, "output.pdf");
    pdf_destroy(pdf);
    return 0;
}

License

License: Unlicense

The source here is public domain. If you find it useful, please drop me a line at [email protected].

Builds

Build status: GitHub Actions

Appveyor status: Build status

Code Coverage: Coverage Status

Coverity scan: Coverity scan

Static Analysis

This is a code base that I use to test static analysis tools. As such the build system is quite a bit more complex than should be necessary for a project of this size.

Language Bindings

pdfgen's People

Contributors

andrerenaud avatar endanke avatar epicalert avatar jdek avatar juliangmp avatar mahmoudfayed avatar mattparks avatar mcgouganp avatar partialvolume avatar phf avatar polarisru avatar ribalgz avatar twpayne avatar unionsystems avatar yevgenypats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdfgen's Issues

Adding grayscale jpeg doesn't work

Using the pdf_add_jpeg function works for RGB jpegs, but not for grayscale jpegs.

The reason is that ColorSpace /DeviceRGB needs to be ColorSpace /DeviceGray for grayscale images.

I unfortunately don't know how to check for this in a JPEG file or I would have opened a PR :)

Macos

MacOS has a special way of doing fprintf (%f, 3.14) It always has the same output: 3,14. This does not depend of the locale. This results in a damaged pdf. I have solved it in my own project Side Cutters, free CAD software, see issue .

Some improvements

I have found this project 2 years ago and have used it for my development for a while.
That's why I have added some more features to the source code.
This is a list of features:

  • adding PNG and BMP images
  • adding a same header block to every page of the project
  • adding QR-code based on Project Nayuki (MIT license)

I have also started to add embedded fonts support.

Please let me know if you need this features in your beauiful project. There are already some differences between the actual code and the code I have changed then, so I have to do some changes and need to know if you really want them.

Thank you in advance.

Visual Studio build problems

I'm using PDFGen in a C++ project in Visual Studio 2019, when I try to compile I get a few compile errors:

  • #include <strings.h> cannot be found
  • #define _XOPEN_SOURCE will not define M_SQRT2, #define _USE_MATH_DEFINES will
  • SKIP_ATTRIBUTE is not defined, when _MSC_VER < 1900 is removed I have no problem
  • stat is not a valid symbol, I can use #define stat _stat in the MSC_VER block

Immediate mode

Consider switching to immediate mode: outputting content streams as they are created.

I've simplified PDFGen to my needs, switching to immediate mode, thus completely avoiding saving contents. The result is pdfsg. See my notes for details.

Thank you very much for PDFGen! It's very nice reading!

Adding an image as the entire page

Hello,

First of all, thank you for the work on this library. I am amazed that this runs without any external dependencies.

I'm trying to convert a large collection of images to a PDF, and have each image be its own page while keeping aspect ratio and image quality.

The problem here is that I need know the image size before calling pdf_page_set_size.
I have read through issue #5, and I understand your reasoning not to include a „get image size“ function.
However, since you do read the image headers and parse the image dimensions when adding the image anyway, it is easy to achieve what I described above. While testing I simply changed pdf_add_png_data's last few lines:

pdf_page_set_size(pdf, page, info.width, info.height);
return pdf_add_image(pdf, page, obj, x, y, info.width, info.height);

Do you think it would be feasable to have a function seperate from pdf_add_image_file/pdf_add_image_data (or a parameter) to achieve this?

I know this is a rather special use case, but I think this would be the better solution rather than to pull some huge dependency only to determine the image dimensions.
If I find time in the coming days I will work on a patch that introduces something like this - if I can manage to make it not horrible.

Generated PDF Comes Broken

I am working on pdf writer plugin for Unreal Engine 5.
I have plugins with PDFium and LibHaru but they have lots of problem so I am looking additional solutions.

(LibHaru doesn't work with mobile and suggested callback functions for saving PDFs on PDFium doesn't work with image inserted PDFs. They say we need to append our file with a loop but there is no sample or documentation about it.)

I included pdfgen.c and pdfgen.h from your master repo and write these codes as sample.

void UFF_PDFGENBPLibrary::PDFGen_Create_Doc(UPdfGenDoc*& Out_PDF, FString In_Author, FString In_Creator, FDateTime In_Date, FString In_Producer, FString In_Subject, FString In_Title, FVector2D In_Size, FString Path)
{
	/*
	const pdf_info PDF_Info = 
	{
		*TCHAR_TO_UTF8(*In_Creator),
		*TCHAR_TO_UTF8(*In_Producer),
		*TCHAR_TO_UTF8(*In_Title),
		*TCHAR_TO_UTF8(*In_Author),
		*TCHAR_TO_UTF8(*In_Subject),
		*TCHAR_TO_UTF8(*In_Date.ToString())
	};
	*/

	struct pdf_info info = {
		"My software",
		"My software",
		"My document",
		"My name",
		"My subject",
		"Today"
	};

	pdf_doc* Document = pdf_create(PDF_A4_WIDTH, PDF_A4_HEIGHT, &info);

	pdf_add_text(Document, NULL, "This is text", 12, 50, 20, PDF_BLACK);
	pdf_add_line(Document, NULL, 50, 24, 150, 24, 3, PDF_BLACK);
	pdf_save(Document, TCHAR_TO_UTF8(*Path));
	pdf_destroy(Document);
}

first info structure gets its values from argument (inputs exposed to Unreal's blueprint system. So, we can change them without returning code even in runtime. FString is equal to const char*) but generated PDF stucked at %45 when I want to open it with chrome.
So, I commented it out and used second struct. I got same result.

Is there any suggestion for that ?
Also do you have a plan to update PDF system to 1.7 ?

This is generated PDF
sample_pdfgen.pdf

Bisotun: A wrapper library around PDFGen

I'm very excited to share with anyone interested in PDFGen, which I made a wrapper library around PDFGen to writing documents more simple and a little bit more high-level:

https://github.com/LinArcX/bisotun

Actually, I'm using it mainly to create my resume, but you can generate books and other kind of documents with it.

Thanks again Andre for your great library.

The pdf_add_text_wrap method does not work for me

I have tried using the pdf_add_text_wrapp method, but without success. I don't know if I'm doing something wrong, but I can't get it to work. I have used the fuzz-text.c example but it doesn't even show me the text in the document I generate.

heap buffer overflow in jpeg_size

git log

commit 206ef1b560efed48aabcb9374ea0e6e832b59f7e
Author: Andre Renaud <[email protected]>
Date:   Wed Apr 4 08:59:06 2018 +1200

    Updated README

test code

int main(int argc, char *argv[])
{
    struct pdf_info info = { 
     .creator = "hello",
     .producer = "world",
     .title = "My document",
     .author = "My name",
     .subject = "My subject",
     .date = "Today"
     };  
    struct pdf_doc *pdf = pdf_create(PDF_A4_WIDTH, PDF_A4_HEIGHT, &info);
    pdf_set_font(pdf, "Times-Roman");
    pdf_append_page(pdf);
    pdf_add_jpeg(pdf, NULL, 100, 500, 50, 150, "./poc.jpg");
    //pdf_add_text(pdf, NULL, data, 30, 0, 400, PDF_RGB(0xff, 0, 0));
    pdf_save(pdf, "output.pdf");
    pdf_destroy(pdf);
    return 0;
}

error

==6203==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000efd6 at pc 0x00000040c5a6 bp 0x7ffcbb9c1da0 sp 0x7ffcbb9c1d90
READ of size 1 at 0x60200000efd6 thread T0
    #0 0x40c5a5 in jpeg_size /home/github/PDFGen_bak/pdfgen.c:2015
    #1 0x40c5a5 in pdf_add_raw_jpeg /home/github/PDFGen_bak/pdfgen.c:2079
    #2 0x40c5a5 in pdf_add_jpeg /home/github/PDFGen_bak/pdfgen.c:2208
    #3 0x401bd4 in main /home/github/PDFGen_bak/main.c:19
    #4 0x7fcc3558382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #5 0x401d08 in _start (/home/github/PDFGen_bak/testprog+0x401d08)

0x60200000efd6 is located 0 bytes to the right of 6-byte region [0x60200000efd0,0x60200000efd6)
allocated by thread T0 here:
    #0 0x7fcc359cb602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x40b914 in pdf_add_raw_jpeg /home/github/PDFGen_bak/pdfgen.c:2064
    #2 0x40b914 in pdf_add_jpeg /home/github/PDFGen_bak/pdfgen.c:2208

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/github/PDFGen_bak/pdfgen.c:2015 jpeg_size
Shadow bytes around the buggy address:
  0x0c047fff9da0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9db0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9dc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9dd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9de0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c047fff9df0: fa fa fa fa fa fa fa fa fa fa[06]fa fa fa 00 fa
  0x0c047fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==6203==ABORTING

testcase:https://github.com/xcainiao/poc/blob/master/PDFGen_heap-buffer-overflow_in_jpeg_size.jpg

static pdf_object *pdf_add_raw_jpeg(struct pdf_doc *pdf,
                                    const char *jpeg_file)
{
    ....
    if (stat(jpeg_file, &buf) < 0) { 
        pdf_set_err(pdf, -errno, "Unable to access %s: %s", jpeg_file,
                    strerror(errno));
        return NULL;
    }    

    len = buf.st_size;
    ....
    if (jpeg_size(jpeg_data, len, &width, &height) < 0) { 
        free(jpeg_data);
        pdf_set_err(pdf, -EINVAL, "Unable to determine jpeg width/height from %s",
                    jpeg_file);
        return NULL;
    }    
    ....
static int jpeg_size(unsigned char* data, unsigned int data_size,
                     int *width, int *height)
{
    int i = 0; 
    if (i + 3 < data_size && data[i] == 0xFF && data[i+1] == 0xD8 &&
            data[i+2] == 0xFF && data[i+3] == 0xE0) {
        i += 4;
        if(data[i+2] == 'J' && data[i+3] == 'F' && data[i+4] == 'I'
                && data[i+5] == 'F' && data[i+6] == 0x00) {

len = 6;
data[i+6] == 0x00 //error

Feature request: transparent text

I was hoping to overlay some transparent text in my pdf. I noticed that pdf_add_text_spacing() supports only RGB. A played a little trying to emit the right commands but my pdf foo isn't strong enough to set the alpha correctly :/ - maybe it's super easy for you.

TrustInSoft follow up: formal verification of your test suite

Hi Andre,

Let me know if you had a chance to take a look at the continuous integration tool TrustInSoft CI.

I began to set it up on this project. Here’s the link: https://ci.trust-in-soft.com/projects/jakub-zwolakowski/PDFGen/1

On the 2 test cases which I configured, no Undefined Behaviors were encountered, as you have already fixed all the issues that we had found before.

You can also see how it looks like when some more tests are added and different architectures checked: https://ci.trust-in-soft.com/projects/jakub-zwolakowski/PDFGen-UB/11

If you’re interested, I’m happy to help you with the setup. But also you shouldn't need much help: it involves creating an account, adding the tis.config file, and then some other minor configuration effort.

Smart quotes and em dash

Thanks for this nice pdf library. I'm trying to write some pretty standard text to pdf, but I'm running into issues with the limited UTF8 support. What is required to add support for a few more characters?

Specifically, I'd like smart quotes and em dash support.

Alignment of rendered text

Hi @AndreRenaud
If I align the text as PDF_ALIGN_CENTER at the centre of the A4 page, the text still aligns as left. Also the left and right alignment is not working as I am hoping.

I'm assuming that if I write "ATA", the letter T should be at the xy co-ordinates.
Also, since it's not the word document, you can add 9 different alignment options as you can see in the attached image.

  1. Top-left 2. Top-Center 3. Top-Right
  2. Center-left 5. Center 6. Center-Right
  3. Bottom-left 8. Bottom-Center 9. Bottom-Right

Screenshot 2020-05-28 at 8 54 40 PM

PDF Size

Hi Andre,

This issue was already raised by @nomancyclewala but closed due to its lack of need by users.

I will be generating at least 100 pages as shown in the attachment, but the size is increasing proportionally.

Is there anyway to reduce it?

pdf2.pdf

main.txt

printf style format specifier %f

Guys, I appreciate all the work you've done for the PDFGen code base. However I have one small observation regarding the use of the "%f" format specifier. By default I've noticed on some platforms this formats the value 0.0 as "0.000000" which adds unnecessary "0" bytes to the PDF stream.

My local testing has shown that using the "%g" format specifier results in a much more compact "0" for a 0.0 value saving several bytes in many places throughout the PDF stream.

FYI, I ported the PDFGen code base to my legacy mainframe project (MVS 3.8J operating system running on the Hercules emulator) with a bit of effort to deal with EBCDIC code as input the code generating a PDF file. Let's just say that mainframes don't know much about ASCII and/or UTF8 characters ;)

Thanks for your time and effort. The code overall is very nice and easy to work with. Best wishes to all.
--Mike Rayborn

Improvement

It would be great , if we can use HDC -functions too

(like DrawText, LineTo, ...)

great work btw :-) thanks a lot !

position (yoff) bug?

Hello.

First, thanks for this great work!

So, I'm testing the following example:

#include <stdio.h>
#include "pdfgen.h"

int main() {
    struct pdf_doc *pdf = pdf_create(PDF_A4_WIDTH, PDF_A4_HEIGHT, NULL);
    pdf_append_page(pdf);
    pdf_set_font(pdf, "Times-Roman");
    pdf_add_text(pdf, NULL, "This is text", 48, 0, 0, 0);
    pdf_save(pdf, "output.pdf");
    pdf_destroy(pdf);
    return 0;
}

and it generates the following page:

image

it is OK for x = 0, however, for the y = 0, it should generate as the following one:

image

what I'm doing wrong? 😕

Issues with adding png image files to pdf

Hello.
First of all, great work on the library, it is very helpful.

Now, my issue is that when i attempt to add a .png image either from memory or from file to a newly created pdf file:

  1. If the image DOES contain alpha channel and i read it from file, the error "PDF doesn't support PNG alpha channel" is displayed
  2. If the image DOES contain alpha channel and i read it from memory, the error "PNG chunk length larger than file" is displayed
  3. If the image does NOT contain alpha channel and i read it from file, the error "PNG chunk length larger than file" is displayed
  4. If the image does NOT contain alpha channel and i read it from memory, the error "PNG chunk length larger than file" is displayed

I dug in the source and this line:
chunk = (const struct png_chunk *)&png_data[pos];

does not seem to read correctly the chunk length.
The number i debug as chunk length inside the source (right after that line) is 218103808 instead of 13. This happens on the first iteration of the while(1) loop, while reading the "IHDR" length bytes.

Tried with more than one image, the same number is returned.
Tried to set chunk->length by reading manually 4 bytes from png_data, but it fails after some iterations with error "Wrong PNG format, chunks not found".

The images used to test the issue were downloaded from the internet, they are displayed correctly in programs(windows Photo, gimp etc.), and are not changed in any way from my program, just loaded as bytes.
Note that i have tested the validity of those loaded bytes by saving them to a test file, which is a perfectly working file. So the bytes are likely not corrupt/messed in any way.

Lua binding

Greetings, I would like to thank you for your collaboration to the community with this library, I share here, a binding for lua, in which I have been working, it is still in early stage of development and does not cover all the methods, but it is already usable, greetings.

https://gitlab.com/vitronic/lua-pdfgen

<sys/stat.h> no such file or directory found

Hi Andre,

I'm trying to port this library in MPLAB X IDE and the compiler is XC32 ver2.41.
After adding pdfgen.c and pdfgen.h in my project I'm facing several issues in which this
<sys/stat.h> no such file or directory found is the one which I can't get over with. The compiler has all required header files except this. I found such header in Arduino Directory and tried to copy them in my project but it only added with more errors.

How can this be solved?

Blank Pages

Hi Andre
I downloaded PDFGen project and compiled (using VS2013) it with you test main.c
All compiled without issue and it generates a pdf file when run.
Only when viewed with Acrobat Reader DC I get 3 blank A4 pages and 1 black A3 page along this the bookmarks.
I downloaded Soda PDF and it displays the pages correctly.
Do you know of any reason why
PDFGen doesn't generate Adobe compatible pdf's.
Thanks in advance... Milton
Adobe

WinAnsiEncoding

Hey, bro.
you have an excellent library
I'm using it.
I made some changes to include winansiencoding. If you want to take a look, follow the code:
Line: 650

case OBJ_font:
        /*
        fprintf(fp, "<<\r\n"
                "  /Type /Font\r\n"
                "  /Subtype /Type1\r\n"
                "  /BaseFont /%s\r\n"
                ">>\r\n", object->font.name);
        */
        fprintf(fp, "<<\r\n"   /*WinAnsiEncoding*/
         "  /Type /Font\r\n"
         "  /BaseFont /%s\r\n"
         "  /Subtype /Type1\r\n"
         "  /Encoding /WinAnsiEncoding\r\n"
         ">>\r\n", object->font.name);
        break;

some Utf8 to WinAnsiEncoding:
Line: 897

#ifndef pdf_UCHAR 
#define pdf_UCHAR(c) (unsigned char)c
#endif

int pdf_add_text(struct pdf_doc *pdf, struct pdf_object *page,
                 const char *text, int size, int xoff, int yoff,
                 uint32_t colour)
{
    int i, ret;
    int len = text ? strlen(text) : 0;
    struct dstr str = {0, 0, 0};

    /* Don't bother adding empty/null strings */
    if (!len)
        return 0;

    dstr_append(&str, "BT ");
    dstr_printf(&str, "%d %d TD ", xoff, yoff);
    dstr_printf(&str, "/F%d %d Tf ",
                pdf->current_font->font.index, size);
    dstr_printf(&str, "%f %f %f rg ",
                PDF_RGB_R(colour), PDF_RGB_G(colour), PDF_RGB_B(colour));
    dstr_append(&str, "(");

    /* Escape magic characters properly */
    for (i = 0; i < len; i++) { 
        if (strchr("()\\", text[i])) {
            char buf[3];
            /* Escape some characters */
            buf[0] = '\\';
            buf[1] = text[i];
            buf[2] = '\0';
            dstr_append(&str, buf);
        } else if (strrchr("\n\r\t\b\f", text[i])) {
            /* Skip over these characters */
            ;
        } else if( pdf_UCHAR(text[i]) == 226){
			char buf[5];
			buf[0] = '\\';
			buf[1] = '2';
			buf[2] = '0';
			buf[3] = '0';
			buf[4] = '\0';/* \200 : euro symbol*/
            dstr_append(&str, buf);
            i++; i++; /*jump two unused characters*/
        }else if(  pdf_UCHAR(text[i]) == 195){
		   char buf[2];
		   buf[0] =  pdf_UCHAR(text[i+1]) + 64;
		   buf[1] = '\0';
		   dstr_append(&str, buf);	
		   i++;   			
		} else if(  pdf_UCHAR(text[i]) == 194){
			/*skip this*/
		}else {
            char buf[2];
            buf[0] = text[i];
            buf[1] = '\0';
            dstr_append(&str, buf);
        }
        
    }
    dstr_append(&str, ") Tj ");
    dstr_append(&str, "ET");
    /*printf("\n\n---<<%s>>\n\n", str.data);*/
    ret = pdf_add_stream(pdf, page, str.data);
    dstr_free(&str);
    return ret;
}

Sorry for my English, I'm Brazilian. I'm not an expert on C programming, and if you can perfect or fix it, I'm happy.

PDF size

I am using this library to dynamically create upto 50 Pages which generates a file with a size of 5.5MB. Is there a way to control the size of the output file ? or any other ways to reduce the dpi of the pdf ?

Unicode Fonts

Hello Andre, thanks for making and sharing PDFGen. It's clean, small, without dependencies. Great. I see you looked into adding fonts to the PDF. Any update / beta / idea on loading and using fonts supporting unicode characters? Pierre

Improper Display of °(Degree Symbol)

Hi Andre,

As I have to show temperature let's say 27°C, it's resulting as 27A°C in the PDF. I opened pdf using MAC Preview and Adobe Reader, but same results.
This problem also occurs with special characters as well.

please take a look at the main code and output.

Thanks

output2.pdf

main.c.txt

MINGW COMPILATION

how do i get it to run on windows codeblocks...
undefined reference to `pdf_create'

Minor gcc warning in pdfgen.c

pdfgen.c: In function ‘find_word_break’:
pdfgen.c:1822:42: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1822 | while (string && *string && (*string < 0 || !isspace(*string)))


static const char *find_word_break(const char string)
{
/
Skip over the actual word */
while (string && *string && (*string < 0 || !isspace(*string)))
string++;

return string;

}


While statement should be:

while (string && *string && (*string <= 0 || !isspace(*string)))

gcc/g++ warnings

Hey,
This seems like an awsome library. I would like to integrate this library to my C/C++ projects, but I'm a gcc/g++ user and the current build presents a few errors/warnings. I don't know if you care to support these compilers. I would love if you did :)

Cheers!

Support hyperlinks

Hi Andre, I like the simplicity of this library. but still, it missed some features.(IMO)

One of them is hyperlinks. currently, we have: pdf_add_link(...), but it's just for linking between pages inside a pdf. but what about web links?

This feature can be beneficial.

Get image dimensions in library?

Hi,

First I want to thank you for work in this library :)
I'm currently working on a html2pdf converter in ANSI-C, and when it comes to drawing an img without dimensions, I needed to create a function to get its original height and width.

Since to draw an image with PDFGen the dimensions are mandatory, do you think it would be useful to include that function in the library or would you prefer it to be a feature to be implemented in the client?

If you want, I can send a pull request implementing this feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.