Change the PDF content and custom annotations color for existing PDF using iText - pdf

The problem now we are facing is- We are loading some color Eng. graphics and doing annotation.
All looks fine and working well and good. Now, at the end of job completion we need to print the PDF file with annotation in black and white.
Here, since the PDF is colored one, we are not able to see print clearly.
Is there any option to make all content in PDF to black color later? So that print will be very clear.
Like this problem.

Related

Image disappears in Microsoft Print to Pdf

I've developed a popup window and I use the body onload='window.print()' function to print the document, and then I choose the printer Microsoft Print to Pdf, which produces a PDF. However, the main logo I have at the top of the document goes missing. I have another website which uses the same approach with a different logo and that works fine.
I have attached the problematic logo below:
The image is a PNG. I originally used a transparent background, but I thought that maybe the PDF converter thinks the ratio of dark to light is too high and hides it, so I changed the background to white to increase the lightness ratio, but to no avail.
Is there something else I can do to force the logo to appear without the user having to tweak print configurations?

How do I convert RMarkdown ioslides presentations to 2-up PDFs programmatically?

I use rmarkdown to generate ioslides HTML presentations, using custom css. This bit is great and I love it. My question is about generating 'notes' versions of presentations.
The only way I've seen to get 2up PDF A4 notes from these slides is to print out of Safari, by clicking Print..., then landscape, then layout 2pages, then border = hairline, then save as. then find the right folder etc. However, it gets the formatting and fonts right, and Webkit renders things that Chrome or other solutions will not.
This is fine for one copy. But I am now regularly updating between 9 and 30 separate presentations at a time and all the clicking sends me nuts, especially when I need to update just a small issue, and I want to check all files have been regenerated as PDF.
Is there any solution to rapidly and programmatically generate a 2-up PDF version of a set of RMarkdown ioslides presentation slides? Alternatively good workarounds would be appreciated.
You can use the webshot package to capture the output of HTML graphics and save this to a graphical device (PDF, PNG, PDF). You can read about it here.
Assuming you have a file called testPres.Rmd stored in the same working directory of the following script, it will convert the report to a PDF:
# Setup
install.packages("webshot")
webshot::install_phantomjs()
library(webshot)
library(rmarkdown)
rmdshot("testPres.Rmd", "document.pdf")
Having created a PDF of the slides, we now need to convert them into a two-page PDF. There is probably a more elegant way of doing this but you could use a very basic R Markdown document. This following script will load all the slides into a two-page layout:
---
output: pdf_document
header-includes:
- \usepackage{pdfpages}
papersize: a4paper
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
\includepdf[pages={1-},scale=0.75, nup=1x2]{document.pdf}
I am not sure this meets your exact requires perfectly, but hopefully is enough to set you in the right direction.
You can check the documentation of the pdfpages LaTeX page to customise how the PDFs of the slide appear in the document (add margins, borders etc.)

iText: why would adding an image cause text to appear fuzzy in PDF?

I'm using iText with Java to create a PDF file. I'm trying to place a paragraph on left, and float an image on right (e.g. next to each other). Using the following code does insert the image, but it also makes the text fuzzy on the entire page (other pages are fine).
// add image
Image img = Image.getInstance(imgPath);
img.setAlignment(Image.RIGHT | Image.TEXTWRAP);
img.scaleToFit(1000, 72f); // 1" height
//img.setSpacingBefore(0f); // does not have any effect
document.add(img);
// add text
Paragraph par = new Paragraph("some text here", styleBody);
par.setSpacingBefore(20f);
document.add(par);
If I remove the image portion of the code, the text looks clean. This is my first attempt at adding an image next to text. Must be doing something obviously wrong. Any idea what could cause this?
I was able to solve this problem. The code above is perfectly fine. The problem was I was using a PNG image with transparency. When I removed the transparency (by re-exporting the image from Illustrator with transparency turned off), I was able to create PDFs with clear text.
I think the transparency forces the PDF page to be written in CMYK color scheme rather than RGB, which perhaps causes this issue.
Hope this helps someone else. I searched everywhere but couldn't find any leads talking about fuzzy text in iText.

