Prevent chrome to re size PDF for printing - c#

I am generating PDF file using migradoc library in a .NET webpage. PDF gets generated as expected. When I save the PDF from chrome to file system and print it using "Actual size" option, the resulting print is same as PDF preview.
Problem is when I directly print it from chrome, apparently it gets resized, therefore the output PDF doesn't look Identical as preview (Some table borders gets disappeared). Any helping idea is appreciated.

You're essentially printing from two different sources. When you print the PDF document (from your file system) as "Actual Size," that size is going to be dictated by the bounding box/page dimensions specified in the document at the time that it was saved to a file.
When you print your document image directly from Chrome, it's Chrome's print options and display options that will be in effect; e.g. Portrait vs. Landscape, to cite one obvious choice you can make. The Chrome print output will be determined by the settings in effect at the time the print job is generated.

Related

Why PDF exported from Report Viewer opens in different zoom size in Adobe Reader

I have 16 Reports in my current application. when I export the reports
through Export drop down menu to PDF file, it saves to my local disk.
But when I open the PDF through Adobe Acrobat Reader it opens it with
a different zoom size for each report. Why I am getting this kind of
behavior.
Can I set a default zoom size for all the generated PDF
dynamically ??
You can't change the zoom level of generated PDFs in Reporting Services.
The zoom is managed by the viewer application, which is Adobe Acrobat Reader in your case.
There is no details about it in the documentation because this feature does not exist, but here is a link to a question on MSDN forums where somebody from Microsoft confirms that there are no ways of doing it:
export SSRS report to pdf / controlling zoom
right click on report and
1) go to report properties
after that you set height and width as per your requirement

Force to print in legal paper

I'm using iTextSharp to generate PDF documents in my asp.net application. That works great. The only issue I have is when I generate a PDF document with size of a legal paper and print it, the printer use the default paper which is letter size. I have to change the printing options manually in order to print it in legal paper. Is there a way I can specify in which paper size I want the document to print programmatically so that I won't have to do it manually?
I'm using this line of code to specify the page size in iTextSharp:
Document doc = new Document(PageSize.LEGAL.Rotate());
You cannot control the client printer. That would be a huge security problem in the PDF format. It is up to that computer's settings.
Ok, I found the answer in another post: Propagate the orientation setup at iTextSharp.text.Document creation to the Print dialog.
The key is to set the viewer preference Choose paper source by PDF page size to true.
writer.AddViewerPreference(PdfName.PICKTRAYBYPDFSIZE, PdfBoolean.PDFTRUE);

Image Quirk with PDF generated by WKHtmlToPDF

Using WKHtmlToPDF to generate PDFs for my company's web-based mapping service.
Essentially, I take a template HTML file, inject an image into a div, save the HTML to disk and use WKHtmlToPDF to render to PDF.
Now, on most templates it works a treat. On one particular one though, where the image should be (int the pdf) is a grey area. HOWEVER, if I right click on the grey area, and select "Save Image As...", the saved image is correct.
Linked are the created PDF and the HTML on which it is based. Help required most urgently, and hints appreciated.
Zip File Containing HTML and PDF
I was having an issue where a particular image was not being printed to the PDF. Other images on the same page were. The src of the missing image is from a CDN, but had no extension, i.e. src="\\path/to/image?param". Using the aforementioned -n switch (disable Javascript), the image shows up in the resulting PDF. Thanks Jordaan.
Don't know WHY this worked, but adding the "--disable-smart-shrinking" option, and/or removing the "-n"(Disable Javascript) option, fixed it.

Convert MsWord first page to Image

I have an msword document that consists of some pages, i need convert only the first page to image and save it. Each page can consist of images, tables, text, etc. But i can't use clipboard buffer or any commercial software.
May be anybody know some other ways ?
You can turn on the "Generate thumbnail for Document" option and word will generate an image for you (that Windows 7 uses to show the large icon view of the document.
In word 2010, click File-Info
then the Properties Drop down
Then Advanced properties
Then Summary tab
and finally SHOW PREVIEW PICTURE
And what's worse, you can't automate it! Ugh, Something about a security risk.
When you do that, there will be an extra WMF file embedded within the DOCX that you can extract.
Print your first page to the Microsoft Office Document Image Writer.
It will give you a TIFF image.
EDIT
Alternatively, print to the Microsoft XPS Document Writer and then convert XPS to an image.

ReportViewer.PrintDialog() throws exception when printing to Adobe PDF

I am working on a WinForms app that uses the ReportViewer control to show a few Reporting Services reports. On these screens, we allow the user to print the report by calling the PrintDialog() method on the ReportViewer like so:
_reportViewer.PrintDialog();
This works fine in most cases, it brings up the standard windows print dialog, the user chooses what printer they want to print to, and it prints. However, when the user chooses to print to PDF using "Adobe PDF", it throws a Win32Exception: The specified datatype is invalid. The file dialog to choose where to save the pdf doesn't even come up.
This only happens with Adobe PDF printer. I installed NitroPDF and used their PDF printer and it works without a problem.
Does anybody have an idea on what could be causing this to happen?
Edit:
Here is the stack trace:
at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
at System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(PrintDocument document, PrintEventArgs e)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at Microsoft.Reporting.WinForms.ReportViewer.PrintDialog(PrinterSettings printerSettings)
at Microsoft.Reporting.WinForms.ReportViewer.PrintDialog()
This doesn't truly fix the problem but solves it in the users' eyes.
Trap the error thrown by the PDF Printer then invoke the Export to PDF functionality built into Reporting Services. It doesn't error in Winforms even when printing to the PDF Printer does. From the user perspective they "printed to pdf" like normal and the experience is identical. It's a work around that works. :-)
AFAIK the ReportViewer control just renders each page as a bitmap image. So when printing to PDF, if the resolution is high, it could be a huge bitmap. Maybe AdobePDF has problems with large bitmaps, Adobe have so many other bugs! Try lowering the resolution as a test?
I have an application that uses the ReportServer API to get the page bitmaps and chunks them into parts to be handled by a custom print processor
Could it be that the contents of the report are creating this problem. I mean to say that the report may contain certain characters that Adobe PDF printer is not able to recognize.
Can you try to print a very simple/basic/blank report and see if that works.

Categories

Resources