Javascript API for Office - Inline Image with anchor - ms-word

I'm doing a Word Add-in using a VSTO Web Word template.
This add-in has to add a header and a footer in a word document, after clicking in the add-in button.
In this moment, i already can add a header and a footer in a word document pretty well, but, now, i need to positioning the image absolutely in the left and in the top with 100% width, independently of the document margin.
Somebody cann show or indicate me some way to positioning this image like I need?
**Here follow the code to put the image in the header:
**
var myHeader = mySections.items[0].getHeader("primary");
myHeader.clear();
var img = myHeader.insertInlinePictureFromBase64(imgHeader, Word.InsertLocation.start);
Thanks a lot.

Related

Evopdf truncate contains in pdf

I use evaluation version of evopdf.
Actually, evopdf truncate contains in the render pdf document.
I think that evopdf only render the part of document visible in window browser.
Is your HTML content inside a scrolling area? In this case you have to either create a version of the HTML which displays the entire content inside the scrolling area or set a large custom viewer height in HtmToPdfConverter.HtmlViewerHeight .
For example:
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Set HTML viewer height in pixels to convert the top part of a HTML page
// Leave it not set to convert the entire HTML
htmlToPdfConverter.HtmlViewerHeight = 2000;
You can also find the working example with C# source code at http://www.evopdf.com/demo/ where you can test online your HTML page.

EvoPdf Page backgrounds and Margins

I am converting HTML pages using EvoPdf and would like to add a background image. I am generating documents and would like to add a cover page, I am doing this by prepending the HTML for the cover page then putting a page break directly after.
I am using this demo as a guide http://www.evopdf.com/demo/HTML_to_PDF/PDF_Pages_Background/Add_Elements_in_Background.aspx and have found that I need to remove the page margins for the image to cover the whole page otherwise it sits inside the margins.
If I remove the margins this means the content that flows over pages now starts directly at the top of the page and flows right to the bottom. I can fix this for left and right margins by putting this in the HTML but this does not work for top and bottom margins that flow over pages. (see the generated PDF from the above demo)
Is there a way to set the PDF page background irrespective of the page margins? I have been looking at creating multiple documents with their own configuration and merging the PDF's but I really want to avoid this.
You can set up a header and footer with the heights you wanted for the top and bottom margins, and then choose to not display them on the first page. This should give you the effect you're looking for.
You can find more information about how to do this here: http://www.evopdf.com/demo/HTML_to_PDF/Headers_and_Footers/HTML_in_Header_Footer.aspx

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.

iText Flatten PDF

I have PDF template with a large text-box. Based on the size of the content, the textbox comes-up with a vertical scroll bar. But issue comes up when I flatten the PDF using PDFStamper, the text box does not have the scroll bar and user see only half of the content.
Is there way to allow scroll bar in the text box after flatten the pdf?
Please note that while designing the textbox in the template we have enabled scroll bar option.
No. Flattening a PDF effectively disables interactivity. What your printer kicks out is what you see on screen. One work around is to drop the font size on the field for long items. Another option is to make the PDF read-only instead flattening it. See this post from the office iText mailing list for more.

PDF text position, page left margin

I want to write an application to validate a PDF file. The validation that is required is to verify that all the text and images in the PDF should start after 0.5" margin from left and 0.5" margin from the right. If any of the text is going outside this margin then application should be able to catch this.
I tried to search this into iText but couldn't get anything usefull that can solve my purpose.
Can somebody help me out in writing this code in .net csharp.
Thanks,
Praveen
In addition to R Ubben's answer : reader.getPageSize(pageNumber) is exactly the same as reader.getBoxSize(pageNumber,"media").
That's how it's implemented in iTextSharp. You can see it in source code.
Extract:
public Rectangle GetPageSize(PdfDictionary page) {
PdfArray mediaBox = page.GetAsArray(PdfName.MEDIABOX);
return GetNormalizedRectangle(mediaBox);
}
use SetMarginMirroring(true)
The PDF standard doesn't really have the concept of margins, since a PDF is supposed to be device independent. What it can have is five boxes designed to constrain output: media box, crop box, bleed box, art box, and trim box. Usually the other four boxes are the same size or smaller than the media box.
If a mediabox is present in your pdfs, you could retrieve it and check to see that it is 0.5" smaller on each side than the page. Try comparing the results of reader.getPageSize(pageNumber) and reader.getBoxSize(pageNumber,"media"). Very likely they will be the same.
What you can do is rewrite the pdfs to make sure there are 1/2 inch margins. The easiest way to this is shrink the page.