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.
Related
Prnt screen of the problem
Hi there, I need some advice. As you can see in the image, I have iframe on my website (width 220px) and space within the box is not fully used. I can see margin on the right side (red arrows), where the scroll bar is.
I need to stretch out the content into the full width of the box. (Delete the space between the arrows)
Can I do something about that? Is that a FB bug?
THX for advices.
It looks like the word „labyrinth” would not really fit on the line where your arrows are – if so, then there’s no „bug” at all, it’s just automatic line breaking as is totally common in HTML displaying.
We are now working on upload word document on Google Docs by .NET. We have an template which contains tables, we set border style of tables to none, then all the borders are invisible. But after we uploaded it on Google Docs, the borders appears in black. We tried upload the template to Google Docs manually, the borders appear too. So I think our code is correct, does the Google Docs API allow us to change the style of table border after convert .docx to Google Doc? Or any solution to keep the borders invisible?
I've tried to make the table border to white (the paper color), then the borders is hidden while I upload it to Google Docs without conversion. But while I try to edit it, the table border appears again. I guess that's because Google viewer convert the .docx to GDoc while I try to edit the .docx document.
I've tried to set table border to none in Word, but the borders still appears after conversion. Is this a bug of Google document conversion? It should set the border to zero while the table border was set to none in Word, but it doesn't do that. Is there anybody can help me on this issue? Many thanks.
To answer your first question, there is no way of modifying the document content after uploading. You may, however find better fidelity by converting to HTML or PDF and uploading those formats.
Otherwise, you should raise a bug report on the issue tracker, so that the conversion can be improved.
This is not an answer to your problem, but it's a work around that I'm using currently, by setting the border colour to white it no longer displays the black borders.
This may seem like a stupid question, but I've been looking everywhere to fix this problem and can't seem to find the solution.
So i have a report that is set to a landscape size: 8.5"x11" and i want to set the report to be a legal size: 8.5"x14".
I have gone to page setup and turned on no printer as well as dissociate formatting page size and i have set the page to legal and changed the dimensions to 8.5"x14".
My problem is that the change only shows up in preview mode and i am unable to move the position of the fields in my report in the newly expanded width. So i would like to know if there is a way to change the size of a report in design view or how to position fields outside of the 8.5"x11" dimensions. Or is this not possible?
Any help or suggestions are greatly appreciated.
Thank you.
Quickest answer I can give you:
Load a PDF printer driver. My favorite is CutePDF (except I am ashamed to recommend it at the office... I usually recommend the "MyPrettyPonyPDF").
Once this is loaded, it will look like you have an additional "printer" available. When you select the PDF Driver as printer, you'll have a large selection of add'l page sizes to choose from. The printer I have available has 13 defined paper sizes. With the CutePDF driver, I have 50 defined page sizes. The largest I see is 36in x 108in -- and when you orient that in Landscape, you can camp on it.
Check your margins. The margin area doesn't show up in the Design tab, but would display on the Preview tab. If 'Adjust Automatically' for margins is set, Crystal will just make your margins huge when you dissociate the paper sizes and then increase the horizontal/vertical manually.
Try deselecting 'Adjust Automatically' under the 'Margins' settings, then set 'No Printer', then select a legal paper size. Double check the margins are the size you want and you should be good.
Simplest answer I can think of: try unchecking the No Printer option, set the layout and paper size to Landscape and Legal, and then set the No Printer option on again.
I'm using a barcode font (IDAutomationMC39H) in an SSRS 2005 report I'm developing, and while it renders fine in the preview in BIDS, if I export the results to PDF, print the results, or do any of the above (including preview) in Report Manager, the barcode font is extending off the top of the textbox. The barcode itself is nearly 20px tall, even at only a 12pt size. I've tried changing the CanGrow value for the textbox, but it seems that even with that set off the barcode isn't pushing the bottom edge of the textbox downwards, it's simply extending over the top of the box. I've also tried resizing the textbox to allow it to contain the entire height of the font, but even with the VerticalAlign set to Bottom the barcode still sticks to the top of the textbox and overflows out the top.
See screenshot here:
http://imgur.com/JDC4Z.png
Does anyone know how to force the font to be bound by the top of the box, instead of overlapping it?
I tried with no real success to get font-based barcoding to work. Ended up getting the boss to pay for NeoDynamic BarCode Professional which works great and has a lot more flexibility than fonts.
I'm using JasperReports to generate a word (docx) document but I have a problem when I want to try to print the doc. The exporter messes up the margins of the page. Does anyone know how to prevent that from happening.
I know how to set the margin in iReport, but it just makes the data generate further from the page borders, but the margins in word which can be adjusted at the top of the page is laying right at the edge.
Has anyone had this problem?
Are you able to specify the page size? Its possible that using this in combination with the margin settings will help the export problem.
If you are not too heavily invested in your Jasper solution, Docmosis and JODReports let you layout the document visually using Word or Writer then render the report in various formats. This may save you time in the long run, but all reporting systems have quirks. Hope you find a solution, especially when your output is not PDF.