Is there a way to set different headers on different pages in a pdf generated flying saucer and iText? - itext

My requirement is like this, I would like to have headers from page 2 of the pdf but not in page 1. Is it possible to do that using css counter and #page?

please check my answer at iText Flying Saucer pdf headers and ignoring html, you can customize the header/footer content based on the page number, i know this is not a answer using flying-saucer. but it works for me.

Related

FPDF Page wise style and size

I want to generate PDF using FPDF library, but I am facing one issue that I can only provide fixed style and size for all pages. But my requirement is that I should provide dynamic style and size in FPDF object.
What can I try to achieve this?
Use TCPDF
You can find many examples with more features than FPDF. You can use methods to publish some XHTML + CSS code, Javascript and Forms in a PDF format.
Some other features:
custom page formats, custom margins and units of measure;
automatic page header and footer management;
PDF annotations, including links, text and file attachments;
text rendering modes (fill, stroke and clipping);
multiple columns mode;
no-write page regions;
text stretching and spacing (tracking/kerning);
automatic page break, line break and text alignments including justification;
automatic page numbering and page groups;
move and delete pages;

single layer/flatten pdf file ITEXTSHARP

My Desktop App is creating a single page pdf with itextsharp library.There are 40 Passport size photos with names under it on a single page.
I need to flatten this pdf page (with 40 photos) as one Image while creating the pdf,currently there are 40 individual photos on the pdf page.I presume it would create around 80 layers by default which would take a very high time on ripping this file for printing on a press.
I dont want to make all the 40 images as one jpeg externally using GDI+ and then lay it in pdf.
I have seen many options using stamper and reading the created pdf file to flatten.Is there a way while creating the pdf i can create a flattened file.
Your understanding of flattening a PDF is completely wrong. The concept of flattening a PDF means: removing all interactivity. For instance: you have a PDF file with form fields. The content of these form fields can be changed in Adobe Reader. When you flatten such a form, you take away the form fields and replace the field content by actual content of the page. The result is a flat PDF in the sense that people can no longer change the content of the fields.
You presume that having multiple pictures on a single page in a PDF means that there are multiple layers in that PDF. Your understanding of layers in a PDF is completely wrong. Layers is a word that is used in many different contexts. For instance, when working with optional content groups (OCG), people often refer to layers.
The concept of layers as you may know it from Photoshop doesn't really exist in PDF. Content is added in a stream. Whatever content is added first, can be covered by content that comes after. You want to pro-process the content by removing all the content that isn't visible in the hope that the PDF will be printed faster. You want to achieve that by replacing many different image objects by one image.
Your assumption that this can be done with iText is wrong. iText doesn't convert PDF to an image. This is outside the scope of what iText is written for.
If you want to add X images as 1 single image using iText, then you have to process the X images into 1 single image before you add the images to the PDF. You need image manipulation software, because iText won't do what you're asking for.

i want to change the pdf look into html look in html2pdf

I want to display HTML design page when converting the page in PDF format.
Is this possible to do? If yes, how?
Currently my HTML page is getting distorted when converting into PDF format while using html2pdf. My header is not as per I designed it.
How to set the value of header as per css?
The script i am using is PHP.
Basically i want to know can i replace my css with the html2pdf css creation?If yes , how and what is the process/procedure?
Please Guide.
Thanks
I resolved the query on my own.
I figured it out that PDF only recognises table and not div.
So when you write an html/ design it , write in table format not div. It does not recognise float.
Hence the above question i mark as resolved.
Thanks

iText - how to move down the current contents in a pdf

I have a requirement to add few lines at the top of an existing PDF.
I have done this using a PdfReader and a PdfStamper.
In order to have more space in the page header area, i need to move down the current contents by 1 or 2 lines.
Below is from the forum. but it doesn't solve the issue.
How to insert content in the middle of a page in a PDF using IText
Any suggestions?
-i can not upload the pdf or the image of the pdf because am a new user
Do I interpret your question correctly if I assume that you really want to move down everything on the page and add some lines above?
You can do that by changing the media box (and crop box and what other boxes might be explicitly defined for your page) and then add the few lines on top the same way you already do it now.
You can access those boxes in the respective page dictionary which you can retrieve via the PdfReader. Look up the PDF specification for details on those boxes.
Or do I interpret you incorrectly and you only want to move down some text while keeping existing headers and footers in place? In that case Alexis' answer to the other question you refer to still holds.

iphone xml parses text but no images or paragraph spacing

i am trying to parse an xml blog found here: http://www.feed43.com/1515171705611023.xml
it has pictures within the text. I am able to parse the headers, the content and the link of the individual posts.
I, however, cannot get it to parse the paragraph spacing links within the text or images. all three of these are EXTREMELY important.
I am using this: http://github.com/mwaterfall/MWFeedParser with very few changes. most them having to do with appearances and the actual feed loaded as well as using a scroll view for the detail view instead of the table view shown.
note: it didnt load these things before I made changes either.
Can anyone help me?
What you are looking for is an html renderer, not an xml parser. On iPhone, that is WebKit, which can be used through UIWebView.
Extract the html embedded in the rss formatted xml and place it in a UIWebView using loadHTMLString. Usually, the baseURL will be the same as the rss source, without the filename.