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.
Related
I am trying to get the position of Paragraph in pdf file.
Right now I get it at pdf generation time, by getting the current position before/after adding the paragraph to the document. And then I use that position to edit.
Is there easy way to find location of paragraphs, after the pdf is generated?
Should I stop using paragraphs and position, and switch to template with AcroForms for filling in data programatically?
Everything works, but It feels like ive selected the wrong approach.
Thank you in advance.
I'm making a Crystal Reports template. The template has some text in the header and then it has an image. If the text has a few lines, the image is normal and allowed in the first page, but if the text has many lines the image will be cut off in the first page and second page. Could it have ways to prevent the image from being cut off to the second page, such as auto-rescaling the image size?
I tried can grow and other settings in Crystal Reports 10, but it didn't work.
Report Design Picture
Make sure Keep Object Together in the properties of the image is checked. This will prevent CR to split your image across pages.
Best option in this case would be Create another section and place the image in that section instead of text and image in same section, This will force the image to go to another page if it doens't fit in first page.
For E.g, if data in report header, create one more section Report Header a and place text in that section and Report Header b and place image in this section
This question is related (follows from) this question.
I am dynamically generating Word documents from data in a database. In the generation I need to have the First Page of a section have a different top margin than the other pages in the section. For reason that would take too long to explain properly, I can't just create a new section with a different top margin.
To get around my problem I thought I would create a shape (rectangle) with no border and no fill (invisible) that was the height I wanted my margin to be. I would then place it absolutely at (0,0). I would also make it wrapTopAndBottom so that it pushed the text in the body of the page down. This is working... except for one small problem.
As you can see there is a large, blank area immediately after my shape. There are actual blank lines there. You can see the lines better in this image where I've put text in those lines.
When I look at the header xml file in the Word archive, those lines don't exist. I'm not sure where they are coming from or how to get rid of them. I can manually remove them using Word but every time I regenerate the file they get put back in there. If someone knows why this is happening and / or how to get around it, I'd appreciate the help.
Thanks.
I finally figured this out.
Sorry I couldn't post code up here. First, I'm not using C#, I'm using PHP. Second, the amount of code I'd have to post to show how the header is getting created is prohibitive on a forum like this. Third, I'm not really allowed to post the company's code up here.
In any case, the problem was simple once I saw it. We are placing multiple absolutely positioned objects (shapes, text, images, whatnot) inside the header. In the class that creates these objects each one was being placed inside a <w:p> element. For example, if there were 3 such objects, the XML looked like this.
<hdr>
<p>Some Object</p>
<p>Some Object</p>
<p>Some Object</p>
</hdr>
The problem is that even though each of the objects inside the <p> are absolutely positioned, the <p> element itself creates a line and space for that line. So the header above would have 3 blank lines in it. This became an issue if the header had 6 or 7 objects because the blank lines would push the header's margin down and force the page's content down as well. This was undesired behavior.
The solution is simple. All the absolutely positioned objects can be placed in the same <p> element. This leaves only 1 blank line in the header no matter how many objects you have.
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 am trying to create PowerPoint slides using MATLAB. It seems like it is basically the same as using VBA to create PowerPoint slides, except with slightly different syntax. The function and variable names are all the same.
Anyway....I can add a picture to a slide. I can also add a specific layout, which creates some placeholders. But I can't figure out how to add a picture and link it to a specific placeholder. I want to import 4 pictures into PowerPoint and apply the "4 Object" layout. I could obviously manually place the pictures in the same locations that the layout would choose. But I would like to link them to the placeholders in case I ever need to change the layout.
Does anyone know how to add a picture and link it to a placeholder?
Thanks,
Andrew
There are a few MATLAB code submissions on the MathWorks File Exchange that may help you move figures from MATLAB into PowerPoint with specific layouts:
saveppt2 by Jedediah Frey.
subplotPPT by Mark Hoyle.
saveppt by Mark Brown.
The last submission has inspired the first 2, along with a few others that may also be of help to you (links are provided in the Acknowledgements section of the last submission).
Hope this helps!