-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are bitmap (.bmp) files supported ? #286
Comments
The library does not provide embedding for BMP file formats. only tiff, jpg, png and the embedding of PDF files are supported natively (so if you got something quick to use to convert to any of those...this could be sufficient). You can still, however, embed any image data provided that you can translate the source data in bmp to raw color data, or to any of the PDF supported encoders. This goes through creating a PDF Image object, which is something you can do with the library. I have an example of how to do something like that with TIFF images. I use libtiff to decode the image to color data (also alpha mask, for transparency effect) and then build a PDF image object directly into the PDF. specifically https://github.com/galkahana/pdf-transparent-tiff/blob/master/src/lib/ModernTiffImageHandler.cpp#L88 shows how to create the image object and write the raw color data. scanning a few libs it might be quite simple to translate bmp code to raw data...as it is pretty much there to begin with. so it might not be overly difficult to find something read it or write something yrself along the lines of existing libs/samples/attempts. Gal. |
Thanks. I was able to adapt that code to work with bitmap. Now my only problem is, is that I can't seem to figure out how to make it modify a preexisting PDF page and add a image to it. |
well, if it's just an overlay on an existing page you can essentially add a new content stream to a page, and place drawing commands to put the image form. there's a helper implementation with the library that makes this fairly simple. refer to the |
EDITED: Removed due to creating a example in a repo |
I did find PDFModifiedPage. I tried it out and maybe I am using it wrong. It does not complain. The output does not have the barcode. The original style adds a new page that has the barcode. https://github.com/devilsclaw/pdf_barcode output/output1.pdf is where it adds a new page and has the barcode at the bottom |
On my own build I also make it add text to the pdf with WriteText. The text wont show up after
is called. |
reviewed the project. very nice :) when looking at output2 you can see that there's a form starting and then while in it there's another form starting. the former is the implementation of the content context that's just started, and the latter is the barcode form xobject. this is a corrupted pdf. In this case is just moved the barcode form creation to be prior to the content context to resolve the issue and have the barcode show up. This is the right thing to do for both modification case, and adding new page. Depending on how your application flow goes there's several other strategies you can use for the case of realizing you want to create an object in the midst of a content context session:
in any case, a wonderful example of using BMP image :). |
First off thank you very much. Second this was very much almost a whole sale rip from the tiff project you pointed to. So it should have the same problem. Again thanks. I will try it out. |
Merged the pull request and tested again thanks. I wanted to point out that out of all the project managers I have had to deal with. Your one of the best and most helpful. |
Oh one other thing, since the project is based off your project how would I give attribution ? I have not used many apache 2 license projects. |
No attribution required, unless you include source code in your project in which case what source code you take should retain the notice at the top (meaning you shouldnt jsut take the source code without the copyright notice i left there)...and if you make modifications to them do document those changes there. In the example project you provided, given yr just referencing the project via cmake there's no need to do any of that. however, in a project such as this one where i have copies of the code, i have to include them as a whole. Also - 0 liability on my part and no warranty is provided. This is code that i provided for the benefit of the software community, not for it to come back and haunt me. it is provided as open source for a reason - so you can change if it doesn't work for you, and/or debug what issues you see. while i do provide assistance on occasion this is by no means guaranteed. Gal. |
So the project https://github.com/galkahana/pdf-transparent-tiff which is yours has a license file but nothing in the source files that would look like attribution. My project copies some of the functions and then modifies them to work with the bitmap buffer from zint. So I was trying to figure out how to attribute. Since to me its mostly your code with just a small adaptation. Would i just add something to the top of the source file that point to the original project that it was based off of and your name ? |
Maybe something like this at the top of the main.cpp ?
|
i think you can avoid even that. it's different enough to not be considered a derived work. |
Currently I am using Zint to generate code 39 barcode and the direct to buffer. The only format currently supported for direct to buffer is bitmap.
I was wondering if this project supports the file format to be embedded or a simple way to convert it to any of the other formats that it does support ?
The text was updated successfully, but these errors were encountered: