How to generate a PDF? [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 12 months ago.
Improve this question
For my Microsoft Surface application I'd like to generate a PDF including some images. How should I start to do that?
EDIT:
I don't want to convert a text or html document, but I want to create a pdf from scratch.

PDFsharp is nice, free, relatively easy to use and compatible with WPF

Two basic options:
use a PDF specific library, like iText in #Kent's answer
install a PDF printer and use any reporting/printing code.
Option 1) will be the most flexible and efficient way.
Option 2) is interesting when you already have code that prints what you want. It is a bit of a hassle to manage the output-file etc. It's very easy to support XPS as well.

Docotic.Pdf library may be used to create PDF files from scratch and many other purposes.
Please take a look at samples for various PDF tasks.
The library has no external dependencies and is written in C#. There are several different license types available.
Disclaimer: I work for Bit Miracle.

For me the easiest way is to use Reporting Services.
http://www.microsoft.com/sqlserver/2008/en/us/reporting.aspx

You should also have a look at Fop/PdfBox for PDF creation/editing.

you need to use one of PDF generation libraries for C#. I tried to use iText , IronPDF and PDFFlow. All of them create PDF documents from scratch.
But PDFFlow was better for my needs, because it has easy fluent syntax and more functionality (I needed repeating headers, automatic page creation, automatic page numeration and multi-page spread table). They also have examples of business documents here: Examples, I haven't seen that much from other PDF generating libraries. There are also how-to-build articles for each sample, that helped me much.
This is how to create simple PDF file:
var DocumentBuilder.New()
.AddSection()
.AddParagraphToSection("Hello world!")
.AddImage("image.png").SetWidth(250)
.ToSection()
.AddLine(300, Color.Red)
.ToDocument()
.Build("Result.PDF");
Hope, this will help you to start.

Related

