-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add support for creating annotations. #89
Comments
Hi @Christopher-S-25 , thank you for reporting the issue. There are several additional features required to support your use case:
So, there are several steps to get a complete implementation. However, none of them are especially difficult. I will focus on adding the features in the order above. |
Added The next step is to allow setting the position and appearance of the annotation. |
Moved setting of comment text out of Currently, the annotations are not explicitly attached to anything in particular. The next step is to deliberately attach them to specific page objects. |
Added new More work is needed to add customising the annotation's appearance. The relationship between the position of the annotation and the attachment points that associate it with a page object is also not yet entirely clear. |
Corrected two bugs in handling of attachment points. Added setting and retrieving of stroke and fill colors for markup annotations. Added PDF versions after 1.3 support appearance streams, allowing for multiple representations of annotations and their popups depending on an appearance mode parameter set by the PDF viewer. There are a few little details to tidy up, but the main missing item in the implementation is support for these appearance streams. Ideally this would be transparent, so the caller doesn't have to worry about whether they are using a PDF file before or after version 1.3. |
Added mutable unwrapper functions for all annotation types to |
I'm sorry for being super late, I can create annotations easily now, thank you very much for your excellent code! |
No problem. I'd like to improve the appearance streams support, but other than that I think the work is basically done. |
Could you add an example of how to add a Stamp? I have not been able to successfully create anything but an empty blank stamp. How do I change the stamp contents and appearance? |
Hi @Jay00 , yes, I will extend the If you prefer to use raw FPDF_* functions, you can see an example of how to do this at https://pdfium.googlesource.com/pdfium/+/refs/heads/main/fpdfsdk/fpdf_annot_embeddertest.cpp#1261. It may also be necessary to update the annotation's appearance stream. A discussion related to that is currently underway in #132. |
@ajrcarey thanks! I appreciate the direction. I am trying to implement a custom stamp. I found this C# example, but I have not been able to recreate it with bindings in Rust.
I was able to add a stamp object to the page, but it was not my custom image, it was just blank. And very strangely, after manipulating the stamp's rotation value in Adobe Acrobat, the blank stamp turned into a generic DRAFT stamp. It is probably something to do with the appearance stream issues you mentioned, but I have not been able to figure it out yet. |
Yes, it's very likely because the appearance stream for your custom object is not being generated. In the short term you may be able to set a null appearance stream directly as discussed at #132; this would force viewer applications to generate the appearance stream themselves, which would at least display something. In the longer term I will think of a cleaner (ideally, an automatic) way of having |
Bumped crate version to 0.8.20 to formally release work so far. With PR now submitted for #132, next steps are to move ahead with appearance stream regeneration and creation of an example of creating a custom stamp annotation. |
Appearance stream regeneration should ultimately be handled upstream in Pdfium itself as part of work done in #145. |
Looking at google's Pdfium library, I figured that it's possible to add Annotations using
FPDFPage_CreateAnnot()
. An example can be found in theAddAndSaveLinkAnnotation
test in pdfium/fpdfsdk/fpdf_annot_embeddertest.cpp.I'm not entirely sure what needs to be done to implement it, whether it's easy or hard or whether the existing types for Annotations are adequate for creating an Annotation or need to be changed. I'm not good at C++, let alone C++ interop, and it's pretty confusing to me overall.
I mainly need this for creating Link Annotations.
The text was updated successfully, but these errors were encountered: