Print a ticket from apache flex - apache-flex

I want to print a ticket (10*5) cm on a labels printer from apache flex, i used this code
var printJob:FlexPrintJob = new FlexPrintJob();
printJob.start();
groupLabel.width=378;
groupLabel.height=188;
printJob.addObject(groupLabel, FlexPrintJobScaleType.MATCH_WIDTH);
printJob.send();
but in print preview from chrome or if i print it not set the page size to the detected and assume it a A4 page, when i print on the labels printer it uses about 5 labels in one print job.
how can i set the page size or is there any another way or component to do this in flex?

Related

Inconsistency of EVR and sink writer flipping screen captured images vertically

Using Media Foundation, I'm trying to capture the screen and record and render it with EVR at the same time. I've written a custom media source for this. It works almost perfectly.
The only problem is, by default without reversing the image, EVR renders the screen correctly, but the recorded video is vertically flipped. I'm literally passing the same IMFSample to the sinks. I reversed the image and it records just fine, but now EVR renders it vertically flipped. Why are EVR and sink writer inconsistent and is there a solution for this problem?
Other possibly useful information:
Capture method: Buffer swapping with DirectX9
Media type:
check = MFExtern.MFCreateMediaType(out var mediaType);
check = mediaType.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
check = mediaType.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, MFMediaType.RGB32);
check = mediaType.SetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, (uint)MFVideoInterlaceMode.Progressive);
check = mediaType.SetSize(MFAttributesClsid.MF_MT_FRAME_SIZE, (uint)mode.Width, (uint)mode.Height);
check = mediaType.SetRatio(MFAttributesClsid.MF_MT_FRAME_RATE, FrameRateNumerator, FrameRateDenominator);
check = mediaType.SetRatio(MFAttributesClsid.MF_MT_PIXEL_ASPECT_RATIO, 1, 1);
check = mediaType.SetBoolean(MFAttributesClsid.MF_MT_ALL_SAMPLES_INDEPENDENT, true);

EvoPdf - Error in "Local IIS" Could not start conversion. WinApi error 5 Check 'evointernal.dat' file execute permission but no error in "IIS Express"

I have ASP .Net framework 4.7 web forms application.
I am using EvoHtmlToPdf v8.0 to convert ASP .net form to pdf. I am using default generic version of EvoHtmlToPdf v8.0 which shall be working both in 32-bit and 64-bit environments.
I am getting below error at code htmlToPdfConverter.ConvertUrl(url);
I get this error only when running project in "Local IIS" but experience no error when I set it to "IIS Express" in project settings in Visual Studio
Could not start conversion. WinApi error code 5. Check 'evointernal.dat' file has execute permissions and that it exists near evohtmltopdf.dll or set the EvoInternalFileName property with the full path of the evointernal.dat file
Here is complete code of my asp .net c sharp code
public static byte[] convertToPdf(string url)
{
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Set license key received after purchase to use the converter in licensed mode
// Leave it not set to use the converter in demo mode
htmlToPdfConverter.LicenseKey = Constants.SystemSettings.PDF_LicenseKey;
// Set HTML Viewer width in pixels which is the equivalent in converter of the browser window width
htmlToPdfConverter.HtmlViewerWidth = Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerWidth)==0? HtmlViewerWidthDefault : Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerWidth);
// Set HTML viewer height in pixels to convert the top part of a HTML page
// Leave it not set to convert the entire HTML
if (Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerHeight) != 0)
{
htmlToPdfConverter.HtmlViewerHeight = Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerHeight);
}
// Set PDF page size which can be a predefined size like A4 or a custom size in points
// Leave it not set to have a default A4 PDF page
htmlToPdfConverter.PdfDocumentOptions.PdfPageSize = SelectedPdfPageSize();
// Set PDF page orientation to Portrait or Landscape
// Leave it not set to have a default Portrait orientation for PDF page
htmlToPdfConverter.PdfDocumentOptions.PdfPageOrientation = SelectedPdfPageOrientation();
// Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed
// Set this property to 0 if you don't need to wait for such asynchcronous operations to finish
htmlToPdfConverter.ConversionDelay = Utility.getConfirmInteger(Constants.SystemSettings.PDF_ConversionDelay);
return htmlToPdfConverter.ConvertUrl(url);
}
I solved issue by giving permissions to application pool identity account to the folder that contained binaries of project

Send future clients to right monitor in awesome?

I'm trying to implement a very customized implementation of awesome.
I have two monitors. I'd like to have my first client always open on the left monitor (a Chrome window in kiosk mode), then all clients after open up on the right monitor.
Are there any custom layouts that accomodate this?
I'd be willing to program it myself, but I'm not sure how to bind a script to some kind of "new client" event.
The new client event is the manage event. It is emitted whenever, well, a new client gets managed by awesome.
To send the first client that ever appears to screen 1 and all following ones to screen 2, you could do something like this:
local first = true
client.connect_signal("manage", function(c)
if first then
c.screen = 1
else
c.screen = 2
end
first = false
end)

VB.NET WebBrowser Object Captures Remote Web Page At Low Resolution

Background
I have an ASP.NET web application with a VB.NET back end. In this application users can create payment requests which must be approved by a manager before they are sent to accounts payable for further processing. Within my request page (the page where the user enters the request information) I have a button that links to a separate .aspx page which provides a print preview of the request. When the request is approved by all of the required approvers, I have a VB.NET function that contains a WebBrowser object that navigates to the print preview page behind the scenes and takes a snap shot of it, then saves it as a .tiff file to an internal file share which is then picked up by a internal process and imported into another internal application called OnBase to go through processing for accounts payable.
The Problem
My problem is that when the my function takes the snap shot of the print preview page, the saved tiff has a lower resolution than desired. In other words, it looks kind of crappy when it is viewed through OnBase and when it is printed out.
The Question
How do I increase the resolution of the generated .tiff file at the time that the snapshot of the webpage is generated?
The Code
Private Sub CaptureWebPage()
Try
Dim tiffFileName As String
tiffFileName = OnBasePath & "CheckRequest_" & CurrentRequestId & ".tiff"
Dim impersonateCode As New AliasAccount("TheUsername", "ThePassword")
impersonateCode.BeginImpersonation()
Dim browser As Windows.Forms.WebBrowser = New Windows.Forms.WebBrowser
browser.ScrollBarsEnabled = False
browser.ScriptErrorsSuppressed = True
browser.Navigate(OnBasePath & htmlFileName)
While browser.ReadyState <> Windows.Forms.WebBrowserReadyState.Complete
System.Windows.Forms.Application.DoEvents()
End While
System.Threading.Thread.Sleep(1500)
browser.ClientSize = New Size(950, 768)
Dim Height As Integer = browser.Document.Body.ScrollRectangle.Bottom
browser.ClientSize = New Size(950, Height)
Dim bmp As Bitmap = New Bitmap(browser.Bounds.Width, Height)
browser.DrawToBitmap(bmp, browser.Bounds)
If File.Exists(tiffFileName) Then
File.Delete(tiffFileName)
End If
If File.Exists(OnBasePath & htmlFileName) Then
File.Delete(OnBasePath & htmlFileName)
End If
bmp.Save(tiffFileName.ToString(), ImageFormat.Tiff)
bmp.Dispose()
impersonateCode.EndImpersonation()
Catch ex As Exception
Throw
End Try
End Sub
Additional Information
I have tried to use the .SetResolution method of my bitmap object, but it doesn't actually change the resolution of the generated .tiff file. I have tried to Google this numerous times find a solution, but haven't found anything useful.
Thanks In Advance
Screen "resolution" is much lower than print "resolution". Typically desktop monitors are around 100ppi, where a normal printer on a desk might be 600dpi.
The only suggestion I have for getting a higher resolution rendering of the web page would be configure what is grabbing the screenshot to use a resolution 3x what you are using now, and then set its zoom to 300%. Text elements and vector graphics will be rendered smoothly. Images will still be their web resolutions, and you may even lose image quality through interpolation when sizing up.
You could try and print the page to a virtual print driver in PDF format. I have found OnBase sometimes does strange things with image files, it doesn't like colour or grey scale TIFFs. Instead use JPEG for colour / grey scale.

WF4 - Display workflow image in asp.net and highlight an activity

I need to display current status of a document approval workflow task in asp.net web page with a specific activity highlighted.
I have seen the Visual workflow tracker example (in wf & wcf samples) but I have two issues,
I have to render workflow in asp.net not in a WPF app.
I don't need to display current status with workflow running, all activities that need to be highlighted are the ones that require user input. e.g. "waiting for approval from department head" etc.
If I could just convert the workflow XAML to JPG after highlighting a specific activity by activity id "that created a bookmark and waiting for resumption the bookmark" it would do the work.
check the attached file for required workflow image to be rendered on asp.net page:
Workflow with current activity highlighted (that is waiting to be resumed)
First load the workflow into the designer.
You should already know the 'activity' you want highlighted. There is selection service in the workflow you can use to select the appropriate model items. This example shows single selection, but there is multiple.
ModelService modelService = wd.Context.Services.GetService<ModelService>();
IEnumerable<ModelItem> activityCollection = modelService.Find(modelService.Root, typeof(Activity));
Selection.Select(wd.Context, activityCollection.ElementAt(5));
On the workflow designer there is a button to copy workflow as image or something along those lines. This link will show you how to get the jpg from the WorkflowDesigner.View.
http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/b781c8df-608a-485a-80e3-a795d800f08d
const double DPI = 96.0;
Rect size = VisualTreeHelper.GetDescendantBounds(view);
int imageWidth = (int)size.Width;
int imageHeight = (int)size.Height;
RenderTargetBitmap renderBitmap = new RenderTargetBitmap(imageWidth, imageHeight, DPI, DPI, PixelFormats.Pbgra32);
renderBitmap.Render(view);
BitmapFrame bf = BitmapFrame.Create(renderBitmap);
using (FileStream fs = new FileStream(#"c:\test.jpg", FileMode.Create))
{
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bf));
encoder.Save(fs);
fs.Close();
}
As an added note you should check out Kushals example:
http://blogs.msdn.com/b/kushals/archive/2009/12/22/visualworkflowtracking-aka-workflowsimulator.aspx

Resources