how do I add bookmark into a pdfpcell - itext

I am doing a report which contains more 1000 records by using pdfptable of itext. it is not easy to seek a particular record, so i am wondering if there is any way to add bookmark in a pdfpcell.

To add bookmarks into a pdf using iTextSharp, you have to use the Chapter and/or Section objects. While technically, you can make this work, the Chapter and Section objects have some limitations and some pretty large overhead, especially for 1000's of items. Also, I have never been able to stop the chapter and section numbers from being displayed in my document, which is probably an issue for you if your content is in pdfpcells.
This link provides a good introduction to adding Bookmarks to a pdf. Scroll down to almost the end of the article for the Bookmark section.
Also in this article, is information about setting LocalDestinations in a pdf. These don't show up as Bookmarks, and they require both a 'Goto' link and a 'Destination'. So, if you were willing or able to create an index page in your pdf, this might be a better solution. Your index page would contain all of the 'Goto' links, and the content in your pdfpcells would be the LocalDestinations.

Related

add page headers to roxygen2 docs

I'm using roxygen2 to document the objects in my R package, as described in the book R packages. I want to insert some text at the top (and bottom) of the doc page for every object, saying for example, "Confidential - Do Not Release". For the HTML doc pages I could do that with a CSS content property, or by inserting some HTML of course.
So how can I modify the page headings of the doc pages rendered from roxygen2? For now I'm only interested in the HTML doc pages, not PDF, so it might be enough to insert some arbitrary CSS or HTML into every doc page with roxygen2, or Rd. Is that possible?
Ideally I'd like to find an option that I can set once globally for the whole package, since if I have to add it separately to each object's documentation, I may miss some. But if I have to add it to each object, I can live with it.

Space length limitation

I have a word document file which is a form.
I try to complete it. Here is a screenshot of how it is looks like
When I type in the grey box there is a limitation in length and when I reach it, it won't let me type more.
I am not sure of what it is, however I want to insert an image or a table but I can't.
How can I make it?
The field you are trying to enter information into is a Legacy Text Form Field in Word 2010. In order to have a data entry area within the form that will accept text, tables, and images, delete this field and replace it with a Rich Text Content Control. This control is found on Word's Developer Tab:
Instructions for Displaying Word Developer Tab (if needed)
Like the legacy form fields, content controls allow manual or programmatic entry of data as well the ability to restrict editing of the data within the content control. Gregory K. Maxey has posted an incredibly detailed tutorial on creating forms with content controls, programming the content entry via VBA (Visual Basic for Applications) and restricting editing of the control's contents (all of which is available using the Rich Text Content Control):
Create Forms with Content Controls by Gregory K. Maxey
The same author also has an additional posting on content controls where he provides links to and offers explanations of more advanced content control abilities such as data mapping:
Content Controls (Additional Information) by Gregory K. Maxey
Lastly, Microsoft also provides some guidance on programming content controls via .NET (which I think may be beyond the scope of your question, but which I include for future readers):
MSDN: How to Add Content Controls to Word Documents

Adding a hit counter to Desktop Intelligence/Xi 3/Business Objects webpage?

for my company I am making a report in Xi3/Desktop Intelligence that pulls data via free hand SQL and makes a html file displaying the data, updating every 20mins. We want to incorporate a hit counter that will show us the number of times this report is being viewed.
I found a couple basic templates online. I tried copying and pasting them into a cell, but the output HTML page just displayed the full HTML (unrendered by my browser). I am decent at writing my own HTML, but I just do not understand how to stick my own HTML code in a dynamically updating report in Xi3.
Moreover, I doubt (for legality reasons) my company will be okay with me using a free hit counter template I find online, especially considering they all seem to reference a third party website to do the actual "counting." Any ideas of the best way to implement/learn how to create a visitor counter?
Thanks.
You can include HTML in a DeskI report. In the cell that contains the HTML, click Format Cell; on the "Number" tab, there is a checkbox for "Read as HTML". Make sure that's checked off. Note that you won't see the rendered HTML within DeskI, but it will display when viewed in Infoview.

Creating PDF from HTML using iTextSharp with TextField and editing the same later

