i want to generate a PDF file with tables, etc in it. so what i did is using a PDF converter (EVO PDF). that works great, except that the PDF has a white background-color.
What I wanted to do is to overlay a PDF document (because our company paperwork) and put the HTML above it. But because the HTML has a white background, I can't get it work.
I'm now using EVOPDF to generate the HTML and Syncfusion to overlay the company paperwork..
there must be an easier way
Convert the company stationary into a flat image, and then set that as the background to the page in CSS. As long as care is taken to measure and set sizing right, that should work for you.
Related
I am working on PDF generation dynamically, I have pdf template and I am creating the similar dynamically using ITextSharp,I am creating the pdf and returning base64 string to mobile app,which then convert the base64 to pdf.
The template is like this
See Image
The footer's disclaimer and page number will appear in all pages of PDF file, and page number is dynamic too.
I have created it successfully, it is not exactly same as of the template, Is there any other way to generate PDF without ITextsharp?
Can I use crystal report or RDLC for this or any other,that fulfils my requirements.(dynamic page number,disclaimer and page in all pages and base64 string).
The content of center table can be multiple ,so the pdf can be of more then one pages.
The difference of generated pdf is that center's table width is going out,it should align with top two tables(I have 100% for three tables),there are other issues as well.
Generating footer and header with ItextSharp is not native,
so you need to code it manually.
Here, is a good Example:
https://www.codeproject.com/Tips/573907/Generating-PDF-using-ItextSharp-with-Footer-in-Csh
I would like to put the page number of each page of a pdf file generated by HTML Renderer for PDF using PDFSharp which is an amazing plugin using PDFSharp and giving the possibility to render a pdf file from html string, moreover it supports CSS 2 to style the generated pdf.
Thanks to this pull request, which is available in the beta version, it is possible to have a proper paging with elements not being cut when they are taller than the page format.
I tried using this in the css:
.footer:after
{
counter-increment: page;
content: counter(page);
}
with no success (the footer being in a fixed position). I would like to know if someone achieved a proper page count with this plugin or if someone knew another way.
I already tried to simulate the pages count the document would take but the styling in browser is quite different from the generated pdf file (lines height, margins management, etc).
I was wondering whether it would at all be possible to have our creative department design a nice-looking PDF template for our client, e.g. a fancy letterhead, then supply it to me so I could inject various types of content into the body using PDFSharp or MigraDoc.
Currently we generate the header and footer content as part of the rendering process, and it works very well, but as you can imagine, any non-trivial layout and styling is pretty complicated to pull off in what is essentially a 2D graphics environment.
So the thought arose as to whether one of these tools would be able to take a pre-existing PDF, give me access to various objects, and allow me to e.g. replace certain text placeholders or manipulate the PDF "DOM" in a more intelligent fashion.
Something similar to working with Spreadsheets (binary and XML versions) or OpenXML, etc.
What we do: take an existing PDF page, draw it at the bottom (Z axis) of a new PDF page, and then use MigraDoc to add other contents to the page.
PDFsharp can also be used to draw on top.
The template PDF pages are used like letter heads with the corporate design of a customer and the final document will have as many pages as needed.
I'm using PDFsharp to use one PDF as a watermark in another PDF. This is mostly working. The watermark PDF is placed "behind" the content of each page in the target PDF. However, the watermark content needs to be partially transparent (or screened) in order for the resulting PDF to be legible.
How do I go about using PDFsharp to globally adjust the transparency of a PDF?
You can check the documentation here for details on adding a watermark onto a pdf using PdfSharp. From the link:
Note: Technically the watermarks in this sample are simple graphical output. They have nothing to do with the Watermark Annotations introduced in PDF 1.5.
Here is another link which claims to have 3 different methods of applying watermarks - have you tried any of these? It looks like you may need to use MigraDocs as well as PdfSharp to achieve this.
You didn't specify what your watermark looks like - does it need to support any custom pdf you can create, or is it just some text going across the page? The latter definitely looks possible using the links I posted.
If you want to create custom objects, maybe you can check this link (Xforms), where it talks about drawing transparent custom shapes:
This sample shows how to create an XForm object from scratch. You can think of such an object as a template, that, once created, can be drawn frequently anywhere in your PDF document.
I think that perhaps instead of having 2 PDFs (1 main and 1 watermark) it is probably going to be easier to have 1 pdf and then create the watermark either with the built-in methods or by creating an XForm object and sticking it on the pdf.
I'm looking for a way to get the PDF page color information using ITextSharp. I need to know if the page is Black and White or color
any help would be great.
To the best of my knowledge PDFs don't have a "page color" or a "background color". The fact that when you open a PDF in Acrobat and you see a white canvas is actually an implementation detail, albeit one that everyone does. (Actually this can be changed by turning on some accessibility options in preferences.)
Instead, any PDF that looks like it has a different background color probably has an image or a full color shape stretched across it. Using iTextSharp you could probably enumerate all of the images and shapes and look for any that are the same size or larger than the actual page, but I'm not sure how reliable that would be.
The only way that I could think that would actually work would be to convert the PDF to an image and sample one or more of the corners where (hopefully) no one has any content. Think link shows how to convert a PDF to JPG.