I'm trying send ActiveReports formatted reports to my company's RightFax server, and pre-set some of the fax fields, like FAX number, sender, and recipient. The RightFax documentation says that the document must include Embedded Codes to set these values, e.g. <TOFAXNUM:12345556789><TONAME:Recipient><FROMNAME:Sender>. I create a TextBox or Label in ActiveReports that contains this text. But the values are not set when RightFax receives the document and brings up the RightFax client UI. The Embedded Codes remain in the fax image. I have the RightFax printer driver set to HP LaserJet 4. I'm developing in C#, using Visual Studio 2010 Professional.
One suggestion on the web is to make sure the Embedded Codes are set in Courier or another "printer font". However, Visual Studio does not have "Courier" or "Times Roman", only MS true type versions of these standard fonts, "Courier New" and "Times New Roman".
This method of sending faxes is working with older software, that doesn't use ActiveReports, on another machine using the same RightFax server.
Any experience you can share interfacing ActiveReports to RightFax would be most appreciated.
Thanks,
Gregg Lobdell
You could accomplish your task by controlling the whole printing process and sending the escape sequence using Windows API. I assume you using ActiveReports 6 or section-based reports of ActiveReports 7.
In more detail:
create your own PrintDocument and define PrintPage handler
in the PrintPage handler send escape sequence to printer using Escape winapi call (see the example on CodeProject)
render the page itself by calling the Page.Draw()
As long as you use a true type font, the printer should recognize that font and be able to "read" the text in it. Only old bitmap fonts are fonts that might be not readable by the printer. Usually commonly used TT fonts on windows like "Courier New" or "Times New Roman", are already in the printer so they won't even be downloaded.
However, RightFax does have some documentation on escape codes here, so you might want to try using escape codes with ActiveReports. Also, here is an example of using the SystemPrinter object in ActiveReports6 to send escape codes directly to the printer without using any special API. You might try using that code and replacing the escape code there with ones that RightFax understands.
Finally, ActiveReports essentially prints by getting a graphics from the printer and drawing on it. Textboxes are real text drawn with appropriate text commands (i.e. text is not rendered as bitmaps). This is a normal way of printing in modern windows so any printer should see the text as normal text. You should be abel to see the same exact results by writing your own simple printing code in .NET and sending it to the RightFax driver. If it works there it will work in ActiveReports.
If it isn't working, and the escape code trick above won't work, I think contacting RightFax and asking them for insight into how to print to their driver from a .NET application would be the next logical step.
Hope this helps!
Related
I am trying to use the Winforms WebBrowser control to display a webpage that can be in many different languages. In one example, I have a HTML file that has characters in Farsi (examples are not limited to this, however - the file can have Mongolian, Japanese, or any other language).
When I try to Navigate() to this file in the WebBrowser control, it displays in a bunch of garbled characters (eg. ÓÇÚÊ). If I display the same file in Firefox, however, it will correctly display with all the the expected characters (eg. ساعت). I can also load the raw HTML file in Notepad++ and it seems to automatically detect the character set/encoding that is being used.
I have read numerous threads that talk about setting the WebBrowser encoding like so:
webBrowser.Document.Encoding = "UTF-8"
however given a set of HTML files, I have no way of telling what language it is written in and therefore no way to know the encoding. I can also confirm there is no "meta" tag within the HTML source that specifies any encoding.
Is there some magic going on behind the scenes of Firefox and Notepad++ to detect the correct character set and if so, how? Can someone tell me how I can get the WebBrowser control to behave in a similar way?
As #Bizan pointed out, in the absence of meta tags to describe the encoding, modern browsers seem to use heuristics to determine the language encoding.
Since the WebBrowser control is based on dated Internet Explorer technology, it appears there is no in-built logic to do these heuristics automatically.
The solutions are:
Implement your own heuristics method and then set the encoding manually.
Use the WebView control (as mentioned by #PanagiotisKanavos) which appears to be use the latest Edge browser. I have tested the pages in Edge and they work correctly. The minimum requirement for WebView is Windows 10 however, which will rule out any use-cases where you need your software to run on earlier versions of Windows.
Some background:
I’m developing a WPF application used for measuring and comparing data that’s delivered of a balance attached to it. It will be installed on a Windows 10 system delivered together with the balance. The application currently has to support eleven languages including Japanese and Chinese. One feature of the application is, that the values measured can be shown as a PDF report. For the creation of the PDF we use the PDFsharp library, for displaying the Telerik RadPdfViewer.
As mentioned before the application supports Japanese and Chinese language, therefore the PDF also needs the ability to show Japanese and Chinese letters. Earlier versions of the application were delivered on older versions of Windows, which meant we could use either the Microsoft YaHei or Arial Unicode MS font for this case. Unfortunately PDFsharp does not support TrueType font collections, which means I can’t use the version of Microsoft Yahei installed on the System and Arial Unicode MS is not available anymore.
Problem:
Since these two aren’t an option anymore I searched the internet for an alternative. After a quick search I noticed that Google’s Noto Sans might be what I need, so I tried to use it. Unfortunately it resulted in a ton of IndexOutOfRange Exceptions from the Telerik.Windows.Documents.Fixed.dll (all internally caught by the library) and does not show any letters on the generated PDF. It shows the PDF and the lines of the generated table, so I assume it’s some problem with the font. I used “Noto Sans CJK SC Regular” for Chinese and “Noto Sans CJK JP Regular” for Japanese.
After a long search session I still did not find another suitable font for Chinese. For Japanese I could use “Gen Shin Gothic”, but I’d prefer to use a font with the same style for both languages. There is the additional problem that the font should be usable without an additional license needed.
Unfortunately I can’t add code, since it’s a running project of my employer.
Questions:
Is there something I need to set/adjust for the Noto fonts to work properly?
Is there another usable sans-serif font for Chinese, where no additional licensing is needed? (It has to be capable of showing Latin letters too, since some stuff, like the product name is written that way)
Alternatively:
Is there a tweak to the PDFsharp library, so it can use TTC fonts?
A user posted their changes for TTC support on the PDFsharp forum:
https://forum.pdfsharp.net/viewtopic.php?p=9039#p9039
Another user found a suitable TTF file that works with PDFsharp:
https://forum.pdfsharp.net/viewtopic.php?p=11874#p11874
There is one TTF and its font name is "標楷體".
I'm writing a program that will (among other things) print out labels with variable information. I want to be able to format these labels (preferably in a GUI) at design-time, then have them print out at runtime. What tools/languages/projects can I use to accomplish this?
The label needs to include text and also Code39 or Code128 barcodes.
Printing will be done on a normal default printer, or possibly a label printer, unknown at this time.
Preference is for open-source, free projects, but any suggestions are appreciated. I'd also like to be able to distribute the program through xcopy, meaning no separate installations needed on the client.
EDIT: I'm now trying to do this using Microsoft Reporting services in local mode, but I'm still having problems getting the barcode to be readable.
There is a simple walkthrough of using our programmable ActiveReports product to do this here. Once you design the labels you can get them in PDF or print them directly (among other things). Another example of using ActiveReports to create a label maker program is here. That one uses the ActiveX/COM edition of ActiveReports but the concepts are still the same in the C#/.NET version.
We also provide a product named Data Dynamics Reports that uses a page-based metaphore for designing reports rather than the banded metephore like ActiveReports. It includes a label wizard which you can find out more about at this link.
Scott Willeke
GrapeCity inc.
Using Microsoft Reporting Services I can use a local report. Its not xcopy, but it is free and relatively easy. I just have to install report viewer on the client (and the barcode font), then I can even run the .exe from a network share.
Background:
I have PDF's I am programmatically generating. I need to be able to send the PDF directly to a printer from the server (not through an intermediate application). At the moment I can do all of the above (generate PDF, send to printer), but because the fonts aren't embedded in the PDF the printer is doing font substitution.
Why the fonts aren't embedded when generated:
I am creating PDF's using SQL Reporting Services 2008. There is a known issue with SQL Reporting Services in that it will not embed fonts (unless a series of requirements are met - http://technet.microsoft.com/en-us/library/ms159713%28SQL.100%29.aspx). Don't ask me why, the PDF meets all of MS's listed requirements and the fonts still show up as not embedded - there is no real control over whether the fonts are embedded, so I have accepted that this isn't working and moved on. The suggested workaround from Microsoft (Link under 'When will Reporting Services do font embedding') is to post process the PDF to manually embed the fonts.
Goal
Take an already generated PDF document, programmatically 'open' it and embed the fonts, resave the PDF.
Approach
I was pointed towards iTextSharp, but most of the examples are for the Java version and I'm having trouble translating to the iTextSharp version (I can't find any documentation for iTextSharp).
I am working on this post for what I need to do: Itext embed font in a PDF.
However for the life of me, I cannot seem to use the ByteArrayOutputStream object. It can't seem to find it. I've researched and researched but nobody seems to say what class it's in or where I find it so I can include it in the using statements. I've even cracked open Reflector and can't seem to find it anywhere.
This is what I have so far and it compiles etc. etc.
(result is my byte[] of the generated PDF).
PdfReader pdf = new PdfReader(result);
BaseFont unicode = BaseFont.CreateFont("Georgia", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
// the next line doesn't work as I need a ByteArrayOutputStream variable to pass in
PdfStamper stamper = new PdfStamper(pdf, MISSINGBYTEARRAYOUTPUTSTREAMVARIABLE);
stamper.AcroFields.SetFieldProperty("test", "textfont", unicode, null);
stamper.Close();
pdf.Close();
So can anybody either help me with using iTextSharp to embed fonts into a PDF or point me in the right direction?
I'm more than happy to use any other solutions other than iTextSharp to complete this goal, but it needs to be free and able to be used by a business for an internal application (i.e. Affero GPL).
This may not be the answer you are looking for (since you want to get your problems solved programmatically, not by an external tool).
But you can use Ghostscript commandline to embed missing fonts in retrospect to PDFs which have not embedded them:
gs \
-sFONTPATH=/path/to/fonts:/another/dir/with/more/fonts \
-o output-pdf-with-embedded-fonts.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
input-pdf-where-some-fonts-are-not-embedded.pdf
One important thing is that the missing fonts are all available in one of the directories pointed to by the -sFontPath=... switch.
Besides Ghostscript, it is also possible to use Poppler and Cairo. There is a command pdftocairo from Poppler that converts PDF to PDF via pdftocairo -pdf input.pdf output.pdf. It also considers font substitutions set in a Fontconfig configuration file. This is very helpful if you do not have all fonts on your system that are referenced in a PDF file, but know which other font you have installed is a good-looking replacement. After processing, the substitution font is embedded.
I had this problem on a Mac with a PDF I was submitting to IEEE. Using Adobe Reader and Preview, I was able to get around this. I think any pdf printer might work in place of Preview if you are on a PC.
Here are the steps I took. You can individually fix each figure, or fix the whole document.
Open at pdf file using Adobe Reader.
Right click on image, and click “Document Properties.”
Click “Fonts.” Check to see if the font isn’t embedded. Should say “Courier” or other font name.
If your pdf isn’t a standard page size, click on “Description” and look at the page size. Write this down. Ex. 19.4 x 5.22 in.
Open the pdf up in Preview. Go to File->Print. If using a pdf that isn’t a standard page size, click on Paper Size and choose custom. You will need to create a custom page size that is equal to the one you wrote down in step 4. Don’t forget to zero the margins to 0 for all sides. After doing that, you’ll need to set the scale of the print in the print dialog to 100%.
In the lower left of the print dialog (in Preview on a Mac), click “PDF” to print the PDF to a new PDF. Select the destination and print.
Open the new pdf up in Adobe Reader and verify that the fonts are now embedded.
I hope this helps.
I had this problem today with an existing PDF I uploaded to lulu.com to make a printed copy. It was rejected for not having all fonts embedded.
I found that if I opened it in Acrobat X and Saved out as postscript .ps file, then when I double clicked this .ps file in File Explorer, it opened in Acrobat X Distiller, and this automatically created a new PDF file with all fonts embedded!
Naturally this would mean you must have all the fonts needed on your computer. Otherwise a program like InFix can make font substitutions.
With C#, how can I print a PDF document (without any dialog boxes in the background) to an indicated printer?
I have used the following PDF library in the past to perform batch printing of PDF documents from a C# Windows Service.
http://www.quickpdflibrary.com/
It's a pretty decent library and if I remember correctly it only took a few lines of code to print the document. It worked very well and saved me a consider amount of time.
Also, the recommended link that discusses using DDE to launch a desktop application on a server to perform the printing is a bad idea. Adobe Reader probably doesn't support this and since it is a desktop application running in a windowless session you may run into problems with message boxes and dialog boxes. That solution just doesn't scale in my humble opinion.
here we go
Disclaimer: I work for Atalasoft
If you don't want to depend on Acrobat being on the server, you need to rasterize the PDF pages yourself and send them to the printer using the normal .NET printing API. We have a product that can rasterize PDF that uses the Foxit engine underneath. It deploys as a normal .NET assembly and doesn't require any other software to be installed.