I have a requirement to create a PDF file from HTML. The resulting PDF needs to have iTextSharp TextField or something similar. I need to update the PDF document with appropriate text in the text field.
Points to note:
1. The PDF length (page numbers) may vary.
2. Due to this, I may have to only know the name of the field to set value to.
OR
I could create a PDF from HTML. As the content of the PDF may vary, I do not know the exact location of a block that I need to edit. I need to stamp text exactly over the block irrespective of the location of the block (i.e. the block may exist in any page).
Example Scenario:
Create a PDF from HTML.
It is sent for approval process. Once it is approved, the name of the approver is printed at a specific place (however the signature area, mentioned as block above, may come at any page, as it depends on the content of the HTML).
Two resources which may help you:
This article details how to use asp.net & itextsharp to create a pdf.
The whole article is pretty useful for a beginner like me, but the section detailing how to create a pdf from HTML may be useful for you as a start on your problem.
https://web.archive.org/web/20211020001758/https://www.4guysfromrolla.com/articles/030911-1.aspx
I would especially pay attention to how he replaces placeholders in the HTML template he is loading. As it seems you may want to head in that direction.
Now to answer your question more directly, have you thought about using a fillable form?
Here is a related Stack Overflow post.
Creating a fillable PDF form with ITextSharp
As I said I am a beginner, so I can't do much to help you from here. But with any luck you can put those together and accomplish what you are looking for.
Let me know if that helps Good luck!

Converting large amounts of text and dynamic data into PDF

I have a three page Word document that needs to be converted into PDF. This Word document was given to me as a template to show me what the PDF output should look like. I tried converting this document into PDF, created a PDF form and used iTextSharp to open the form, populate it with data and return it back to the client. This is all great but due to large amounts of data stored, the placeholders were insufficient and the text would be truncated or hidden.
My second attempt was to create an MVC 2 View without master page, pass the model to the view, take the HTML representation of the View, pass it over to iTextSharp and render the PDF. The problem here was that iTextSharp failed on some tags (one of them was <hr> tag). I managed to get rid of the problematic tag, but then tables were not rendered properly. Namely, the border attribute was ignored so I ended up with borderless tables. That attempt failed.
I need a suggestion or advice on the most efficient way to create a PDF document in MVC 2 which would be maintainable in the long run. I really don't want my actions to be 200+ lines long. Working directly with the Word document is not the best solution as I have never worked with VSTO so I don't quite know what it would look like to open Word and manipulate text inside of it and add dynamic data and then convert that dynamically into PDF.
Any suggestion is highly welcome.
Best regards!
One thing that I've done in the past is to save the Word file as a DOCX and unzip it since DOCX is just a renamed zip file. Within the archive open up /word/document.xml and you'll see your document. There's a lot of weird XML tags in there but overall you should get a pretty good idea of where your content is. Then just add placeholder text like {FIRST_NAME}, save the file and re-zip.
Then from code you can just perform the same steps, unzipping with something like SharpZipLib or DotNetZip, swapping placeholder copy, re-zipping and then using very simple Word automation to Save-As a PDF.
The other route is to fully utilize iTextSharp and actually write Paragraphs and PdfPTable and everything else. It takes a lot longer to setup but would give you the most control.
Q: you say "... but due to large amounts of data stored, the placeholders were insufficient and the text would be truncated or hidden"
How do you end up having to much data ? If the word template can "hold" the data in 3 pages, they should fit in 3 PDF pages.
I used to use iTextSharp to create my PDF's, but I also almost always ended up building the PDF document from scratch myself.(not really a <200 line solution) Have you considerate another library, I recently switched to MigraDoc's PDFSharp.Way simpler to use then iText, lotsa examples / docus
Just my two cents
Word documents object model is quite easy to understand. It will either contain series of Paragraphs or Tables. Using the Open XML SDK, you can iterate through each paragraph/table in the word document and retrieve it's content and styles. Then you can generate PDF document on the fly using those retrieved information. This will work under MVC too.
But if your word document contains complex elements, then it will take some more time for you to implement based on this approach. Also, this approach would only work with (Word 2007 and 2010) files.
Also, HTML to PDF options currently available in the ITextSharp library would work with only known set of tags, as far as I know.
Another suggestion is to make use of commercially available .NET components. There are lot of good solution available. For ex: Syncfusion