False dots around circles in pdf export of libreoffice draw

When i draw a small circle in LibreOffice draw and export it to pdf i get some extra dots around the circles. Especially in the upper left and lower right outer corner of the circle.
See example PDF here: https://dl.dropbox.com/u/233922/example-dots-circle.pdf
or as a Screenshot here:
You have any idea how i can get rid of this?
It is old bug and has not been fixed yet. I can reproduce it under Linux and Windows. My version: LibreOffice 4.1.0.
Create new file in LO Impress or LO Draw.
Draw ellipse (or rounded rectangle, or smile etc.).
Set line width e.g. 5mm (for better view).
Export as PDF.
I propose two workaround:
Export to MS PowerPoint and export in it :/
Print to PDF (using e.g. cups-pdf).
ad 1) You must have MS PP and you graphics may look bad.
ad 2) I use cups-pdf and PDF look very well, but:
Text is stored as bitmap graphics (small rectangles)! You can not extract text without using OCR.
You must use paper format from list (A4, A0, Letter etc.). If you use unstandardised paper format you must use bigger format and you get white bars on PDF. However you can use pdfcrop and remove white bars.
PDF is always orienter horizontally. If you print as vertically you can rotate pdf using pdf270 command line tool.
In Adobe Reader (version 11 at least) -> Go to "Preferences" => "Page Display" => uncheck "Enhance thin lines"
Libre Office seems to add dots of 0 size and practically no visibility. When "Enhance thin lines" is checked, Adobe Reader will make these dots visible.
Best wishes,
Patrick
Similar to the https://stackoverflow.com/users/1797782/dzwiedziu-nkg 's answer, I need a multi-step process to fix this issue.
Steps:
Open the file in a pdf viewer (Document Viewer for me in Ubuntu.)
Print the pdf to a file (also a pdf) from the viewer. I assume this also uses cups-pdf, as it modifies the image size. (I don't mind, because I use the next step to eliminate all margins anyways.)
Use pdfcrop to remove all the extra space around the actual content's bounding box. If you just give pdfcrop one argument, it doesn't overwrite the old file, so use the same argument twice:
$ pdfcrop monkey.pdf monkey.pdf
Another "workaround" that worked for me:
Go without outline. You can set the line style in Draw to "none" and just work with flat solid objects.
PS: I see these dots also in Draw, not just in the exported pdf.
A simple workaround is to "patch" the dot in Libreoffice Draw using a white object -- say, a square with white area and white outline. Note that you can not see the dot in Draw. So you first generate the pdf with the orginal drawing, see where the dot appears in the pdf, go back to Draw, and a add a white patch where it is required.
Searching for a workaround myself, I've found this awk script called odg2epsfix that will fix the exported EPS to not contain those ghost dots anymore.
I stumbled upon it in this launchpad bug entry.
Fixed in LibreOffice pre-export.
Steps:
Right click on the circle in LibreOffice and select "Line"
On the "Line" page, set "Corner Style" to "-none-"
Save document and Export as PDF.
The dot is gone without removing line enhance. Mine still shows in preview but doesn't print.
The bug is still present in LO 6.0. But if you set "Cap style" to "flat" in the "Line" tab of the "Graphic Styles", the dots disappear from the screen and from the exported pdf.

image colors in pdf files in vb.net

I'm creating a program to generate PDF files in VB.Net.
Everything is working fine except that the image is being displayed with a blue background while the image provided doesn't have any.
Following are the lines of code being used:
sColor = IIf(mvarEncodeASCII85, ToASCII85(ImgColor),
(System.Text.Encoding.GetEncoding(1252).GetString(ImgColor)))
What am I doing wrong?
There is not alot of details, but my first thougt is that it is .png-files or .gif-files.
Am I correct? In that case it may be an issue with adobe acrobat handling the transparent backgrounds.
As I said it's hard to say exactly without any further details.