how to printing/create pdf files from an asp.net page? [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
export to pdf in asp.net 3.5
What is a tools can I use to print asp.net pages ?
Is there any good software to create pdf files for asp.net?
is there any free software that takes care of this?
I like Expert PDF (http://www.html-to-pdf.net/). It converts regular HTML and CSS to a PDF format and opens in the associated reader on your local machine. Much easier than some of the other generators out there such as iText Sharp which require a lot of time learning the API. Unfortunately its a paid app, so if your company isn't willing to chip in for the license you might want to look at one of the free libraries.
SQL Server Reporting Services (SSRS) offers some good PDF generating functionality, though depending on your exact needs it may be too much. The best way to find out is to take a look at this page and see what you think: http://www.microsoft.com/sqlserver/en/us/solutions-technologies/business-intelligence/reporting-services.aspx
If you don't want to use the Report Viewer control, there is a blog post I've seen that details how you can avoid creating one: http://geekswithblogs.net/bsherwin/archive/2007/04/29/112094.aspx (It's in VB but could easily be converted to C#).
iTextsharp is widely used and of-course it is free.
Just download the DLL

How to convert PDF to WORD in c# [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Does the anyone know a .Net component to convert PDF to Word or RTF programatically? I don't want to use OCR and Adobe dependent solutions.
I tried several libraries:
PDF Focus .NET: https://sautinsoft.com/products/pdf-focus/index.php
Aspose.PDF: https://products.aspose.com/pdf/net
Gembox: https://www.gemboxsoftware.com/document
Spire.PDF: https://www.e-iceblue.com/Introduce/pdf-for-net-introduce.html
considered also using Word via COM automation to open and save to pdf programmatically.
Among all of them I liked PDF Focus .NET best of all, and I will explain why:
They try to keep the structure of the document EDITABLE, so that
when I will try to continue editing the text, the paragraph will be
smoothly prolonged. Other libraries are trying to do a
"minimalistic" approach by inserting absolute positioned shapes, so
that if you continue editing the text, it will overlap with the next
piece of text.
They do all their best to recognize tables, so
that tables in the output document will be REAL TABLES, but not a
collection of shapes and texts with absolute positioning (as
produced by other libraries).
A customer of ours is evaluating now different libraries, and I will recommend PDF Focus .NET first of all.
P.S. I AM NOT INVOLVED IN ANY KIND OF RELATIONSHIP WITH THIS SOFTWARE PRODUCER. As a former .NET developer I simply see a high quality components which really work fine.
Use PDF Focus.
Nice and easy.
EDIT: And also
How to convert DOC into other formats using C#
http://dotnetf1.blogspot.com/2008/07/convert-word-doc-into-pdf-using-c-code.html
You need something like GemBox.Document. It's a simple .NET component that enables you to manipulate and convert all kinds of document files.
You should have read this: C# and PDF. There are methods to convert, like beforementioned PDF Focus but be warned: it is buggy, and crashy process. PDF is not intended to be PC-readable.

Dynamic PDF generation from template [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I've a requirement to be able to generate PDF's within our (ASP.net) application. We need to meet the following requirements:
The text will be largely dynamic and must be added programatically.
Ideally we'd like to base these generated documents off PDF templates provided by our designers.
Some of the sections/pages may or may not be visible depending on certain conditions - ideally we'd like the content to 'flow' upwards to fill the space when something is removed.
Some of the pages may need to repeat, depending on certain conditions.
Some of the PDF templates will be out of our control (we're populating application forms supplied by third parties), so being able to read in a blank PDF and populate it would be good.
I've looked at iTextSharp and it seems to do most of these things (i.e. I can take a PDF, edit it to include form fields where we need to fill data and then use iTextSharp to read that in as a template and populate the data), however, I'm not sure how then to go about potentially hiding whole sections and/or repeating pages.
What I'm looking for here is a little advice from anybody who's been in a similar situation.
Small update here, we went with iTextSharp - it's a powerful tool, but does take a bit of learning, however it's quick, light, and does precisely what we want it to do.
However...
I would point out that the latest version is no longer really free (as in beer) - the license does not permit commercial usage. As a result, we now have a licensed version, but it's not shockingly cheap (and they don't publish a price list).
I would use iTextSharp. I create all kinds of PDF files based on different templates and iText has worked the best for me. It is a very powerful control and can manipulate pdf files in just about any way.
I'm not sure that iText can handle your third requirement. I know that it can create a pdf from a html file. Maybe use what Tomas posted and create the pdf with iText.
There are various commercial components to do this. Look at: PDFLib (http://www.pdflib.com/), Tall Components (http://www.tallcomponents.com/) etc
I have use products from Tall components and can recommend them.
Some others are a lot more expensive.
ITextSharp as you've mentioned is quite good and can be used to add/remove external pages, in this can you could hide full pages by ommiting them, or replacing them with placeholder pages. iText can use existing PDF files or create blank pages.
From my personal experience, I have just dropped in images and text onto existing pages and added pages generated by a reporting tool when tabular data is required.
HTH
Why need the template files in the pdf format? With the dynamic that you want it is a bad format for reporting template. Use a reporting software that also output as pdf. Your designers can create the templates very easy with a GUI. You will find many reporting solutions here on stackoverflow.
We've used http://www.dynamicpdf.com/, for projects like this and have been pleased with the outcome. They have a PDF WYSIWYG designer tool that you can use to build out the layout template of your PDF, along with the tool to merge the template with your data based on field to column mapping. This saves hours of hand coding each element of a given PDF. It supports page headers and footers and deals with the complexities of page breaks.
I would consider using creating HTML files from templates and turn them into PDF with Prince. Prince is very flexible and crating HTML files from templates is much easier then creating PDF files directly.

How should I document my C# code? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am building the documentation for our C# API containing:
A general overview and description of the current state as a doc/pdf file.
A class library API in a .chm file using Sandcastle.
Questions:
Should I merge these two into the same .chm file? What is a good way to merge them?
I need to exclude certain classes/packages. How can I specify that in SandCastle?
It generates documentation for the VB code and the Visual C++ code. How can I change this? Or should I leave it, knowing that I am only using safe code?
Where can I find HTML Help 2.x Viewer Path on my system?
Edit:
The comments I make above methods, fields and classes are not generated in the documentation.
What should I do?
I recommend that you use Sandcastle Help File Builder from Codeplex. You can easily include and exclude namespaces, but I am unsure how to go about excluding a single class. You can set the option to only generate documentation for public/protected classes, but I do not know if that will fit your scenario.
You can also target a specific language in SHFB, as to your second question.
Additionally, you can use MAML within SHFB for conceptual documentation, such as you mention as being in the doc/pdf file. You should be able to use Doc2Maml for to migrate your existing documentation. Doc2Maml is a part of DocProject, but it appears that you might be able to run it standalone.
Edit in response to comment:
Directions are for SHFB 1.8.0.1. I do not remember the exact way to do it in 1.7, but I believe it is similar:
Under "Comments" group in the Project Properties tab, click the ellipsis to the right of "NamespaceSummaries".
In the checkbox list in the top left, uncheck any namespace you want to exclude.
This is also the screen where you put namespace summaries in.
In addition to Sand Castle as mentioned above, I would also recommend looking at FxCop and StyleCop to help make sure your code and documentation is up to CLS Compliance standards.
Sandcastle Help File Builder (SHFB) itself has a .chm file where you can find the answers to questions like "how can I exclude certain namespaces or classes from the generated doc?"
You may think I know the answer and I am being snarky by not telling you. Not true. But I was skimming the doc last night and saw an entry on this very topic.
I don't know why you wouldn't just leave in the VB and C++ stuff; there may in the future be someone who uses a language that is (shockingly) not C# with your library. The language is normally settable by the help viewer, so C# devs can ignore the VB syntax.
As for merging, SHFB has a mechanism to add in arbitrary HTML in an arbitrary hierarchy. In the GUI it is here:
http://www.freeimagehosting.net/uploads/7de19ea568.jpg
Using this, you could convert the PDF/DOC to HTML and then just embed it in the .chm.

Converting PDF into workable text using C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is there a library that has a class to extract the text from a pdf file in c#.net? I've tried a few but documentation is terrible, so I haven't been able to get it off the ground. Also if it provides a class to extract images that would be a plus. Any suggestions? Thx in advance.
Also I need to be able to implement it into an existing application.
Have you tried PDFKit.NET? It has reasonable docs and some good examples. It is designed for a server environment, so it is a little expensive.
EDIT Here is an open source library on SourceForge called iTextSharp. It is free for open source projects. I haven't used it, but it looks promising. Here is a tutorial for it that has lots of code examples.
There are a couple of ways you can go here -- a lot of it will depend on whether you want to retain the formattting (i.e., paragraphs and other layout elements) of the original PDF.
If you're considering commercial solutions, we do offer two products that might meet your requirements. One is EasyPDF SDK which has single shot ExtractText() and ExtractText2() calls that pull text out of your PDFs as plain text.
Note that the output from these calls is pretty simplistic and you will lose a lot of the original layout elements. They're nice for simple text extraction but might not be great if your PDF contains tabular data.
If you're dealing with tables, a nicer alternative could be to pull it out as rich text instead. We a have a tool called EasyConverter SDK geared for business documents which does just that using a single function call.
With EasyConverter SDK, the layout of your original PDF will be retained.
Both support C# so feel free to check out the eval versions at www.pdfonline.com if you're interested. I do work for the vendor so do take this suggestion as kind of a mother loving her own child :-) I've been browsing stackoverflow.com for code snippets for a long time, but have only recently started posting, so if you have any questions with either API just let me know and I can help. Cheers!
Docotic.Pdf library can extract text and images from PDF files.
You can extract text from whole document of from some pages only. The library can extract plain text and also text chunks with coordinates.
You can extracted images from PDFs (as JPEG and TIFF files).
Here is a couple of samples for your task:
Extract text from PDFs
Extract images from a PDF
Disclaimer: I work for Bit Miracle, vendor of the library.
we've used snowbound software at work for image conversion. it apparently supports text extraction too. however, it's not free.

Categories